docx

Create, edit, and validate Word .docx documents via XML manipulation and docx-js scripts.

Updated Aug 25, 2017
One-click install
npx skills add https://github.com/loki495/dotfiles --skill docx-loki495
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/loki495/dotfiles/tree/main/ai/skills/synced/4f2cd280-c105-47f5-b498-fb931ff17906_01354434-3473-483d-87d9-0aa269eff282/docx
Command: npx skills add https://github.com/loki495/dotfiles --skill docx-loki495

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 files. This Skill provides tested workflows and scripts to create, read, edit, redline, and comment on .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 a .docx, merge fragmented runs, edit word/document.xml directly, and validate tracked changes against the original with XSD schema checks. - Comments & Review: Add threaded comments with all six required satellite XML files, accept tracked changes via LibreOffice, and render output to PDF images for visual verification. - Use Case: A user needs to redline a contract: unpack the .docx, merge runs so clauses are findable, wrap edits in w:ins/w:del elements, validate with --author to confirm every change is tracked, then produce a clean accepted copy. ## Quick Start Use the docx skill to create a professional Word report with a table of contents 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 that requires the preinstalled docx npm package and defines 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 characters.

How to edit an existing .docx file when docx-js cannot open it?▼

Unzip the .docx, edit word/document.xml directly without reformatting, then rezip. Run merge_runs.py first to coalesce fragmented runs so target text exists as contiguous strings, and validate the result against the original with validate.py.

How do I add tracked changes to a Word document?▼

Wrap inserted runs in w:ins elements and deleted runs in w:del with w:delText, each carrying w:id, w:author, and w:date attributes. Validate with validate.py --author to catch any edit missing tracked-change markup.

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 phrases rarely exist as contiguous strings. The merge_runs.py script merges adjacent identically-formatted runs without changing rendering, making text findable.

Can this skill handle PDFs or Google Docs?▼

No, it is scoped strictly to .docx and .dotx files. Legacy .doc files must first be converted to .docx with LibreOffice. PDFs, spreadsheets, and Google Docs require different tools and are explicitly out of scope.

How do I verify a generated Word document looks correct?▼

Convert the .docx to PDF with LibreOffice headless, then rasterize pages with pdftoppm at 100 DPI and inspect the resulting JPEG images. This catches layout issues like broken tables or wrong page orientation before delivery.