Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of "Word doc", "word document", ".docx", or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a "report", "memo", "letter", "template", or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, or general coding tasks.
A .docx file is a ZIP archive containing XML files.
| Task | Approach |
|---|---|
| Read/analyze content | pandoc or unpack for raw XML |
| Create new document | Use docx-js (Node.js) - see Creating New Documents below |
| Edit existing document | Unpack ZIP → edit XML → repack - see Editing Existing Documents below |
Legacy .doc files must be converted before editing:
libreoffice --headless --convert-to docx document.doc
# Text extraction with tracked changes
pandoc --track-changes=all document.docx -o output.md
# Raw XML access - unzip the docx
mkdir -p unpacked && unzip -o document.docx -d unpacked/
# Main content is in unpacked/word/document.xml
libreoffice --headless --convert-to pdf document.docx
pdftoppm -jpeg -r 150 document.pdf page
To produce a clean document with all tracked changes accepted (requires LibreOffice):
# Use a LibreOffice macro to accept all changes
libreoffice --headless --invisible --norestore \
"macro:///Standard.Module1.AcceptAllChanges" input.docx
Or use pandoc to extract clean text (without change tracking markup):
pandoc --track-changes=accept document.docx -o clean.md
Generate .docx files with JavaScript using the docx npm package, then validate. Install: npm install -g docx
const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, ImageRun,
Header, Footer, AlignmentType, PageOrientation, LevelFormat, ExternalHyperlink,
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));
// CRITICAL: docx-js defaults to A4, not US Letter
// Always set page size explicitly for consistent results
Edit PDFs with natural-language instructions using the nano-pdf CLI.