
Docx Format
This handles precise Word document formatting using python-docx, which matters because manual formatting across dozens of pages is tedious and error prone. You'd reach for this when standardizing academic papers, fixing mixed Chinese-English fonts, or bulk-applying formatting rules. The skill emphasizes processing both paragraphs and tables (where content often hides in official documents), properly setting CJK fonts with qn('w:eastAsia'), and using uv run to avoid dependency issues. It includes ready-to-run templates for common tasks like bibliography formatting and markdown-to-docx conversion. The decision tree is practical: analyze unknown formats first, then apply official or academic standards. One thing to appreciate is the explicit checklist reminding you to backup files and close Word before running scripts, which saves you from the classic "file is locked" headache.
- skills.sh installs
- 262
- GitHub stars
- 51
- last updated
- Jun 3, 2026
Install
$ npx -y skills add ninestep/docx-format-skill --skill docx-format --agent claude-codeInstalls into .claude/skills of the current project.
Files
Word 文档格式处理
使用 python-docx 库精确操作 Word 文档格式,适用于格式分析、格式规范化、批量修改。
核心规则
被调用时立即执行:
- 确认文件路径:询问用户 Word 文档的完整路径
- 明确需求:确认是分析格式还是修改格式,目标规范是什么
- 选择模板:根据需求选择合适的代码模板或脚本
- 生成脚本:创建独立的 Python 脚本文件
- 执行验证:使用
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')
Sponsors
Details
- Repository
- github.com/ninestep/docx-format-skill
- Categories
- Code Review & Quality, Office & Documents
- First seen
- Jun 3, 2026