docx

Create, read, edit, and validate .docx files by manipulating OOXML with Python.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/andebet07-oss/MemoriaShare_C --skill docx-andebet07-oss
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/andebet07-oss/MemoriaShare_C/tree/main/skills/skills-main/skills/docx
Command: npx skills add https://github.com/andebet07-oss/MemoriaShare_C --skill docx-andebet07-oss

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Word documents (.docx) are complex to edit, requiring manual handling of XML when formatting, commenting, or tracking changes. This skill provides a robust, programmatic way to create, read, edit, validate, and convert Word documents, reducing manual tooling and risk of errors.

Core Features & Use Cases

  • Document creation and templating: generate new .docx files from templates
  • Edit existing documents: modify content, formatting, and tracked changes programmatically
  • Validate and repair: ensure XML well-formedness, content types, and relationships; repair whitespace preservation
  • Convert and integrate: support conversions via a pack/unpack workflow (e.g., to PDF)

Quick Start

Unpack a sample DOCX with unpack.py, edit the XML as needed, then re-pack with pack.py to generate 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 programmatically edit and validate Word documents without corrupting the XML?

To programmatically edit Word documents, you can unpack the .docx file, manipulate the raw OOXML content directly, and re-pack it. This process validates XML well-formedness, content types, and relationships to ensure reliable outputs without manual tooling.

What is the best way to automate docx generation from templates using Python?

Automating docx generation from templates involves using Python libraries like lxml and defusedxml to manipulate OOXML content. By unpacking a template, modifying the XML structure, and repacking, you can reliably generate new Word documents.

Can I handle tracked changes and document formatting by editing OOXML directly?

Yes, you can handle tracked changes and document formatting by editing OOXML directly. By unpacking the .docx file, you can programmatically modify content, formatting, and tracked changes in the raw XML before repacking it into a valid document.

Do I need defusedxml and lxml to unpack and pack Word files?

Yes, you need the Python libraries defusedxml and lxml to unpack and pack Word files. These dependencies are required to securely parse and manipulate the OOXML content that makes up the internal structure of .docx documents.

Why does my Word document break after manually editing the XML content?

Word documents break after manual XML editing due to invalid well-formedness, incorrect content types, or broken relationships. Using an automated pack and unpack workflow validates these elements and repairs whitespace preservation to prevent corruption.