python-docx
Create and manipulate Microsoft Word documents programmatically. Build reports, contracts, and documentation with full control over paragraphs, tables, headers, styles, and images.
How do I install this agent skill?
npx skills add https://github.com/vamseeachanta/workspace-hub --skill python-docxIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill is a legitimate guide for using the standard python-docx library to automate Microsoft Word document creation. It correctly points to official documentation and uses well-known packages from the Python Package Index (PyPI). No malicious patterns or security risks were identified.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerwarn
2/2 files flagged
What does this agent skill do?
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
- Official Documentation: https://python-docx.readthedocs.io/
- GitHub Repository: https://github.com/python-openxml/python-docx
- PyPI Package: https://pypi.org/project/python-docx/
- Open XML SDK Reference: https://docs.microsoft.com/en-us/office/open-xml/
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
- 1. Basic Document Creation
- 2. Advanced Paragraph Formatting
- 3. Table Creation and Formatting
- 4. Headers, Footers, and Page Setup
- 5. Image Insertion and Positioning
- 6. Style Management and Custom Styles
- Report Generation from Database (+1)
- Batch Document Generation
- 1. Document Structure (+3)
- Common Issues
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/vamseeachanta/workspace-hub/python-docx">View python-docx on skillZs</a>