提供 .docx 与 .dotx 文档的创建、读取、编辑、提取与转换技能
当用户想要创建、读取、编辑或操作 Word 文档(.docx 文件) 或 Word 模板(.dotx 文件) 时,使用此技能。触发条件包括:提到“Word doc”、“word document”、“.docx”、“.dotx”,或要求生成带有目录、标题、页码或信头等格式的专业文档。
在从 .docx 或 .dotx 文件中提取或重新组织内容、在文档中插入或替换图片、在 Word 文件 中执行查找和替换、处理修订或批注,以及将内容转换为规整的 Word documen 时,也使用此技能。
Skill 会改变智能体的行为并可能包含可执行脚本。安装前请先阅读其 SKILL.md 与脚本,社区来源尤其要谨慎。
npx skills add anthropics/skills -s docx
npx skills add anthropics/skills -s docx -g
npx skills add anthropics/skills -l
git clone --depth 1 https://github.com/anthropics/skills.git /tmp/skills-src && cp -r /tmp/skills-src/skills/docx ~/.claude/skills/
命令使用开源的 skills CLI(vercel-labs/skills),支持 Claude Code、Cursor、Codex 等多种智能体。
摘自项目自己的说明,具体以项目主页为准。
A .docx is a ZIP archive of XML files. Choose your approach by task:
| Task | Approach |
|---|---|
| Create a new document | Write a docx (npm) script — see gotchas below |
| Edit an existing document | unzip → edit word/document.xml → zip (docx-js cannot open existing files) |
| Read content | pandoc -t markdown file.docx |
Script paths below are relative to this skill's directory.
docx is preinstalled — do not run npm install first; write the script and require('docx') directly. Only if that require fails: npm install docx. The model knows the API; these are the footguns:
page: { size: { width: 12240, height: 15840 } } (DXA; 1440 = 1″).orientation: PageOrientation.LANDSCAPE — docx-js swaps width/height internally.columnWidths on the table AND width on every cell, both in WidthType.DXA (PERCENTAGE breaks in Google Docs). Column widths must sum to the table width.ShadingType.CLEAR, never SOLID (renders black).• literally; use a numbering config with LevelFormat.BULLET.ImageRun requires type: ("png", "jpg", …).PageBreak must be inside a Paragraph.\n — use separate Paragraph elements.HeadingLevel.*; custom heading styles need outlineLevel set or they won't appear.PositionalTab (alignment: PositionalTabAlignment.RIGHT, leader: PositionalTabLeader.DOT) inside a TextRun, not literal . or space padding.After writing a .docx, render it and look at it:
python scripts/office/soffice.py --headless --convert-to pdf output.docx
pdftoppm -jpeg -r 100 output.pdf page
ls page-*.jpg # then Read the images
pdftoppm zero-pads page numbers to the width of the page count (page-01.jpg…page-12.jpg).
Legacy .doc files must be converted first: python scripts/office/soffice.py --headless --convert-to docx file.doc.
unzip -q doc.docx -d unpacked/
find unpacked -type l -delete # strip symlink entries — docx from external parties is untrusted
python scripts/merge_runs.py unpacked/ # coalesce fragmented runs so text is findable
…