Agent skill

docx-templates

Template-based Word document generation using Jinja2 syntax. Create reports, contracts, and documents with loops, conditionals, tables, and mail merge capabilities.

Stars 4
Forks 4

Install this agent skill to your Project

npx add-skill https://github.com/vamseeachanta/workspace-hub/tree/main/.claude/skills/data/office/docx-templates

SKILL.md

Docx Templates

Quick Start

bash
# Install docxtpl
pip install docxtpl

# Install with image support
pip install docxtpl Pillow

# For Excel data sources
pip install docxtpl openpyxl pandas

# Verify installation
python -c "from docxtpl import DocxTemplate; print('docxtpl ready!')"

When to Use This Skill

USE when:

  • Generating documents from templates with dynamic data
  • Creating mail merge documents from data sources
  • Building reports with loops and conditional sections
  • Need to maintain consistent formatting across generated documents
  • Generating contracts, invoices, letters from templates
  • Processing batch document generation from databases or spreadsheets
  • Templates need professional formatting preserved
  • Non-technical users maintain template design

DON'T USE when:

  • Building documents programmatically from scratch (use python-docx)
  • Need complex document manipulation beyond template filling
  • PDF output is the final format (generate docx then convert)
  • Templates require complex macros or VBA
  • Real-time collaborative editing needed

Prerequisites

bash
# Core installation
pip install docxtpl>=0.16.0

# For image handling
pip install docxtpl Pillow>=9.0.0

# For data processing
pip install docxtpl pandas>=2.0.0 openpyxl>=3.1.0

# For database connections
pip install docxtpl sqlalchemy psycopg2-binary

# All dependencies
pip install docxtpl Pillow pandas openpyxl sqlalchemy

Verify Installation

python
from docxtpl import DocxTemplate, InlineImage
from docx.shared import Mm, Inches

print("docxtpl installed successfully!")

# Quick test
# template = DocxTemplate("template.docx")
# context = {"name": "World"}
# template.render(context)
# template.save("output.docx")

Resources

Version History

  • 1.0.0 (2026-01-17): Initial release with template rendering, loops, conditionals, tables, images, mail merge

This skill provides comprehensive patterns for template-based document generation with docxtpl, refined from production document automation workflows.

Sub-Skills

  • 1. Basic Template Rendering
  • 2. Loops and Iterations
  • 3. Conditional Content
  • 4. Table Generation
  • 5. Image Insertion
  • 6. Mail Merge and Batch Generation
  • Database Integration
  • FastAPI Service
  • 1. Template Design (+2)
  • Template Variables Not Rendering (+2)

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results