Skip to main content
skill CX Codex

template-engine — Claude Code skill: what it does, how to install

Fills Word, Excel, and PowerPoint templates with data from dictionaries or CSV files. Built for automated document generation and mail merge.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add claude-office-skills/skills --skill template-engine -a claude-code
Open on GitHub

What template-engine does

The skill automates document population by pairing Jinja2-style placeholders with incoming data. It handles simple variable swaps like {{ variable }}, loops through items, and applies conditional blocks like {% if condition %}. Word documents rely on docxtpl, while Excel workbooks are processed with openpyxl.

Bulk generation works alongside the fill_docx_template tool from the office MCP server. Feed a CSV spreadsheet to a mail merge routine, and the skill writes a personalized file for each entry. That saves manual effort on contracts or custom reports.

Your runtime must have Python with python-docx, openpyxl, python-pptx, reportlab, and jinja2 installed. Without these libraries in your environment, the rendering scripts will fail.

What it helps with

  • merge customer data from CSV files into batch contracts
  • fill Word templates using Jinja2 loops and conditional blocks
  • populate Excel spreadsheets with runtime key-value pairs
  • generate personalized certificate files from standardized templates

Example prompts for the agent

  • Fill templates/order_confirmation.docx with details for order ORD-12345
  • Run a mail merge using templates/welcome_letter.docx and data/contacts.csv
  • Populate client fields in the contract template and save it to output

How to install template-engine

1Skills CLI (Vercel)

npx skills add claude-office-skills/skills --skill template-engine -a claude-code

2Manually: put the files in place

~/.claude/skills/template-engine/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/template-engine/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about template-engine

How to install template-engine in Claude Code?

Run npx skills add claude-office-skills/skills --skill template-engine -a claude-code. The skill file is placed at ~/.claude/skills/template-engine/SKILL.md.

What does template-engine do?

It populates document templates across Word, Excel, and PowerPoint with structured data. It supports Jinja2 syntax for loops, conditionals, and variable substitution.

What dependencies are required to run template-engine?

You need a local Python environment with python-docx, openpyxl, python-pptx, reportlab, jinja2, and docxtpl installed via pip.

Source text

SKILL.md · MIT
---
# ═══════════════════════════════════════════════════════════════════════════════
# CLAUDE OFFICE SKILL - Enhanced Metadata v2.0
# ═══════════════════════════════════════════════════════════════════════════════

# Basic Information
name: template-engine
description: "Auto-fill document templates with data - mail merge for any format"
version: "1.0"
author: claude-office-skills
license: MIT

# Categorization
category: template
tags:
  - template
  - engine
  - autofill
  - docxtpl
department: All

# AI Model Compatibility
models:
  recommended:
    - claude-sonnet-4
    - claude-opus-4
  compatible:
    - claude-3-5-sonnet
    - gpt-4
    - gpt-4o

# MCP Tools Integration
mcp:
  server: office-mcp
  tools:
    - fill_docx_template

# Skill Capabilities
capabilities:
  - template_filling
  - document_automation

# Language Support
languages:
  - en
  - zh
---

# Template Engine Skill

## Overview

This skill enables template-based document generation - define templates with placeholders, then automatically fill them with data. Works with Word, Excel, PowerPoint, and more.

## How to Use

1. Describe what you want to accomplish
2. Provide any required input data or files
3. I'll execute the appropriate operations

**Example prompts:**
- "Mail merge for bulk letters/contracts"
- "Generate personalized reports from data"
- "Create certificates from templates"
- "Auto-fill forms with user data"

## Domain Knowledge


### Template Syntax (Jinja2-based)

```
{{ variable }}           - Simple substitution
{% for item in list %}   - Loop
{% if condition %}       - Conditional
{{ date | format_date }} - Filter
```

### Word Template Example

