The docx skill is the Word document guide from Anthropic’s public skills repository, one of the document skills that power Claude’s file creation features. It triggers whenever a task involves a .docx or .dotx file, or a report, memo, letter or template wanted as a Word file, and picks the approach by task: write a script against the docx npm library to create a new document, unpack the archive and edit word/document.xml to change an existing one, and run pandoc to read one as Markdown.
Most of the guide is a list of docx-js footguns: A4 as the default page size, tables that need widths on both the table and every cell, shading that renders black, literal bullet characters, and heading styles that need their own font, spacing and keepNext. It then covers rendering the output to images to check it, redlining with tracked changes, accepting changes into a clean copy, and adding threaded comments, with Python scripts for merging fragmented runs, adding comments, accepting changes and validating the result against the OOXML schemas.
What You Get
- A SKILL.md guide with a task table for creating, editing and reading .docx files
- A list of docx-js gotchas covering page size, landscape, table widths, shading, lists, images, page breaks, headings, tables of contents and dot leaders
- A render-and-look step that converts the document to PDF with LibreOffice and to JPEG pages with pdftoppm
- merge_runs.py, which merges Word’s fragmented runs so visible text can be found in the XML
- comment.py, which writes the comment parts, relationships and content types and prints the markers to place in document.xml
- accept_changes.py, which accepts all tracked changes through LibreOffice to produce a clean copy
- validate.py, which checks the document against bundled OOXML schemas, can auto-repair common issues, and with —author reports edits made without tracked changes
Common Use Cases
- Generating a formatted report, memo or letter as a Word file with headings, tables and a table of contents
- Redlining a contract with tracked insertions and deletions under a named author
- Adding review comments and replies to an existing document
- Find-and-replace or content edits in a .docx without breaking its formatting
- Converting a legacy .doc file to .docx, or reading a document’s text as Markdown
What Makes It Unique
Like the pdf skill from the same repository, it is Anthropic’s own reference for a complex skill used in production, but where the pdf skill routes tasks across many libraries, this one splits the work by whether the document exists yet: docx-js only for new files, direct XML edits for existing ones. Rather than teaching the docx API, it assumes the model knows it and lists only the mistakes that produce broken output. Its redlining check is unusual: it undoes the new tracked changes and compares the text with the original, so any edit made without a w:ins or w:del is reported.
Under The Hood
The guide has the agent write and run its own Node script requiring the docx package, which it expects to be preinstalled and installs from npm only if the require fails, and it shells out to pandoc, zip, pdftoppm and LibreOffice. The bundled Python scripts, which use defusedxml, unpack documents with a safe extractor that refuses symlinks and paths outside the target folder, rewrite XML parts in the unpacked folder, and rezip the result, so they write files next to the documents they work on. soffice.py runs LibreOffice headless; before rendering to PDF or images it copies the document with links to outside files cut, and where the sandbox blocks Unix sockets it writes a small C shim to the temp folder, compiles it with gcc and loads it with LD_PRELOAD. accept_changes.py writes a LibreOffice Basic macro into a profile under /tmp and runs it to accept every tracked change. comment.py copies its XML templates into the document. The shared office folder also carries the XSD schemas, the docx and redlining validators, and pptx helpers and validators that this skill’s guide does not use.