docx

Create, read, edit, and template Word .docx files with python-docx CLIs.

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/loteiron/ZeusAgent --skill docx-loteiron
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/loteiron/ZeusAgent/tree/main/skills/productivity/docx
Command: npx skills add https://github.com/loteiron/ZeusAgent --skill docx-loteiron

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires python-docx, lxml, and includes scripts (resource) and references (resource) components.

What problem does it solve? Working with Microsoft Word documents programmatically is error-prone: text gets fragmented across runs, tracked changes and comments live in raw XML, and templates with placeholders break easily. This Skill provides tested command-line helpers that handle creation, reading, editing, templating, revision review, comments, and package health checks for .docx files without manual XML manipulation. ## Core Features & Use Cases - Document creation and templating: Build .docx files from a JSON spec (headings, paragraphs, lists, tables, images, TOC, page numbers) or fill {{token}} placeholders in existing templates from JSON data. - Editing and inspection: Find-and-replace with formatting preserved, edit table cells, insert/delete/style paragraphs, extract text, outlines, styles, and embedded images. - Review workflows: List, accept, or reject tracked changes; list, add, or delete comments anchored to document text; validate package health with docx_validate.py. - Use Case: You receive a contract template with {{client_name}} and {{date}} placeholders plus reviewer tracked changes. Fill the tokens with docx_template.py, accept all revisions with docx_revisions.py, then verify the result with docx_validate.py. ## Quick Start Ask the agent to create a Word report from a JSON spec or to replace specific text in an existing .docx file, and it will run the appropriate script and verify the output.

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 from Python?▼

Write a JSON spec describing page setup, styles, and content blocks (headings, paragraphs, lists, tables, images), then run docx_create.py with the spec and output path. The script builds the .docx with python-docx and prints a JSON result.

How to find and replace text in a .docx without losing formatting?▼

Run docx_edit.py replace with --find and --replace arguments. It walks body, tables, headers, and footers, preserving run formatting; matches spanning multiple runs are collapsed into the first run's formatting. Run normalize first on heavily edited files.

Can python-docx accept or reject tracked changes in Word files?▼

python-docx has no built-in revision API, but docx_revisions.py resolves run-level insertions and deletions by manipulating the XML directly. It supports list, accept-all, reject-all, and single-revision accept or reject by id.

Does this support legacy .doc or .odt files?▼

No, only the .docx (OOXML zip) format is supported. Legacy .doc and .odt files are explicitly out of scope, and the skill does not perform WYSIWYG layout work or render documents itself.

How do I convert a .docx to PDF?▼

Use LibreOffice headlessly: soffice --headless --convert-to pdf --outdir outdir/ file.docx. python-docx cannot render PDFs, so if LibreOffice is unavailable, PDF conversion is not possible in that environment.

Why does find-and-replace miss text in my Word document?▼

Word often fragments text into multiple runs, so a phrase may not exist in any single run. Run docx_edit.py normalize first to merge adjacent runs with identical formatting, which makes later replacements match reliably.