Back to the collection
docx·Productivity

Create and edit Word files with docx, then check revisions and layout

On this page

docx handles Word creation, reading, and editing through different workflows. New files can be generated with the docx library. Preserving an existing document often requires editing its internal XML. Pandoc can extract text for inspection. State whether you want a rebuilt report or a few targeted changes to the original; these are not interchangeable requests.

Install and invoke

Send these two commands in the Claude Code chat input, one at a time. They are plugin commands, not shell commands for your operating system. The second installs the official collection containing docx.

Prompt
/plugin marketplace add anthropics/skills
/plugin install document-skills@anthropic-agent-skills

In your project conversation, ask Claude to “use docx” and supply the task or files. The prompt below is an editable starting example. Installing the collection supplies instructions and resources; it does not supply your source material or guarantee that every runtime dependency is installed locally. If the skill is missing, check that its plugin is installed, enabled, and loaded in the current session. Do that before troubleshooting the requested output.

Start with a short briefing

Prompt
Use docx to turn notes.md into a two-page A4 project briefing named briefing.docx.
Preserve supplied names and numbers. Use real heading styles, one progress table, and page numbers.
Mark missing information. Validate the document and render every page to inspect tables and page breaks.
Deliver the editable Word file and a PDF preview without overwriting notes.md.

Specify the audience, page size, orientation, length, and mandatory content. For a table of contents, use actual Word heading levels rather than enlarged text. For tables, describe the columns and expected widths. Table width and cell widths need to agree, and page breaks need proper paragraph structure.

The skill describes a prepared environment with dependencies already available. Your local Claude Code project may still lack docx, Pandoc, LibreOffice, or Poppler. Identify whether a missing tool affects creation, conversion, or rendering. Installing the skill is not the same as installing an office-processing environment.

Preserve review information when editing

For revisions, supply the original file, the requested scope, and the reviewer's name. Explicitly request tracked changes or comments when they matter. Word can split an apparently continuous phrase across several text runs, so a plain string search may miss it. The skill includes helpers for merging compatible runs and validating the package.

Ask for pandoc --track-changes=all when reviewing insertions, deletions, and comments. Pandoc's default accepted-change text view does not retain all review information. If you also need a clean copy, save it separately from the version preserving the review history. Deleted paragraphs can leave empty items in some extracted or converted views, so inspect the document structure before treating them as source defects.

Verify content completeness first, then inspect rendered pages for isolated headings, split tables, page numbers, and font changes. Structural validation does not establish attractive pagination, and a correct PDF preview does not eliminate font differences on another computer. Open the editable file in the application where it will be used and keep both the Word version and its fixed-layout preview.

Distinguish editing an original from creating a new file

For a contract with comments, provide the original DOCX, the exact clause, the replacement wording, and the tracked-change author. Ask the agent to check whether the target spans multiple XML runs before editing and validating it. A global string replacement can damage numbering, formatting, or comments. Save a separate output and keep the original for comparison.

For a new brief, review structure and heading levels before rendering every page. If a table spills across pages, adjust widths, paragraph spacing, and page breaks before shrinking text beyond readability. If the environment lacks a renderer, state that visual QA remains open; a successfully written DOCX is not proof of a good final layout.

Make the file survive a round trip

After generating a DOCX, have the agent reopen its own output and confirm that headings, tables, notes, and figures remain. Then render pages for visual inspection. When editing an original, compare input and output and ensure changes stay within scope. Word's XML structure can preserve extracted text while losing formatting or tracked-change markers; plain text and PDF each reveal only part of the result. For legal or audit-sensitive revision requirements, a person familiar with that workflow should inspect it in the target application.

Open the deliverable in its target editor

A DOCX with complex footnotes and tables may extract as text yet still trigger a Microsoft Word repair dialog. One user compared the XML before and after Word repaired a long generated document. Before sharing a client deliverable, open it in the Word version the recipient uses and inspect the repair prompt, footnote numbering, and editable tables. If repair appears, keep the input and generation record while isolating the structural cause.

How did your first task go?

These choices help us understand where readers get stuck through site analytics. Blocking analytics may prevent delivery; use email for a specific issue.

References

  1. docx — SKILL.mdAnthropic
  2. anthropics/skills READMEAnthropic
  3. Anthropic Agent Skills marketplaceAnthropic
  4. Pandoc User’s Guide: --track-changesPandoc contributors
  5. docx skill: footnote separators and table XML patterns trigger Word repair dialoginternationaldevelopment
Found outdated or incorrect information? Let us know