docx

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

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill docx-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/docx
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill docx-tamagusko

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 naive generation produces corrupt files, broken tables, or lost tracked changes. This Skill provides tested workflows and scripts to create, read, and edit .docx files reliably. ## Core Features & Use Cases - Document Creation: Generate polished .docx files with docx-js, including tables of contents, headings, lists, tables, images, footnotes, headers/footers, and multi-column layouts, with explicit page size and style control. - Surgical Editing: Unpack existing documents, edit the raw OOXML directly for tracked changes, comments, find-and-replace, and image insertion, then repack with schema validation and auto-repair. - Content Extraction & Conversion: Extract text with pandoc (including tracked changes), convert legacy .doc files, accept all 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 it with docx-js and validates the output before delivery. ## Quick Start Ask the assistant to create a Word document report with a table of contents and styled headings, or to edit an existing .docx file with tracked changes.

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 Paragraph, Table, and ImageRun elements, then write it with Packer.toBuffer. Always set the page size explicitly in DXA units, since docx-js defaults to A4 rather than US Letter.

How do I add tracked changes to a .docx file?

Unpack the .docx into its XML parts, 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 repack with validation.

Why do my docx tables render incorrectly in Google Docs?

Tables break when using WidthType.PERCENTAGE, which Google Docs does not support. Always use WidthType.DXA, set columnWidths on the table plus matching width on each cell, and ensure the column widths sum exactly to the table width.

Can I convert a legacy .doc file to .docx?

Yes, legacy .doc files must be converted before editing. Run LibreOffice headless with the soffice.py helper using the --convert-to docx flag, which also 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 with the input and output file paths. It uses a LibreOffice Basic macro to execute AcceptAllTrackedChanges headlessly and saves a clean document with all revisions applied.

What are the limitations of editing .docx XML directly?

Auto-repair only fixes invalid durableId values and missing xml:space preserve attributes. Malformed XML, invalid element nesting, missing relationships, and schema violations must be fixed manually, so validation against the OOXML XSD schemas is required after editing.