docx

Create, read, edit, and validate Word .docx files via XML manipulation.

Updated Jan 26, 2023
One-click install
npx skills add https://github.com/yuyalun-allen/dotfiles --skill docx-yuyalun-allen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/yuyalun-allen/dotfiles/tree/main/tools/pi/agent/skills/docx
Command: npx skills add https://github.com/yuyalun-allen/dotfiles --skill docx-yuyalun-allen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires defusedxml, lxml, and includes scripts (resource) components.

What problem does it solve?

Provides a complete toolkit to create, read, edit, and validate Microsoft Word .docx files without relying solely on GUI tools, removing the manual, error-prone steps of unpacking Office XML, fixing schema issues, handling tracked changes/comments, and reassembling valid documents.

Core Features & Use Cases

  • Unpack & Inspect: Extract .docx contents to editable XML and pretty-print files for direct editing.
  • Edit & Redline Support: Add or merge tracked changes and comments, preserve formatting and smart quotes, and manage redlines safely.
  • Generate & Validate: Produce new .docx using docx-js conventions, enforce table/image/page rules, and validate against OOXML XSDs with auto-repair for common issues.
  • Conversion Utilities: Convert legacy .doc and .docx → PDF/images via LibreOffice and Poppler for previews or raster outputs.
  • Use Case: Turn a draft Markdown report into a US Letter .docx with Heading styles, a Table of Contents, embedded images, and validated OOXML for corporate distribution.

Quick Start

Create a US Letter Word report with Heading 1 title, a Table of Contents, a two-column section, a full-width table using DXA widths, and embed an image with alt text using the docx skill.

Frequently Asked Questions about docx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a .docx document from Markdown with a table of contents and embedded images?

Generate a .docx document from Markdown by applying docx-js conventions to create professional reports with heading styles, a table of contents, and embedded images with alt text. The process unpacks, modifies XML, and repacks the archive into a valid file.

What is the best way to edit tracked changes and comments in a Word document programmatically?

Editing tracked changes and comments in a Word document involves unpacking the .docx XML, safely adding or merging redlines while preserving formatting and smart quotes, and repacking the archive. This approach removes manual GUI steps and manages redline metadata directly.

How does OOXML XSD validation with auto-repair work for .docx files?

OOXML XSD validation for .docx files works by unpacking the archive, checking the internal XML against schema rules, and applying auto-repair to fix common structural issues before repacking. This ensures generated documents meet strict corporate distribution standards.

Can I use LibreOffice and Poppler to convert .docx files to PDF or images?

Yes, you can convert .docx files to PDF or raster images using LibreOffice and Poppler conversion utilities. This provides previews or image outputs from your generated or modified Word documents without relying on Microsoft Word.

Do I need to manage table DXA widths and page rules when generating a Word document via XML?

Yes, generating a Word document via XML requires enforcing table DXA width rules, page size standards like US Letter, and image embedding rules. Properly managing these OOXML constraints ensures the repacked .docx file is structurally valid and displays correctly.

Why does my programmatically generated .docx file have corrupted XML or formatting issues?

Corrupted XML or formatting issues in a generated .docx file often stem from invalid schema structures or improper tracked-change handling. Unpacking the archive, modifying the XML directly, and validating against OOXML XSDs with auto-repair resolves these errors.