docx

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

Updated Aug 21, 2026
One-click install
npx skills add https://github.com/ewtodd/son-of-anton --skill docx-ewtodd
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/ewtodd/son-of-anton/tree/main/skills/productivity/docx
Command: npx skills add https://github.com/ewtodd/son-of-anton --skill docx-ewtodd

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Working with Word documents programmatically is error-prone: text gets fragmented across runs, tracked changes and comments live in raw XML, and naive find-replace corrupts files. This Skill provides tested command-line scripts that handle creation, reading, editing, templating, revision resolution, comment management, and package health checks for .docx files. ## Core Features & Use Cases - Document creation from JSON specs: Build reports, letters, and contracts with headings, styled paragraphs, lists, tables, images, headers/footers, TOC fields, and page numbers. - Editing and templating: Run formatting-preserving find-replace, insert/delete/style paragraphs, set table cells, and fill {{token}} placeholders from JSON values with strict-mode validation. - Review workflows: List, accept, or reject tracked changes (w:ins/w:del) and list, add, or delete comments anchored to document text. - Use Case: You receive a contract draft with tracked changes and reviewer comments. List all revisions, accept them in bulk, fill {{client_name}} and {{date}} tokens from a JSON file, then validate the package before sending it back. ## Quick Start Ask the agent to create a Word report from a JSON spec, or to replace a phrase in an existing .docx file, and it will run the appropriate docx 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 an output path. The script builds the .docx via python-docx and prints a JSON confirmation.

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

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

How do I accept or reject tracked changes in a Word document programmatically?▼

Use docx_revisions.py: list shows every w:ins and w:del with id, author, and text, while accept-all, reject-all, or accept/reject --id resolve them. It covers run-level revisions in body, tables, headers, and footers, but not paragraph-mark or format-change records.

Does python-docx support adding comments to Word documents?▼

Yes. python-docx 1.2+ has a native add_comment API, and docx_comments.py uses it automatically; on older versions it falls back to building comments.xml and range markers directly. Comments are anchored to the first occurrence of a target phrase.

Can python-docx convert a Word document to PDF?▼

No, python-docx cannot render PDFs. Convert headlessly with LibreOffice using soffice --headless --convert-to pdf. If LibreOffice is not installed, PDF conversion is unavailable in that environment.

Why does find-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.