docx

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

1|Updated Jul 2, 2026
One-click install
npx skills add https://github.com/mccleod1290/bb-agentic-setupv2 --skill docx-mccleod1290
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/mccleod1290/bb-agentic-setupv2/tree/main/documenting-skills/docx
Command: npx skills add https://github.com/mccleod1290/bb-agentic-setupv2 --skill docx-mccleod1290

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 for creating new documents, editing existing ones at the XML level, and validating output against OOXML schemas. ## Core Features & Use Cases - New Document Generation: Build .docx files with docx-js including styles, tables, images, TOC, headers/footers, footnotes, hyperlinks, and multi-column layouts, with explicit page sizing and validation. - Surgical Editing of Existing Files: Unpack a .docx, edit the XML directly for tracked changes, comments (with replies), image insertion, and find-and-replace, then repack with auto-repair validation. - Content Extraction & Conversion: Extract text with pandoc (including tracked changes), convert legacy .doc to .docx, render to PDF/images via LibreOffice, and accept all tracked changes programmatically. - Use Case: A user asks for a redlined contract revision. The Skill unpacks the .docx, inserts tracked deletions and insertions with proper <w:ins>/<w:del> markup, adds reviewer comments, validates against the XSD schema, and repacks a clean file. ## Quick Start Use the docx skill to create a professional Word report with a table of contents, styled 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 programmatically with JavaScript?▼

Use the docx npm package (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, and validate the output file afterward.

How do I add tracked changes to an existing .docx file?▼

Unpack the .docx into its XML parts, then replace entire <w:r> runs with <w:del> and <w:ins> sibling elements containing the old and new text. Preserve the original run's <w:rPr> formatting, then repack with validation against the original file.

Why do my generated Word tables render incorrectly?▼

Tables need dual widths: set columnWidths on the table and a matching width on every cell, both in DXA units that sum exactly to the table width. Never use WidthType.PERCENTAGE because it breaks in Google Docs, and use ShadingType.CLEAR rather than SOLID for cell shading.

Can I convert legacy .doc files to .docx for editing?▼

Yes, convert .doc to .docx first using LibreOffice headless mode via the soffice.py helper script. Legacy binary .doc files cannot be unpacked or edited as XML directly, so conversion is a required first step.

How do I add comments with replies to a Word document?▼

Run the comment.py script against the unpacked directory with a comment ID and pre-escaped XML text, using the --parent flag for replies. Then add commentRangeStart and commentRangeEnd markers as direct children of the paragraph in document.xml, never inside a run.

What are the limitations of editing .docx XML directly?▼

Auto-repair only fixes invalid durableId values and missing xml:space="preserve" attributes; malformed XML, bad element nesting, and missing relationships still fail validation. Element order inside <w:pPr> and schema compliance rules must be followed manually.