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-code

Installs into .claude/skills of the current project.

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')

Sponsors

Details

Repository
github.com/ninestep/docx-format-skill
Categories
Code Review & Quality, Office & Documents
First seen
Jun 3, 2026
1octagonai avatarsec-cash-flow-reviewoctagonai/skillsExtract and analyze cash flow trends and working capital changes from SEC filings using Octagon MCP. Use when researching operating cash flow, investing activit262skills.sh installs
2octagonai avatarearnings-competitive-reviewoctagonai/skillsAnalyze management's discussion of competitive landscape, market positioning, and strategic differentiation from earnings call transcripts.261skills.sh installs
3bobmatnyc avatarapi-security-reviewbobmatnyc/claude-mpm-skillsAPI security checklist for reviewing endpoints before deployment. Use when creating or modifying API routes to ensure proper authentication, authorization, and 257skills.sh installs
4yuque avataryuque-personal-style-extractyuque/yuque-pluginyuque personal style extract257skills.sh installs
5pproenca avatarbug-reviewpproenca/dot-skillsUse this skill when a user asks to review a pull request for bugs, wants AI code review focused on correctness issues, or runs /bug-review. Trigger on PR review256skills.sh installs
6vivy-yi avatarcontent-reviewvivy-yi/xiaohongshu-skillsUse when needing to understand content moderation policies, avoid content removal, or successfully navigate Xiaohongshu's content review process256skills.sh installs