
document-docx
Builds docxtpl templates, DOCX extraction for RAG, and EAA accessibility checks. Use when templating Word or extracting tables; plain edits and redlines: official docx skill.
- Installs
- 475
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill document-docx- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads document-docx automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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.
Quick Reference
| Task | Tool | When |
|---|---|---|
| Template fill, mail merge | docxtpl + scripts/docx_render_template.py | Word-authored templates, batch documents |
| Structural edits in Python | python-docx (references/docx-patterns.md) | Styles, tables, sections, fields, hyperlinks |
| Comments | python-docx add_comment (version-gated) or the official docx skill | Review notes without revisions |
| DOCX to HTML | mammoth via scripts/docx_to_html.mjs | Trusted documents, semantic HTML |
| DOCX to JSON/Markdown | scripts/docx_extract.py, Markdown converters | Automation, RAG ingestion |
| Inspect revisions/comments | scripts/docx_inspect_ooxml.py | Before editing any reviewed document |
| Release gate | scripts/docx_quality_gate.py | Every generated or edited file |
| DOCX to PDF | Word automation / LibreOffice headless | Release artifacts, CI smoke tests |
Format And Safety Caveats
- python-docx comments: main body only, no anchors in headers or footers, no threaded replies or resolved state, and anchors are whole runs.
- python-docx has no tracked-change authoring, no alt-text property, no field API and no public hyperlink authoring API. The workarounds in the references use private attributes; re-verify them after upgrades.
- A TOC and other Word fields stay empty or stale until updated in Word or rendered by LibreOffice.
- New python-docx documents can inherit author, date and comments from the default template. Inspect core properties before distribution.
Version-Gate Before Promising A Feature
Do not assume the environment has a current library:
Document.add_comment()is a recent python-docx addition and raisesAttributeErroron older pins. Checkhasattr(docx.document.Document, "add_comment")before promising comment support.- If a user asks for something flagged unsupported here (tracked-change authoring in python-docx, threaded replies, resolved comments), say so plainly and route to the official
docxskill. Do not approximate it with formatting.
Default Workflow
- Identify the file type and trust level:
.docx/.dotx,.docm/.dotm, or legacy.doc. - If the document may carry review metadata, run
scripts/docx_inspect_ooxml.py --jsonfirst. - Generate or modify: docxtpl through
docx_render_template.py, or python-docx/docx for structure. - For a newly generated output, set
doc.core_propertiesto the intended author, clear template comments, and setcreated/modifiedtodatetime.now(timezone.utc).replace(tzinfo=None)(python-docx expects naive UTC). For edits to an existing file, preserve provenance unless the user requested a metadata reset. - Run
scripts/docx_quality_gate.py. It exits 2 on any issue, including a requested--check-libreofficethat could not run. - Render to images and look at every page before shipping:
soffice --headless --convert-to pdf out.docx && pdftoppm -png -r 80 out.pdf page, then open thepage-*.pngfiles. For external distribution, also check in Word and apply the accessibility checklist.
python3 scripts/docx_render_template.py template.docx context.json out.docx # exit 2 on missing vars
python3 scripts/docx_quality_gate.py out.docx --json # exit 2 on any issue
python3 scripts/docx_extract.py in.docx --include headers footers comments --out extracted.json
node scripts/docx_to_html.mjs in.docx out.html --style-map map.txt --extract-images-dir assets/
Round-Trip Release Proof
- Capture the expected counts of sections, tables, images, hyperlinks, comments and tracked changes before the final save.
- Reopen the saved DOCX and compare the counts.
- Render a copy and inspect page breaks, numbering, table overflow, missing fonts and unresolved tags.
A successful OOXML parse or text extraction does not prove layout fidelity. A visually correct PDF does not prove that comments, hyperlinks, fields or accessibility metadata survived in the editable DOCX. Record which viewer did the primary review and which secondary viewer was checked.
Navigation
Resources
- references/docx-patterns.md - python-docx gotchas: styles, tables, sections, fields, hyperlinks, corruption pitfalls
- references/template-workflows.md - docxtpl tag placement, fail-closed rendering, batch rules
- references/review-comments-workflows.md - Comments, review notes, programmatic redline routing, comment limits
- references/tracked-changes.md - What is and is not feasible for tracked revisions
- references/llm-extraction-workflows.md - Mammoth, MarkItDown, Docling, HTML/Markdown/JSON extraction; includes Extraction Stack tool candidates by job (native parse, structured converter, OCR)
- references/docx-extraction-failure-modes.md - Silent-loss modes for KB/RAG ingestion (content-control tables, image tables, revisions, lying filenames) and the table-count detection check
- references/accessibility-compliance.md - Word accessibility, EN 301 549 context, manual checks
- references/cross-platform-compatibility.md - Word, Google Docs, LibreOffice, PDF conversion
- references/document-automation-pipelines.md - CI/CD, batch generation, quality gates
- data/sources.json - External documentation links
Scripts
scripts/docx_inspect_ooxml.py- Dependency-free OOXML inspection for tracked changes and commentsscripts/docx_extract.py- Extract text, tables, metadata, and optional headers/footers/hyperlinks/comments/images to JSONscripts/docx_render_template.py- Render adocxtpltemplate from JSON, failing on missing variables (--allow-missingfor drafts)scripts/docx_to_html.mjs- Convert trusted.docxto HTML with style maps and optional image extractionscripts/docx_quality_gate.py- Validate parseability, unresolved template tags, tracked-change/comment signals, and optional LibreOffice conversion; exits 2 on any issue
Templates
- assets/docx-template-authoring-checklist.md - Template authoring and handoff checklist
Related Skills
- ../document-pdf/SKILL.md - PDF generation and release workflows
- ../document-xlsx/SKILL.md - Spreadsheet generation and exports
- ../document-pptx/SKILL.md - Presentation generation
- ../docs-codebase/SKILL.md - Technical writing patterns
Learnings Loop
When prior decisions or pitfalls are relevant, consult learnings.consolidated.md if present; use learnings.md only for needed history or as the available fallback. Otherwise skip both.
After applying it, if you encountered a pattern worth remembering, a mistake worth preventing, or a domain fact that surprised you, append one dated bullet to learnings.md via agents-skills-feedback-loop/scripts/append_learning.py. Do not modify SKILL.md itself.
FAQ
What does the document-docx skill do?
Builds docxtpl templates, DOCX extraction for RAG, and EAA accessibility checks. Use when templating Word or extracting tables; plain edits and redlines: official docx skill.
How do I install document-docx?
Run npx skills add https://github.com/vasilyu1983/ai-agents-public --skill document-docx in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/document-docx/ (personal) or .claude/skills/document-docx/ (project).
Which AI agents can use document-docx?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is document-docx safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains document-docx?
It is published by vasilyu1983 in vasilyu1983/ai-agents-public. It has 475 recorded installs.
More from vasilyu1983/ai-agents-public
software-architecture-design
vasilyu1983/ai-agents-public
Designs runtime topology in a chosen solution. Use when choosing monolith vs services, cells, consistency, ADRs. Not for cross-system design (software-solution-architecture).
product-management
vasilyu1983/ai-agents-public
Guides founder-PM discovery, roadmaps, prioritization, and PMF measurement. Use when planning product strategy, metrics, or roadmaps.
document-xlsx
vasilyu1983/ai-agents-public
Builds Excel charts, pivots, validation, exports, Office Scripts/Graph automation, and workbook audits. Use when automating workbooks; for plain edits prefer official xlsx skill.
software-ui-ux-design
vasilyu1983/ai-agents-public
Designs and audits UI/UX systems with usability and accessibility requirements. Use when shaping flows, design systems, interaction patterns, or WCAG-aware product behavior.
document-pdf
vasilyu1983/ai-agents-public
Handles PDF/UA accessibility, real redaction, metadata scrubbing, signing, and extraction. Use when redacting or signing PDFs; for plain create/merge prefer the official pdf skill.
qa-testing-playwright
vasilyu1983/ai-agents-public
Builds and debugs Playwright E2E suites. Use when authoring browser tests, fixing flakes, or hardening Playwright CI and locator strategy.
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.