Precise Word (.docx) formatting toolkit for analyzing, batch-editing, and standardizing fonts, indents, and spacing via python-docx.

skills.sh installs
263
GitHub stars
51
last updated
Jun 3, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers format analysis, batch formatting, official-document and academic standards, mixed Chinese-English fonts, and reference-style edits
  • Includes scripts/analyze.py, format_official.py, format_academic.py, and md_to_docx.py, plus templates that also process table cell content
  • Requires running scripts via uv run --with python-docx python3 and sets East Asian fonts separately using qn('w:eastAsia')
  • Designed for editing existing .docx files with python-docx; .doc is unsupported and Markdown conversion is handled directly

Install

$ npx -y skills add ninestep/docx-format-skill --skill docx-format -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Word 文档格式处理

使用 python-docx 库精确操作 Word 文档格式,适用于格式分析、格式规范化、批量修改。

核心规则

被调用时立即执行:

  1. 确认文件路径:询问用户 Word 文档的完整路径
  2. 明确需求:确认是分析格式还是修改格式,目标规范是什么
  3. 选择模板:根据需求选择合适的代码模板或脚本
  4. 生成脚本:创建独立的 Python 脚本文件
  5. 执行验证:使用 uv run 执行并检查结果

强制性约束:

  • ✓ 必须使用 uv run --with python-docx python3 script.py
  • ✓ 必须处理 doc.paragraphs 和 doc.tables(文档正文常在表格内)
  • ✓ 必须分设 中英文字体(使用 qn('w:eastAsia'))
  • ✓ 必须询问 用户文件路径和输出路径
  • ✗ 禁止使用 直接 python 命令(缺少依赖)
  • ✗ 禁止遗漏 表格内容处理(常见错误)

何时使用

触发场景:

  • 分析 Word 文档格式(字体/字号/缩进/行距)
  • 批量修改文档格式
  • 统一排版规范(学术论文、报告等)
  • 处理中英文混排字体
  • 修改交叉引用/参考文献样式

触发关键词:修改 Word 格式、统一字体、调整缩进、分析文档格式、参考文献格式

决策树

用户需求是什么?
├─ 不清楚当前格式 → 使用 scripts/analyze.py
├─ 应用公文标准 → 使用 scripts/format_official.py
├─ 应用学术标准 → 使用 scripts/format_academic.py
├─ 统一正文格式 → 使用【快速模板:批量格式化】
├─ 修改参考文献 → 使用【快速模板:参考文献处理】
└─ 自定义需求 → 基于【基础模板】组合

快速开始

基础模板

from docx import Document
from docx.shared import Pt
from docx.oxml.ns import qn

doc = Document('input.docx')

Details

Repository
github.com/ninestep/docx-format-skill
Category
Office Files & Slides
First seen
Jun 3, 2026

Similar to Docx Format

More Office Files & Slides