docx

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

Updated May 28, 2026
One-click install
npx skills add https://github.com/changfengpro/agent-skills --skill docx-changfengpro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/changfengpro/agent-skills/tree/main/skills/docx
Command: npx skills add https://github.com/changfengpro/agent-skills --skill docx-changfengpro

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 files are ZIP archives of XML with strict schema rules, and common libraries have pitfalls like wrong default page sizes, broken tables, and invalid tracked changes. This Skill provides tested workflows and scripts to create, read, and edit .docx files correctly. ## Core Features & Use Cases - Document Creation: Generate polished Word documents with docx-js, including styles, lists, tables, images, headers/footers, footnotes, hyperlinks, multi-column layouts, and tables of contents. - Document Editing: Unpack existing .docx files, edit the raw XML directly, and repack with validation—supporting tracked changes, comments, and image insertion. - Validation & Repair: Validate documents against OOXML XSD schemas with automatic repair of common issues like invalid IDs and missing whitespace preservation. - Use Case: A user asks for a quarterly report as a Word file with a table of contents, styled headings, and a data table. The Skill generates it with docx-js, validates the output, and delivers a clean .docx. ## Quick Start Create a Word document report with a title page, table of contents, and a formatted data table, then save it as report.docx.

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 with JavaScript?

Use the docx npm library (docx-js) to build a Document object with paragraphs, tables, and styles, then write it with Packer.toBuffer. Always set the page size explicitly since docx-js defaults to A4 rather than US Letter.

How do I edit an existing .docx file programmatically?

Unpack the .docx into its XML parts with the unpack script, edit the XML in the word/ directory directly, then repack with validation. This approach supports tracked changes, comments, and image insertion that high-level libraries cannot handle.

How do I add tracked changes to a Word document?

Insert w:ins and w:del elements around the affected runs in document.xml, using w:delText instead of w:t inside deletions. Replace entire w:r elements rather than injecting tags inside runs, and preserve the original run's formatting properties.

Why do my docx-js tables render incorrectly?

Tables need dual widths: set columnWidths on the table and a matching width on each cell, both in DXA units that sum to the table width. Never use WidthType.PERCENTAGE, which breaks in Google Docs, and use ShadingType.CLEAR instead of SOLID for cell shading.

Can this convert legacy .doc files to .docx?

Yes, legacy .doc files are converted to .docx using LibreOffice in headless mode via the soffice script before editing. LibreOffice also handles PDF conversion and accepting all tracked changes in a document.

When should I not use this Skill?

Do not use it for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. It is scoped specifically to creating, reading, and editing .docx Word documents.