docx
What it does
This tool allows you to create, read, edit, and organize Word documents (.docx). You can use it to generate professional reports, letters, or any document requiring specific formatting.
When to use it
- βCreating a new Word document with specific formatting.
- βEditing an existing Word document to add or remove content.
- βExtracting information from a Word document into another format.
Skill link
https://github.com/anthropics/skills/blob/main/skills/docx/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCreate a monthly report with a table of contents, page numbers, and a header with the company logo.β
5 new skills a week. 1 minute to read.
How it works
The tool works by manipulating the internal files of Word documents (.docx), which are like packages of text and formatting. It can read content, make direct changes to files, or create new documents based on instructions.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
DOCX creation, editing, and analysis
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.
Creating with docx-js β gotchas
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 defaults to A4. For US Letter set
page: { size: { width: 12240, height: 15840 } }(DXA; 1440 = 1β³). - Landscape: pass portrait dimensions and
orientation: PageOrientation.LANDSCAPEβ docx-js swaps width/height internally. - Tables need dual widths: set
columnWidthson the table ANDwidthon every cell, both inWidthType.DXA(PERCENTAGE breaks in Google Docs). Column widths must sum to the table width. - Table shading: use
ShadingType.CLEAR, neverSOLID(renders black). - Lists: never insert
β’literally; use anumberingconfig withLevelFormat.BULLET. ImageRunrequirestype:("png","jpg", β¦).PageBreakmust be inside aParagraph.- Never use
\nβ use separateParagraphelements. - TOC: headings must use built-in
HeadingLevel.*; custom heading styles needoutlineLevelset or they won't appear. - Don't use a table as a horizontal rule β use a paragraph bottom border instead.
- Dot-leader / right-aligned-on-same-line: use
PositionalTab(alignment: PositionalTabAlignment.RIGHT,leader: PositionalTabLeader.DOT) inside aTextRun, not literal.or space padding.
Verify the output
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).
Editing existing documents
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
# edit unpacked/word/document.xml in place β do NOT reformat or pretty-print
(cd unpacked && rm -f ../out.docx && zip -Xr ../out.docx .)
python scripts/office/validate.py out.docx --original doc.docx # XSD checks; --auto-repair fixes common issues
# redlining? add --author "<the name you redlined under>" to check every edit is tracked
Word splits text across many <w:r> runs (revision ids, spell-check markers), so a phrase you can see in the document often doesn't exist as a contiguous string in the XML. merge_runs.py merges adjacent identically-formatted runs in word/document.xml without changing content or rendering; it also accepts a .docx directly (python scripts/merge_runs.py doc.docx -o merged.docx).
Tracked changes: when redlining, validate with --author "<the name you redlined under>" (needs --original) β it reports any text you changed without a <w:ins>/<w:del> around it, which is easy to do by accident and invisible in the accepted view. Wrap runs in <w:ins>/<w:del> with w:id, w:author, w:date attributes. Inside <w:del>, the text element is <w:delText>, not <w:t>. A deleted paragraph mark (<w:pPr><w:rPr><w:del w:id=".." w:author=".." w:date=".."/></w:rPr></w:pPr>) means "merge this paragraph into the next" β so deleting a paragraph outright is that plus a <w:del> around every run. The <w:del/> must come before the rPr's other children; their order is schema-enforced.
To produce a clean copy with all tracked changes accepted: python scripts/accept_changes.py in.docx out.docx.
β¦
FAQ
How does the tool handle tables?
For tables, you need to define the width of columns and each cell. The tool uses a format called DXA for this. It's important that the sum of the column widths equals the total table width.
Can I add images?
Yes, but when adding images, you need to specify the file type (like 'png' or 'jpg').
How do bulleted lists work?
To create bulleted lists, you should not use the 'β’' symbol directly. Instead, the tool uses a special configuration called 'numbering' to ensure lists are formatted correctly.
Details
Original description by the author
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .
repo: anthropics/skills
Popularity
- GitHub stars
- 181k
- Ranking position
- #642
- License
- β
- Updated
- 10/9/2026
Comments
- β¦
More skills from this repository
academy-guide
181kHas your agent recommend courses and tutorials for learning Claude. It's useful when you have questions about how to use Claude or its products.
algorithmic-art
181kHelps your agent create art using code, generating unique images. It's useful when you want original computer-generated art.
brand-guidelines
181kHas your agent apply Anthropic's brand colors and visual style to materials. It's useful for maintaining the company's visual identity across projects.
canvas-design
181kHelps your agent create beautiful visual art in files. It's useful when you ask for a poster, art, or any static design.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.