What it is
The docx skill guides an AI agent through creating, editing, and reading Word documents. A .docx is treated as a ZIP archive of XML files. New documents are written with a docx (npm) script, existing ones are edited by unzipping and modifying word/document.xml, and content is read with pandoc. It also covers tracked changes, comments, validation, and rendering output for visual checks.
Who it's for
- Developers or agents generating Word documents such as reports, memos, and letters
- Users who need to edit existing .docx files, including tracked changes (redlining)
- Users adding comments to Word documents programmatically
- Users extracting or reorganizing content from .docx or .dotx files
Requirements
Requirements
- docx (npm package, stated as preinstalled; run
npm install docxonly if require('docx') fails) - pandoc
- LibreOffice (soffice)
- pdftoppm (Poppler)
- Python (to run the bundled scripts such as scripts/office/soffice.py, merge_runs.py, validate.py, accept_changes.py, comment.py)
Examples
Render a created document to check it
bashpython scripts/office/soffice.py --headless --convert-to pdf output.docx
pdftoppm -jpeg -r 100 output.pdf page
ls page-*.jpg # then Read the imagesWhat it does: After writing a .docx, convert it to PDF and then to JPEG page images to visually verify the output.
Edit an existing document's XML
bashunzip -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 issuesWhat it does: Unpack the docx, remove symlinks, merge fragmented runs so text is searchable, edit document.xml, rezip, and validate against the original.
Add comments with the helper script
bashpython scripts/comment.py unpacked/ "Fees & expenses cap is too low"
python scripts/comment.py unpacked/ "Agreed" --parent 0
python scripts/comment.py contract.docx "This cap is too low" -o annotated.docxWhat it does: The script creates the cross-linked comment files and prints the range/reference markers to place in word/document.xml so the comment is visible.
Accept all tracked changes
bashpython scripts/accept_changes.py in.docx out.docxWhat it does: Produces a clean copy of the document with all tracked changes accepted.
Convert a legacy .doc file
bashpython scripts/office/soffice.py --headless --convert-to docx file.docWhat it does: Legacy .doc files must be converted to .docx before editing.
Pros & cons
Pros
- Pro:Documents common docx-js pitfalls (A4 default page size, dual table widths, ShadingType.CLEAR, ImageRun type, PageBreak inside Paragraph)
- Pro:Includes a render-and-inspect verification workflow using PDF and JPEG conversion
- Pro:Provides helper scripts for merging fragmented runs, validating, accepting tracked changes, and adding comments
- Pro:Supports tracked-change validation with --author to catch untracked edits
Cons
- Con:docx-js cannot open existing files, so editing requires manual XML manipulation
- Con:Accepting tracked changes can leave empty paragraphs (pandoc never joins them; accept_changes.py fails in some cases)
- Con:Comments are invisible until the anchor markers are manually added to document.xml
- Con:Licensed as Proprietary (see LICENSE.txt) and not intended for PDFs, spreadsheets, or Google Docs
Images
