docx

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

Updated Sep 1, 2026
One-click install
npx skills add https://github.com/sshekhar-04/SIH_PS_26151 --skill docx-sshekhar-04
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/sshekhar-04/SIH_PS_26151/tree/main/.agents/Skills/docx
Command: npx skills add https://github.com/sshekhar-04/SIH_PS_26151 --skill docx-sshekhar-04

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-js has undocumented pitfalls, Word fragments text across XML runs making find-and-replace unreliable, and tracked changes or comments require coordinating multiple cross-linked XML files. This Skill provides tested workflows and scripts that handle these complexities correctly. ## Core Features & Use Cases - Document Creation: Generate new .docx files with the docx npm library, with guidance on page sizes, tables, lists, images, and tables of contents. - Document Editing: Unzip, edit word/document.xml directly, and repack, with merge_runs.py to coalesce fragmented text runs so search-and-replace works. - Tracked Changes & Comments: Add redlined edits with proper w:ins/w:del markup, insert comments via comment.py, and accept all tracked changes with accept_changes.py. - Validation: Verify output with XSD schema validation and render documents to PDF/images for visual inspection. - Use Case: A user needs to redline a contract received as a .docx file. The Skill unpacks the document, merges runs, applies tracked deletions and insertions, validates every change is properly marked, and repacks a clean deliverable. ## Quick Start Use the docx skill to create a professional Word report with a table of contents, headings, and a formatted table, then render it to PDF for review.

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 library to build documents with paragraphs, tables, images, and headings. Set page dimensions in DXA units (1440 per inch), define table column widths on both the table and each cell, and use a numbering config for bullet lists instead of literal bullet characters.

How do I edit an existing .docx file?

Unzip the .docx, edit word/document.xml directly, then rezip the directory. Run merge_runs.py first to coalesce fragmented text runs, since Word splits visible text across many w:r elements that break naive find-and-replace.

Why does find-and-replace fail in Word document XML?

Word fragments text across multiple w:r run elements due to revision IDs and spell-check markers, so a visible phrase may not exist as a contiguous string in the XML. Merging adjacent identically-formatted runs before editing resolves this without changing rendering.

How do I add tracked changes to a Word document?

Wrap inserted runs in w:ins elements and deleted runs in w:del elements with w:id, w:author, and w:date attributes, using w:delText instead of w:t inside deletions. Validate with the --author flag to confirm every edit is properly tracked.

Can I convert legacy .doc files to .docx?

Yes, convert legacy .doc files using LibreOffice headless mode with the command soffice --headless --convert-to docx file.doc. The resulting .docx can then be unpacked, edited, and validated like any other Word document.

What are the limitations of accepting tracked changes programmatically?

Both pandoc --track-changes=accept and LibreOffice-based acceptance can leave stray empty paragraphs when a fully deleted paragraph should merge into the next one. Check paragraph deletions directly in the XML rather than trusting either rendered view.