mcpField
P
python-docx

python-docx

github.com/vamseeachantaDocuments1857 installsUpdated today
Repository

About python-docx

python-docx is a skill covering Python library patterns for creating and editing Microsoft Word documents. It is intended for document automation, with guidance on formatting, templates, and batch generation.

Key features

  1. 01Create and modify DOCX documents
  2. 02Format paragraphs, tables, and styles
  3. 03Add headers, footers, and images
  4. 04Automate templates and mail merges
  5. 05Generate documents in batches

Use cases

  1. 01Producing consistently formatted reports
  2. 02Generating contracts or invoices from data
  3. 03Editing existing Word documents
  4. 04Creating multi-section documents with images

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/vamseeachanta/workspace-hub --skill python-docx

After installing, type/python-docxin Claude Code to confirm it loaded.

Details

From the project README

Python Docx

Overview

Python-docx is a Python library for creating and manipulating Microsoft Word (.docx) documents. This skill covers comprehensive patterns for document automation including:

  • Document creation from scratch or templates
  • Paragraph formatting with styles, fonts, and alignment
  • Table generation with merged cells, styles, and formatting
  • Headers and footers with page numbers and dynamic content
  • Image insertion with sizing and positioning
  • Style management for consistent document appearance
  • Template manipulation for document workflows
  • Mail merge patterns for bulk document generation

When to Use This Skill

USE when:
  • Creating Word documents programmatically from data
  • Generating reports with consistent formatting
  • Building contracts, invoices, or legal documents
  • Automating template-based document creation
  • Modifying existing Word documents
  • Creating documents with complex table structures
  • Generating technical documentation with code blocks
  • Building multi-section documents with headers/footers
  • Creating documents with embedded images and charts
  • Batch processing document generation
DON'T USE when:
  • Simple template filling (use docx-templates instead)
  • PDF generation is the final output (use pypdf or reportlab)
  • Need real-time collaborative editing
  • Document requires complex macros or VBA
  • Need to preserve complex Word features (use COM automation on Windows)
  • Only need to extract text from documents (use python-docx2txt)

Prerequisites

Installation
# Using pip
pip install python-docx

# Using uv (recommended)
uv pip install python-docx

# With image support
pip install python-docx Pillow

# Full installation with all optional dependencies
pip install python-docx Pillow lxml
Verify Installation
from docx import Document
from docx.shared import Inches, Pt, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT

print("python-docx installed successfully!")

Version History

1.0.0 (2026-01-17)
  • Initial skill creation
  • Core capabilities documentation
  • 6 complete code examples
  • Integration patterns
  • Best practices guide
  • Troubleshooting section

Resources

Related Skills

  • docx-templates - Jinja2-style template rendering for Word documents
  • pypdf - PDF manipulation and generation
  • openpyxl - Excel file automation
  • python-pptx - PowerPoint presentation generation

This skill provides comprehensive patterns for Word document automation refined from production document generation systems.

Sub-Skills

Comments

Markdown supported