docx-skill

Create, read, and edit Word documents using docx-js and OOXML manipulation.

2|1|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/dkyazzentwatwa/skill_starter_pack --skill docx-skill-dkyazzentwatwa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx-skill
Source: https://github.com/dkyazzentwatwa/skill_starter_pack/tree/main/docx-skill
Command: npx skills add https://github.com/dkyazzentwatwa/skill_starter_pack --skill docx-skill-dkyazzentwatwa

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Working with Word documents programmatically is error-prone: tables render incorrectly, tracked changes corrupt files, and formatting breaks across platforms. This Skill provides tested patterns and validation tooling to create, read, and edit .docx files reliably. ## Core Features & Use Cases - Document Creation: Generate polished Word documents with docx-js, including tables, images, tables of contents, headers, footers, footnotes, and multi-column layouts. - Surgical Editing: Unpack .docx files into XML, apply tracked changes and comments with proper OOXML structure, then repack with schema validation and auto-repair. - Content Extraction & Conversion: Extract text with pandoc, convert legacy .doc files, accept tracked changes via LibreOffice, and render pages to images. - Use Case: A user asks for a project status report as a Word file with a table of contents, styled headings, and a summary table; the Skill generates the document with docx-js and validates it before delivery. ## Quick Start Use the docx-skill to create a Word document report with a title page, table of contents, and a two-column summary table.

Frequently Asked Questions about docx-skill

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

FAQPage Schema
How do I create a Word document with JavaScript?

Use the docx npm package (docx-js) to build a Document object with sections, paragraphs, tables, and images, then write it with Packer.toBuffer. Always set the page size explicitly since docx-js defaults to A4, and validate the output file afterward.

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

Unpack the .docx into XML, then wrap inserted text in w:ins elements and deleted text in w:del elements with w:delText, including author and date attributes. Replace entire w:r run elements rather than injecting tags inside runs, and preserve the original w:rPr formatting.

Why do Word tables render incorrectly in Google Docs?

Tables break when using WidthType.PERCENTAGE or when cell widths are missing. Always use WidthType.DXA, set both the table columnWidths array and each cell's width so they sum exactly to the table width, and use ShadingType.CLEAR instead of SOLID.

Can I convert legacy .doc files to .docx?

Yes, convert legacy .doc files using LibreOffice headless mode with the command soffice --headless --convert-to docx. The included soffice.py helper handles sandboxed environments where Unix sockets are blocked.

How do I accept all tracked changes in a Word document?

Run the accept_changes.py script, which uses a LibreOffice Basic macro to accept all tracked changes and save a clean document. It requires LibreOffice installed and produces a new output file without modifying the original.

When should I not use this document editing approach?

Do not use it for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to Word documents. Direct XML editing also cannot auto-repair malformed XML, invalid element nesting, or missing relationships, so those must be fixed manually.