docx

Create, edit, and validate Word .docx documents via OOXML manipulation.

Updated Sep 11, 2026
One-click install
npx skills add https://github.com/CYRUS-pinto/pi-bot --skill docx-cyrus-pinto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/CYRUS-pinto/pi-bot/tree/main/.agents/skills/docx
Command: npx skills add https://github.com/CYRUS-pinto/pi-bot --skill docx-cyrus-pinto

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Working with Word documents programmatically is error-prone: docx-js cannot open existing files, Word fragments text across XML runs, and tracked changes or comments require many cross-linked XML parts. This Skill provides tested workflows and scripts to create, edit, read, redline, and validate .docx and .dotx files reliably. ## Core Features & Use Cases - Document Creation: Generate polished Word documents with the docx npm library, avoiding common pitfalls like A4 default page size, broken table widths, and literal bullet characters. - Editing & Redlining: Unzip, edit word/document.xml directly, merge fragmented runs for reliable find-and-replace, and produce tracked changes with proper <w:ins>/<w:del> markup. - Comments & Validation: Add threaded comments with all six required satellite XML files, accept tracked changes via LibreOffice, and validate output against OOXML XSD schemas with auto-repair. - Use Case: A lawyer asks you to redline a contract: unpack the .docx, merge runs, wrap edits in tracked-change elements, validate with the author flag, and render a PDF to visually verify the result. ## Quick Start Use the docx skill to create a professional Word report with a table of contents, headings, and page numbers, then render it to PDF so I can review the layout.

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 requiring the preinstalled docx npm package and define paragraphs, tables, and sections. Watch for gotchas: page size defaults to A4, tables need columnWidths plus per-cell widths in DXA, and bullets require a numbering config rather than literal bullet characters.

How do I edit an existing .docx file?

Unzip the .docx, edit word/document.xml directly without reformatting, then rezip. Run merge_runs.py first because Word splits text across many runs, so visible phrases often do not exist as contiguous strings in the XML.

Can docx-js open or modify existing Word documents?

No, docx-js only creates new documents and cannot open existing files. To modify an existing .docx, unzip it, edit the underlying XML, and rezip, then validate the result against OOXML schemas.

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 the --author flag to catch any edits missing tracked-change markup.

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

Word fragments text across many <w:r> runs due to revision IDs and spell-check markers, so target phrases are split across elements. Running merge_runs.py coalesces adjacent identically formatted runs so text becomes searchable without changing rendering.

How do I verify a generated .docx looks correct?

Convert it to PDF with LibreOffice headless, then use pdftoppm to render pages as JPEG images and visually inspect them. Also run the validate.py script to check the XML against OOXML XSD schemas and auto-repair common issues.