```python
from docxtpl import DocxTemplate

# Create template with placeholders:
# Dear {{ name }},
# Thank you for your order #{{ order_id }}...

def fill_template(template_path: str, data: dict, output_path: str):
    doc = DocxTemplate(template_path)
    doc.render(data)
    doc.save(output_path)
    return output_path

# Usage
fill_template(
    "templates/order_confirmation.docx",
    {
        "name": "John Smith",
        "order_id": "ORD-12345",
        "items": [
            {"name": "Product A", "qty": 2, "price": 29.99},
            {"name": "Product B", "qty": 1, "price": 49.99}
        ],
        "total": 109.97
    },
    "output/confirmation_john.docx"
)
```

### Excel Template

```python
from openpyxl import load_workbook
import re

def fill_excel_template(template_path: str, data: dict, output_path: str):
    wb = load_workbook(template_path)
    ws = wb.active
    
    # Find and replace placeholders like {{name}}
    for row in ws.iter_rows():
        for cell in row:
            if cell.value and isinstance(cell.value, str):
                for key, value in data.items():
                    placeholder = "{{" + key + "}}"
                    if placeholder in cell.value:
                        cell.value = cell.value.replace(placeholder, str(value))
    
    wb.save(output_path)
    return output_path
```

### Bulk Generation (Mail Merge)

```python
import csv
from pathlib import Path

def mail_merge(template_path: str, data_csv: str, output_dir: str):
    """Generate documents for each row in CSV."""
    
    Path(output_dir).mkdir(exist_ok=True)
    
    with open(data_csv) as f:
        reader = csv.DictReader(f)
        
        for i, row in enumerate(reader):
            output_path = f"{output_dir}/document_{i+1}.docx"
            fill_template(template_path, row, output_path)
            print(f"Generated: {output_path}")

# Usage with contacts.csv:
# name,email,company
# John,[email protected],Acme
# Jane,[email protected],Corp

mail_merge(
    "templates/welcome_letter.docx",
    "data/contacts.csv",
    "output/letters"
)
```

### Advanced: Conditional Content

```python
from docxtpl import DocxTemplate

# Template with conditionals:
# {% if vip %}
# Thank you for being a VIP member!
# {% else %}
# Thank you for your purchase.
# {% endif %}

doc = DocxTemplate("template.docx")
doc.render({
    "name": "John",
    "vip": True,
    "discount": 20
})
doc.save("output.docx")
```


## Best Practices

1. **Use clear placeholder naming ({{client_name}})**
2. **Validate data before rendering**
3. **Handle missing data gracefully**
4. **Keep templates version-controlled**

## Installation

```bash
# Install required dependencies
pip install python-docx openpyxl python-pptx reportlab jinja2
```

## Resources

- [docxtpl / yumdocs Repository](https://github.com/elapouya/python-docxtpl)
- [Claude Office Skills Hub](https://github.com/claude-office-skills/skills)

© claude-office-skills · MIT · claude-office-skills/skills

Similar skills

Everything for Office documents →

From the same set111

Invoice Organizer Pulls data out of invoices and receipts, sorts expenses into categories, keeps a payment register and builds reports for tax time. CX Codex +1 4,600installs PDF Watermark Adds text and image watermarks, headers, footers, and page numbers to PDF documents. Helps brand drafts and confidential files before sharing. CX Codex +1 4,600installs Mailchimp Automation A skill that automates Mailchimp email marketing: builds campaigns, segments subscribers, sets up email sequences and reads engagement reports. CX Codex +1 4,600installs invoice-template This skill turns structured invoice data into a finished PDF: line items, tax, totals, billing details. Useful when invoices follow a template instead of being drawn by hand. CX Codex +1 4,600installs Security Monitoring A skill for automating security monitoring: detection rules, alerting, incident response and compliance checks. CX Codex +1 4,600installs Applicant Screening Screens resumes against role requirements and gives each candidate a score. Useful when applications pile up and someone has to read them all. CX Codex +1 4,600installs Lead Qualification Evaluates and scores sales leads using BANT, MEDDIC, and GPCTBA/C&I frameworks. It helps teams prioritize prospect pipelines and spot deal-breakers early. CX Codex +1 4,600installs Webhook Automation A skill for building webhook integrations: receiving events, verifying signatures, routing and transforming payloads. Useful when payments, GitHub or Slack need to talk to your own services. CX Codex +1 4,600installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor