docx · Word Document Toolkit

docx creates, reads, edits, and reviews Word documents (.docx/.dotx). New documents are generated with docx-js scripts (plus a built-in checklist of layout pitfalls: page size, dual table widths, list numbering, TOC outlines); editing existing files goes through unzip → edit word/document.xml → zip (docx-js can't open existing files); reading goes through pandoc to Markdown.
It supports tracked changes (review with per-author validation), comments (auto-generated six-file linkage), and clean accepted copies — with every output rendered to PDF for visual verification.
Example invocation: "Turn this report into a Word document with a table of contents."
Full brief
Positioning
docx is the general-purpose Word document toolkit: creating, reading, editing, and reviewing .docx/.dotx files, with a dedicated path per task. It does not handle PDFs or spreadsheets.
Core capabilities
- New documents: generated by
docx(npm) scripts with a built-in pitfall checklist — A4 default vs Letter DXA sizes, landscape via portrait dimensions + orientation, table column widths AND cell widths in DXA,ShadingType.CLEAR(never SOLID), lists vianumberingconfig,ImageRunrequirestype:, page breaks inside paragraphs, TOC needs built-in heading styles oroutlineLevel. - Editing existing documents:
unzip→merge_runs.pyto coalesce fragmented runs (Word splits visible text across runs; only merged text is findable) → editword/document.xmlin place (no reformatting) →zip; legacy.docconverts first; symlinks stripped from untrusted files. - Reading:
pandoc -t markdown file.docxfor extraction. - Tracked changes: edits wrapped in
w:ins/w:delwith id/author/date;validate.py --authorchecks every edit is tracked;accept_changes.pyproduces a clean accepted copy. - Comments:
comment.pyauto-generates the six cross-linked comment files (directory or direct mode); anchor markers placed in document.xml. - Output verification: soffice to PDF + pdftoppm rendering — every document is visually checked.
Workflow
- Create: write the docx-js script → generate → render and visually verify
- Edit: unzip → merge_runs → edit XML in place → zip → validate (XSD;
--auto-repairfor common issues) → render and verify - Review: tracked edits / comments →
--authorvalidation → clean accepted copy
Inputs & outputs
| Input | Notes |
|---|---|
| Requirements / template | Content and layout for new documents |
| Existing document | .docx / .dotx (legacy .doc converts first); external files treated as untrusted |
Output: .docx file + rendered verification images (PDF/JPG); author-validation report for tracked reviews.
Boundaries with adjacent skills
- md2resume (office docs): a fixed template pipeline for Markdown → one-page Chinese resumes; docx is the general Word creation/editing/review toolkit.
Fit
- Formal reports, memos, letters, and templates with TOCs, page numbers, tables, letterheads
- Editing existing contracts with tracked-change review
- Bulk find-and-replace, image swaps, content reorganization
- Commenting and closing the review loop
Before you start
- Dependencies:
docx(npm, preinstalled), pandoc, LibreOffice (soffice), pdftoppm. - No API key; no PDFs, spreadsheets, or Google Docs.
- Tracked review needs the reviewer's name (
--author) to validate complete change tracking.
docx is part of the Aiglade Skill library. Invoke it from the Aiglade chat box in plain language.