docx

Create, edit, and validate Word documents including tracked changes and comments.

6|1|Updated Sep 3, 2026
One-click install
npx skills add https://github.com/jasonzhu0922-sketch/agentloop --skill docx-jasonzhu0922-sketch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/jasonzhu0922-sketch/agentloop/tree/main/packages/agentloop-skills/skills/docx
Command: npx skills add https://github.com/jasonzhu0922-sketch/agentloop --skill docx-jasonzhu0922-sketch

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires docx, pandoc, pdftoppm, defusedxml, lxml, and includes scripts (resource) components.

What problem does it solve? Working with Word documents programmatically is error-prone: docx-js has layout footguns, Word fragments text across XML runs making find-and-replace unreliable, and tracked changes or comments require many cross-linked files. This Skill provides tested workflows and scripts to create, edit, read, and validate .docx, .doc, and .dotx files correctly. ## Core Features & Use Cases - Document Creation: Generate polished Word documents with the docx npm library, avoiding common pitfalls like wrong page sizes, broken table widths, and invalid list formatting. - Surgical Editing: Unzip a .docx, merge fragmented runs, edit word/document.xml directly, rezip, and validate against XSD schemas with optional auto-repair. - Redlining & Comments: Insert tracked changes with proper <w:ins>/<w:del> markup, verify every edit is tracked, accept all changes via LibreOffice, and add threaded comments with all six required satellite files. - Use Case: A user needs to redline a contract: convert it, merge runs, wrap edits in tracked-change elements, validate with --author to confirm nothing was changed untracked, and render a PDF to visually inspect the result. ## Quick Start Use the docx skill to create a professional Word report with a table of contents and headings, then render it to PDF for visual verification.

Frequently Asked Questions about docx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Word document programmatically with docx-js?

Write a Node script using the preinstalled docx npm package and require it directly. Watch for footguns: page size defaults to A4, tables need columnWidths on the table plus width on every cell in DXA, and lists must use a numbering config rather than literal bullet characters.

How do I edit an existing .docx file?

Unzip the .docx, run merge_runs.py to coalesce fragmented runs so text is findable, edit word/document.xml in place without reformatting, then rezip and validate with validate.py against the original. docx-js cannot open existing files, so direct XML editing is the supported path.

How do I add tracked changes to a Word document?

Wrap inserted runs in <w:ins> and deleted runs in <w:del> with w:id, w:author, and w:date attributes; deleted text uses <w:delText> instead of <w:t>. Validate with validate.py --original file.docx --author "Name" to catch any edit missing tracked-change markup.

Can I convert legacy .doc files to .docx?

Yes, use LibreOffice headless: python scripts/office/soffice.py --headless --convert-to docx file.doc. LibreOffice is an optional dependency; the shared Runtime baseline does not install it, so legacy conversion requires an Office-capable Host.

Why does find-and-replace fail on Word document XML?

Word splits visible text across many <w:r> runs due to revision IDs and spell-check markers, so a phrase often does not exist as a contiguous string in the XML. Running merge_runs.py first merges adjacent identically-formatted runs without changing rendering.

How do I verify a generated .docx looks correct?

Convert it to PDF with soffice --headless --convert-to pdf, then use pdftoppm to render pages as JPEG images and inspect them visually. When LibreOffice is unavailable, run validate.py for structural XSD validation and report that visual rendering was skipped.