Skip to content
OpenSmartRoute
Skillv1.0.0

template-engine

Auto-fill document templates with data - mail merge for any format

by claude-office-skills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from claude-office-skills/skills (template-engine/SKILL.md) via skills.sh. Install upstream with npx skills add claude-office-skills/skills --skill template-engine. Copyright stays with the author (MIT).

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

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

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)

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,john@example.com,Acme
# Jane,jane@example.com,Corp

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

Advanced: Conditional Content

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

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

Resources

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/claude-office-skills-skills-template-engine/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

claude-office-skills-skills-template-engine.ocm.jsonjson
{
  "ocm": "1",
  "id": "claude-office-skills-skills-template-engine",
  "kind": "skill",
  "name": "template-engine",
  "description": "Auto-fill document templates with data - mail merge for any format",
  "publisher": "claude-office-skills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "template",
      "engine",
      "autofill",
      "docxtpl",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Auto-fill document templates with data - mail merge for any format"
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/claude-office-skills/skills",
      "path": "template-engine/SKILL.md",
      "ref": "HEAD",
      "url": "https://www.skills.sh/claude-office-skills/skills/template-engine",
      "key": "claude-office-skills/skills/template-engine/SKILL.md"
    },
    "license": "MIT"
  },
  "instructions": "# Template Engine Skill\n\n## Overview\n\nThis skill enables template-based document generation - define templates with placeholders, then automatically fill them with data. Works with Word, Excel, PowerPoint, and more.\n\n## How to Use\n\n1. Describe what you want to accomplish\n2. Provide any required input data or files\n3. I'll execute the appropriate operations\n\n**Example prompts:**\n- \"Mail merge for bulk letters/contracts\"\n- \"Generate personalized reports from data\"\n- \"Create certificates from templates\"\n- \"Auto-fill forms with user data\"\n\n## Domain Knowledge\n\n\n### Template Syntax (Jinja2-based)\n\n",
  "cost": {
    "context_tokens": 930
  }
}

Fetch it by URL: GET /api/v1/registry/claude-office-skills-skills-template-engine/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.