
Docx
Create, edit, or extract content from professional Word (.docx) files—reports, memos, letters, templates—with tables of contents, tracked changes, and find-and-replace.
Overview
docx is an agent skill most often used in Build (also Validate and Operate) that creates, reads, edits, and manipulates Word .docx files with professional formatting and XML-aware workflows.
Install
npx skills add https://github.com/modelscope.cn --skill docxWhat is this skill?
- Triggers on Word doc, .docx, report, memo, letter, and template requests—not PDFs, spreadsheets, or unrelated coding
- Read via pandoc or unpack XML; create with docx-js; edit via unpack → XML edit → repack
- Legacy .doc conversion through headless office scripts before editing
- Supports tracked changes, comments, images, TOC, headings, page numbers, and letterheads
Adoption & trust: 1 installs on skills.sh.
What problem does it solve?
You need a real Word document—or to fix one—with tables of contents, tracking, or templates, and chat-only answers keep breaking Office structure.
Who is it for?
Solo builders producing client-ready Word reports, memos, letters, or templates and refactoring existing .docx content without leaving the agent.
Skip if: PDF generation, spreadsheet work, Google Docs workflows, or coding tasks that don’t involve .docx deliverables.
When should I use this skill?
User mentions Word doc, word document, .docx, report/memo/letter/template as Word, tracked changes, comments, TOC, or content extraction from .docx.
What do I get? / Deliverables
You get a correctly structured .docx (new or edited) with formatting preserved, plus a repeatable unpack-edit-repack or docx-js path for the next revision.
- .docx file with requested formatting
- Edited XML round-trip for existing documents
- Extracted or reorganized document content
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Word deliverables most often ship during product documentation and formal outputs in the build phase, though the same skill applies whenever a solo builder needs a polished .docx artifact. Docs subphase is the canonical shelf for agent-driven document generation and restructuring that isn’t generic markdown in-repo.
Where it fits
Export a scoped feature brief as a formatted .docx proposal with headings and page numbers for a client sign-off.
Generate an implementation memo with TOC and letterhead from repo notes before handoff.
Unpack an existing SOP .docx, apply find-and-replace across sections, and repack without losing styles.
How it compares
Use for native Word XML workflows instead of dumping markdown and asking the user to paste into Word manually.
Common Questions / FAQ
Who is docx for?
Indie builders and small teams who must ship or edit .docx files—reports, memos, templates—and want the agent to handle Office structure, not just plain text.
When should I use docx?
During build when writing formal docs; at validate when a scope or proposal must be Word; at operate when updating SOPs or client-facing letters; whenever the user mentions Word, .docx, tracked changes, or letterheads.
Is docx safe to install?
Review the Security Audits panel on this Prism page and limit filesystem/shell access to project folders; the skill runs conversion and unpack scripts locally.
SKILL.md
READMESKILL.md - Docx
# DOCX creation, editing, and analysis ## Overview A .docx file is a ZIP archive containing XML files. ## Quick Reference | Task | Approach | |------|----------| | Read/analyze content | `pandoc` or unpack for raw XML | | Create new document | Use `docx-js` - see Creating New Documents below | | Edit existing document | Unpack → edit XML → repack - see Editing Existing Documents below | ### Converting .doc to .docx Legacy `.doc` files must be converted before editing: ```bash python scripts/office/soffice.py --headless --convert-to docx document.doc ``` ### Reading Content ```bash # Text extraction with tracked changes pandoc --track-changes=all document.docx -o output.md # Raw XML access python scripts/office/unpack.py document.docx unpacked/ ``` ### Converting to Images ```bash python scripts/office/soffice.py --headless --convert-to pdf document.docx pdftoppm -jpeg -r 150 document.pdf page ``` ### Accepting Tracked Changes To produce a clean document with all tracked changes accepted (requires LibreOffice): ```bash python scripts/accept_changes.py input.docx output.docx ``` --- ## Creating New Documents Generate .docx files with JavaScript, then validate. Install: `npm install -g docx` ### Setup ```javascript const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, ImageRun, Header, Footer, AlignmentType, PageOrientation, LevelFormat, ExternalHyperlink, InternalHyperlink, Bookmark, FootnoteReferenceRun, PositionalTab, PositionalTabAlignment, PositionalTabRelativeTo, PositionalTabLeader, TabStopType, TabStopPosition, Column, SectionType, TableOfContents, HeadingLevel, BorderStyle, WidthType, ShadingType, VerticalAlign, PageNumber, PageBreak } = require('docx'); const doc = new Document({ sections: [{ children: [/* content */] }] }); Packer.toBuffer(doc).then(buffer => fs.writeFileSync("doc.docx", buffer)); ``` ### Validation After creating the file, validate it. If validation fails, unpack, fix the XML, and repack. ```bash python scripts/office/validate.py doc.docx ``` ### Page Size ```javascript // CRITICAL: docx-js defaults to A4, not US Letter // Always set page size explicitly for consistent results sections: [{ properties: { page: { size: { width: 12240, // 8.5 inches in DXA height: 15840 // 11 inches in DXA }, margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 } // 1 inch margins } }, children: [/* content */] }] ``` **Common page sizes (DXA units, 1440 DXA = 1 inch):** | Paper | Width | Height | Content Width (1" margins) | |-------|-------|--------|---------------------------| | US Letter | 12,240 | 15,840 | 9,360 | | A4 (default) | 11,906 | 16,838 | 9,026 | **Landscape orientation:** docx-js swaps width/height internally, so pass portrait dimensions and let it handle the swap: ```javascript size: { width: 12240, // Pass SHORT edge as width height: 15840, // Pass LONG edge as height orientation: PageOrientation.LANDSCAPE // docx-js swaps them in the XML }, // Content width = 15840 - left margin - right