docx

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

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill docx-vivekgoquest
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/vivekgoquest/hermes-agent-stable/tree/main/skills/productivity/docx
Command: npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill docx-vivekgoquest

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 naive find-replace corrupts files. This Skill provides tested CLI scripts that handle .docx creation, reading, editing, templating, revision review, and package validation safely. ## Core Features & Use Cases - Document Creation & Templating: Build .docx files from a JSON spec (headings, tables, images, styles, TOC, page numbers) or fill {{token}} placeholders in existing templates from JSON data. - Editing & Review: Find-and-replace with formatting preserved, edit table cells, insert/delete paragraphs, list and accept/reject tracked changes, and add or delete anchored comments. - Inspection & Validation: Extract full text, heading outlines, styles, and embedded images, plus health-check packages for corrupt zips, dangling relationships, and missing styles. - Use Case: A contract template with {{client_name}} and {{date}} tokens needs filling, then the counterparty's tracked changes must be reviewed — fill the tokens with docx_template.py, list revisions with docx_revisions.py, and accept or reject each change by id. ## Quick Start Use the docx skill to create a Word report from a JSON spec and then verify the output with the validation script.

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 size, 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 supports custom styles, headers, footers, and page-number fields.

How to 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 while preserving run formatting. For heavily edited documents, run the normalize subcommand first to merge fragmented runs so matches succeed reliably.

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 w:ins and w:del XML directly. It supports accept-all, reject-all, or targeting a single revision by id; paragraph-mark and format-change revisions are detected but not resolved.

Does this support converting docx to PDF?▼

PDF conversion is not done by python-docx since it cannot render layouts. When LibreOffice is installed, run soffice --headless --convert-to pdf on the file; otherwise PDF output is unavailable in that environment.

Why does find-replace fail on some Word documents?▼

Word often splits text into multiple runs, so a search string may span run boundaries and miss single-run replacement. The replace helper collapses matched runs, and running docx_edit.py normalize first merges adjacent runs with identical formatting to reduce fragmentation.

What are the limitations of programmatic docx editing?▼

Legacy .doc and .odt formats are unsupported, and WYSIWYG layout work is out of scope. Field results like TOC entries and page numbers are computed by Word when opened, comment threading in commentsExtended.xml is ignored, and validation is a health check rather than full XSD schema validation.