DOCX
Create Word documents or edit existing files with attention to structure, tracked changes, and page layout.
npx skills add anthropics/skills --skill docx What it does
A Word document contains styles, package relationships, comments, and layout rules beyond plain text. The DOCX skill separates new-document creation from existing-document editing and asks the agent to inspect rendered pages.
What changes after install
- Uses docx-js for new files and package editing for existing Word documents.
- Covers document headings, tables, numbering, comments, and tracked changes.
- Includes structural checks and rendered-page inspection.
Install
Run this command with Node.js 22.20 or later and select your agent in the Skills CLI.
npx skills add anthropics/skills --skill docx Before using DOCX
- New-document generation uses Node.js and the docx npm package. Reading and rendering workflows use Pandoc, LibreOffice and Poppler; the bundled document helpers require Python.
Read the reviewed setup instructions for the selected workflow.
When to use it
- Creating a Word report with headings, tables, and consistent formatting.
- Editing an existing DOCX or DOTX while retaining its document conventions.
When not to use it
- Using a Word-generation library as if it could safely open and modify every existing document.
- Extracting rows from a scanned PDF when no editable Word source is available.
- Maintaining formulas in a budget that readers need to recalculate after changing quantities.
A worked example
Give the agent terms.docx and ask: “In the Payment terms row, change 30 days to 45 days. Track the edit under Morgan Lee. Keep the separate 30-day cancellation period and all reviewer comments. Return terms-review.docx.”
Keep the original for comparison. Unpack a working copy and locate the table row by its label. Check the adjacent cell before changing the number. Record the old number as a tracked deletion and the new number as a tracked insertion, then repack the copy. A global replacement would also change the cancellation period.
From the skill directory, with both files there, run python scripts/office/validate.py terms-review.docx --original terms.docx --author "Morgan Lee". Open the result in Word with revisions visible. In the Payment terms row, the reviewer should see 30 deleted and 45 inserted under Morgan Lee’s name.
Troubleshooting
- A visible phrase cannot be found in the XML. Word may split it across text runs. Use the bundled
merge_runs.pyon the working copy to join adjacent runs with identical formatting. If the phrase crosses a style change, inspect both runs before editing. - A comment has text but no margin marker. The comment helper prints markers to place in the document. Put the range around the intended words and insert the matching reference. Reopen the copy and click the passage.
- A heading is missing from the table of contents. Inspect its paragraph style. Apply the appropriate built-in heading level or set the outline level on its custom style. Check that the entry leads to that heading.
How it chooses an approach
If the user only needs to read the wording, extract it with Pandoc. For a report written from scratch, use the docx npm package and define the page size and heading styles before adding content.
If reviewers need their original comments, numbering or revision history, edit the existing package. Convert a legacy .doc to .docx before unpacking it.
When to use another skill
- Give PDF the signed PDF when the task is to extract clauses from that copy.
- Give XLSX the quantities and rates when the recipient needs an editable cost model.
- Give Internal Comms the approved terms and intended audience when the deliverable is a staff announcement.
What to check after it runs
- On separate copies, accept and reject the revision. Payment terms should read 45 and 30 days respectively. Cancellation should read 30 in both.
- Inspect the rendered pages for a split table row or clipped text. Open the review copy in Word and click each original comment to confirm it still highlights the intended words.
FAQ sources: Word opening error · #12, missing comment · #1733, empty contents after conversion · #1002, Windows rendering tools · #2206.
Related workflows
FAQ
- Why can Pandoc read my edited document when Word refuses to open it?
- In issue #12, adding a comment also reformatted the underlying XML. Pandoc could still extract the text. Start from the original file, preserve the XML whitespace during the edit, and reopen the repacked document in Word before handing it back.
- Why did a reviewer’s comment disappear even though the file passed validation?
- Issue #1733 describes an edit that kept the comment text but removed its anchor. Check the original passage against the revised one. The range markers and reference must still point to the comment. Open the file in Word and select that passage to verify the reviewer’s note.
- Why is the table of contents empty after conversion to Google Docs?
- In issue #1002, Word displayed the table of contents, but Google Docs relied on cached entries that were absent. Use the documented heading levels when creating the Word file. If recipients will convert it, test that conversion and follow a heading link in the converted copy.
- How can I review page layout on Windows if the rendering tools are missing?
- Issue #2206 describes a machine without LibreOffice or Poppler. The guide’s route needs both to produce page images. If Word is available, inspect every page there and say which application you used. If nobody has inspected the pages, leave visual verification open.