docx

Create, edit, and analyze Word documents using docx-js and direct XML manipulation.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Working with Word documents programmatically is error-prone: docx-js defaults to A4 page size, tables render incorrectly without dual widths, tracked changes require precise XML structure, and unicode bullets break list formatting. This Skill provides tested patterns and scripts to create, read, and edit .docx files correctly the first time. ## Core Features & Use Cases - Document Creation: Generate professional .docx files with docx-js, including tables of contents, headers/footers, footnotes, hyperlinks, multi-column layouts, and properly configured tables and lists. - Document Editing: Unpack .docx files to XML, perform find-and-replace, insert tracked changes and comments with proper schema compliance, then repack with validation and auto-repair. - Content Extraction & Conversion: Extract text with pandoc (including tracked changes), convert legacy .doc files, and render documents to PDF or images via LibreOffice. - Use Case: A user asks for a quarterly report as a Word file with a table of contents, styled headings, a data table, and page numbers. The Skill generates the document with docx-js using correct page dimensions and validates the output. ## Quick Start Create a Word document report with a title page, table of contents, and a formatted data table, then validate the output file.

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 package (docx-js) to build a Document object with sections containing 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 a Word document programmatically?

Unpack the .docx into XML, then wrap inserted runs in <w:ins> elements and deleted runs in <w:del> elements using <w:delText>, each with an id, author, and date. Replace entire <w:r> blocks rather than injecting tags inside runs, and preserve the original <w:rPr> formatting.

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 match, and ensure column widths sum exactly to the table width.

How do I convert a .doc file to .docx?

Legacy .doc files must be converted before editing using LibreOffice in headless mode: run soffice with --headless --convert-to docx. The Skill wraps this in scripts/office/soffice.py, which also handles sandboxed environment configuration.

Why does my table of contents not appear in the generated docx?

A TableOfContents only populates when headings use the built-in HeadingLevel values with matching outlineLevel properties in the style definitions. Custom styles on heading paragraphs prevent TOC entries from being recognized.

Can this approach handle PDFs or Google Docs?

No, the Skill explicitly excludes PDFs, spreadsheets, and Google Docs. It targets .docx files only, though it can convert a finished .docx to PDF or images using LibreOffice and pdftoppm for preview purposes.