docx
Installation
SKILL.md
DOCX
What This Skill Helps With
Use this skill when you need to create, edit, review, or inspect a .docx file and want a dependable workflow instead of guessing which library or format detail matters.
Ask for this skill with prompts like
Use the exact skill name $docx in your prompt.
Use $docx to extract the text from this Word document.Use $docx to update this report and keep the headings and tables intact.Use $docx to create a new project brief from this outline.Use $docx to inspect the raw XML in this file because formatting keeps breaking.
Tools and Assumptions
This skill works best when the agent can use some of these tools:
python-docxfor most create and edit taskspandocfor fast text extraction when availablezipfile,unzip, or another archive tool for raw OOXML inspectiondocxtplfor template-driven generation when a.docxtemplate is provided
If a tool is missing, install it first or fall back to a simpler workflow.
Recommended Workflow
1. Read or extract content
- Prefer
pandocwhen you mainly need text and headings. - Fall back to ZIP or XML inspection when you need comments, relationships, numbering, styles, or embedded assets.
Example:
pandoc input.docx -t markdown -o output.md
2. Create a new document
- Prefer
python-docxfor letters, reports, meeting notes, and basic tables. - Prefer
docxtplwhen the user gives you a Word template with placeholders. - Keep the first version simple before adding advanced styling or images.
3. Edit an existing document
- Use
python-docxfor text edits, headings, tables, lists, and basic formatting. - Be conservative with complex layout changes.
- If the document has unusual numbering, section breaks, or field codes, inspect the XML before making broad edits.
4. Inspect OOXML directly
A .docx file is a ZIP archive. Inspect OOXML directly when:
- styles are broken,
- numbering resets unexpectedly,
- section breaks disappear,
- images or relationships are missing,
- comments or metadata need inspection.
Key files:
word/document.xmlword/styles.xmlword/numbering.xmlword/comments.xmlword/_rels/document.xml.rels
Important Limits
- Standard Python libraries do not reliably produce native Word tracked changes the way Microsoft Word does.
- If the user specifically needs true tracked changes or comment threads, say so clearly before editing.
- For simple final-text edits,
python-docxis usually enough. - For review-markup fidelity, a manual Word review step may still be necessary.
Common Mistakes
- Treating
.docxlike plain text and losing structure. - Making global XML edits before understanding the style or numbering model.
- Assuming tracked changes will be preserved automatically.
- Forgetting that low-level paragraph insertion may need XML style IDs instead of human-readable style names.
If paragraph styles silently fall back to Normal, use $python-docx-style-id-mismatch.