docx

Create, edit, and validate Word DOCX documents programmatically with Python.

2|1|Updated Feb 5, 2026
One-click install
npx skills add https://github.com/dalehurley/phpbot --skill docx-dalehurley
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/dalehurley/phpbot/tree/main/skills/docx
Command: npx skills add https://github.com/dalehurley/phpbot --skill docx-dalehurley

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill provides a programmable approach to create, read, edit, and manipulate Word documents (.docx) to automate formatting, assembly, and content management, reducing manual processing time.

Core Features & Use Cases

  • Create new DOCX documents from templates and programmatic content, including paragraphs, tables, headers/footers, and images.
  • Unpack existing DOCX files, modify their underlying XML, merge runs, validate structure, and re-pack with consistent content types and relationships.
  • Validate and automate batch processing of documents, leveraging on-demand scripts to ensure consistency and repeatability across tasks such as formatting, tables, and TOC generation.

Quick Start

Unpack a Word document, edit its XML to apply changes, then re-pack it into a new DOCX.

Frequently Asked Questions about docx

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

FAQPage Schema
How do I automate Word document editing and formatting in bulk?

Automate Word document editing by unpacking existing DOCX files, modifying their underlying XML, and repacking them. This enforces structural validation and supports batch processing to ensure consistent formatting across multiple files.

What is the best way to programmatically create a Word document from a template?

Programmatically create a DOCX from a template by generating content such as paragraphs, tables, headers, footers, and images. On-demand scripts ensure deterministic outcomes for document generation and template filling workflows.

Do I need lxml to modify Word XML directly?

You need lxml and defusedxml to safely parse and modify Word XML directly. These dependencies allow you to unpack DOCX files, merge runs, and manipulate content types while validating document structure.

How does DOCX validation handle content types and relationships?

DOCX validation handles content types and relationships by enforcing structural integrity during unpacking and repacking. This ensures IDs and content types remain consistent when modifying underlying XML.

Can I extract content from existing Word documents for data processing?

Extract content from existing Word documents by unpacking the DOCX file and parsing its underlying XML. This supports content extraction workflows by allowing programmatic access to paragraphs, tables, and document elements.