docx

Create, edit, and validate Word documents with tracked changes and comments.

52|Updated Apr 24, 2026
One-click install
npx skills add https://github.com/Immortalqx/my_codex_skills --skill docx-immortalqx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/Immortalqx/my_codex_skills/tree/main/docx
Command: npx skills add https://github.com/Immortalqx/my_codex_skills --skill docx-immortalqx

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, and naive edits corrupt formatting, tracked changes, or relationships. This Skill provides a complete workflow for creating new Word documents with docx-js and safely editing existing ones via unpack-edit-repack with schema validation. ## Core Features & Use Cases - Document Creation: Generate polished .docx files with docx-js, including tables, images, TOC, headers/footers, footnotes, hyperlinks, and multi-column layouts, with explicit page size and style control. - Tracked Changes & Comments: Insert, delete, and comment on existing documents as redlines using unpack/edit/pack scripts, with proper OOXML markup for w:ins, w:del, and comment ranges. - Validation & Conversion: Validate edited XML against OOXML schemas with auto-repair, accept all tracked changes via LibreOffice, and convert documents to PDF or images. - Use Case: A user asks to redline a contract draft: unpack the .docx, apply tracked-change XML edits preserving formatting, validate and repack, then deliver a Word file the recipient can review in Track Changes mode. ## Quick Start Use the docx skill to create a professional Word report with a table of contents, headings, and a summary table, saved 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 Paragraph, Table, and ImageRun elements, 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 add tracked changes to an existing Word document?

Unpack the .docx into XML, wrap inserted text in w:ins elements and deleted text in w:del with w:delText, then repack. Replace entire w:r run elements rather than injecting change tags inside runs, and preserve the original run's formatting properties.

Why does my docx table render incorrectly in Google Docs?

Tables break when using WidthType.PERCENTAGE, which Google Docs does not support. Always use WidthType.DXA, set both the table columnWidths array and each cell's width so they sum exactly to the table width.

Can I accept all tracked changes in a docx programmatically?

Yes, the accept_changes.py script uses LibreOffice headless with a Basic macro to accept all tracked changes and save a clean document. It requires LibreOffice (soffice) installed on the system.

How do I add comments to a Word document programmatically?

Run comment.py on the unpacked document to create the comment entries across comments.xml and related parts, then add commentRangeStart and commentRangeEnd markers in document.xml as siblings of runs, never inside them.

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 OOXML schemas is essential before packing.