document-docx
Installation
SKILL.md
Document DOCX Skill - Quick Reference
This skill covers the specialist .docx lanes: docxtpl template pipelines, python-docx structural edits and extraction, LLM/RAG ingestion, and accessibility/EAA compliance.
Boundary: when the official Anthropic docx skill is available, prefer it for plain create/edit (docx-js), tracked-change (redline) authoring via <w:ins>/<w:del> with validate.py, and comment authoring. When the user asks for "a document" without naming a format and a document connector or artifact type is available, prefer that over generating a .docx.
Core Decision Rules
- Non-developers own the layout in Word, and code supplies data:
docxtpl. Code decides the structure:python-docx(Python) ordocx(Node). - Render templates fail-closed. docxtpl's defaults render a missing variable as blank and insert
&/<unescaped, so the file opens fine and passes a tag scan. Usescripts/docx_render_template.py(StrictUndefined + autoescape); see references/template-workflows.md. - Tracked changes: never promise high-level library support, and never fake redlines with colour or strikethrough. Route authoring to the official
docxskill's OOXML workflow. See references/tracked-changes.md. - Semantic HTML from a trusted file:
mammoth, then sanitise (it does no sanitisation). Markdown/JSON for RAG: a Markdown converter orscripts/docx_extract.py; see references/llm-extraction-workflows.md. - DOCX feeding a KB or index: tables inside content controls are silently missing from
Document.tables, tables pasted as images have no text, tracked changes need an explicit accept/original policy, and filenames can lie. Run the table-count detection check in references/docx-extraction-failure-modes.md before indexing any file (load it whenever DOCX is ingestion input). - PDF output: Word automation for the highest fidelity; LibreOffice headless for CI and batch.
.doc: convert to.docxfirst..docm/.dotm: treat the macros as untrusted and never execute them..docxis the editable source; PDF is the release artifact.