python-pptx-6-template-based-generation

Sub-skill of python-pptx: 6. Template-Based Generation.

5 stars

Best use case

python-pptx-6-template-based-generation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Sub-skill of python-pptx: 6. Template-Based Generation.

Teams using python-pptx-6-template-based-generation should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/6-template-based-generation/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/_archive/data/office/python-pptx/6-template-based-generation/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/6-template-based-generation/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How python-pptx-6-template-based-generation Compares

Feature / Agentpython-pptx-6-template-based-generationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Sub-skill of python-pptx: 6. Template-Based Generation.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 6. Template-Based Generation

## 6. Template-Based Generation


```python
"""
Generate presentations from templates with placeholder replacement.
"""
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.shapes import MSO_SHAPE_TYPE
from typing import Dict, Any, List
from pathlib import Path
from copy import deepcopy

def replace_text_in_shapes(slide, replacements: Dict[str, str]) -> None:
    """Replace placeholder text in all shapes on a slide."""
    for shape in slide.shapes:
        if shape.has_text_frame:
            for paragraph in shape.text_frame.paragraphs:
                for run in paragraph.runs:
                    for key, value in replacements.items():
                        if f'{{{{{key}}}}}' in run.text:
                            run.text = run.text.replace(f'{{{{{key}}}}}', str(value))

        if shape.has_table:
            for row in shape.table.rows:
                for cell in row.cells:
                    for paragraph in cell.text_frame.paragraphs:
                        for run in paragraph.runs:
                            for key, value in replacements.items():
                                if f'{{{{{key}}}}}' in run.text:
                                    run.text = run.text.replace(
                                        f'{{{{{key}}}}}',
                                        str(value)
                                    )


def generate_from_template(
    template_path: str,
    output_path: str,
    data: Dict[str, Any]
) -> None:
    """Generate presentation from template with data substitution."""
    prs = Presentation(template_path)

    for slide in prs.slides:
        replace_text_in_shapes(slide, data)

    prs.save(output_path)
    print(f"Generated presentation: {output_path}")


def create_monthly_report_template(output_path: str) -> None:
    """Create a template for monthly reports."""
    prs = Presentation()

    # Title slide with placeholders
    slide = prs.slides.add_slide(prs.slide_layouts[6])

    # Title placeholder
    title = slide.shapes.add_textbox(
        Inches(0.5), Inches(2.5),
        Inches(12), Inches(1.5)
    )
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "{{report_title}}"
    p.font.size = Pt(44)
    p.font.bold = True
    p.alignment = 1  # Center

    # Subtitle
    subtitle = slide.shapes.add_textbox(
        Inches(0.5), Inches(4),
        Inches(12), Inches(1)
    )
    tf = subtitle.text_frame
    p = tf.paragraphs[0]
    p.text = "{{report_period}}"
    p.font.size = Pt(24)
    p.alignment = 1

    # Summary slide
    slide = prs.slides.add_slide(prs.slide_layouts[6])

    title = slide.shapes.add_textbox(
        Inches(0.5), Inches(0.5),
        Inches(12), Inches(1)
    )
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Executive Summary"
    p.font.size = Pt(32)
    p.font.bold = True

    # Key metrics boxes
    metrics = [
        ("Revenue", "{{revenue}}"),
        ("Customers", "{{customers}}"),
        ("Growth", "{{growth}}"),
    ]

    for i, (label, placeholder) in enumerate(metrics):
        x = 1 + (i * 4)

        # Label
        label_box = slide.shapes.add_textbox(
            Inches(x), Inches(2),
            Inches(3), Inches(0.5)
        )
        tf = label_box.text_frame
        p = tf.paragraphs[0]
        p.text = label
        p.font.size = Pt(14)
        p.alignment = 1

        # Value box
        shape = slide.shapes.add_shape(
            MSO_SHAPE.ROUNDED_RECTANGLE,
            Inches(x), Inches(2.5),
            Inches(3), Inches(1.5)
        )
        shape.fill.solid()
        shape.fill.fore_color.rgb = RgbColor(0x44, 0x72, 0xC4)
        tf = shape.text_frame
        p = tf.paragraphs[0]
        p.text = placeholder
        p.font.size = Pt(28)
        p.font.bold = True
        p.font.color.rgb = RgbColor(255, 255, 255)
        p.alignment = 1

    prs.save(output_path)
    print(f"Template saved: {output_path}")


def batch_generate_presentations(
    template_path: str,
    data_list: List[Dict[str, Any]],
    output_dir: str
) -> List[str]:
    """Generate multiple presentations from template."""
    output_path = Path(output_dir)
    output_path.mkdir(parents=True, exist_ok=True)

    generated = []

    for data in data_list:
        filename = f"{data.get('filename', 'presentation')}.pptx"
        file_path = output_path / filename

        generate_from_template(template_path, str(file_path), data)
        generated.append(str(file_path))

    return generated


# Example usage:
# create_monthly_report_template('monthly_template.pptx')
#
# data = {
#     'report_title': 'Monthly Performance Report',
#     'report_period': 'January 2026',
#     'revenue': '$12.5M',
#     'customers': '45,000',
#     'growth': '+15%'
# }
# generate_from_template('monthly_template.pptx', 'january_report.pptx', data)
```

Related Skills

wave-based-parallel-plan-execution

5
from vamseeachanta/workspace-hub

Orchestrate phase execution by discovering dependencies, grouping into waves, spawning subagents, and collecting results with optional wave filtering

python-import-path-mismatch-debugging

5
from vamseeachanta/workspace-hub

Diagnose and fix ModuleNotFoundError when a package is installed but imports still fail due to environment/path mismatches

python-import-path-debugging

5
from vamseeachanta/workspace-hub

Diagnose ModuleNotFoundError when a package is installed but still fails to import

label-driven-prompt-generation-architecture

5
from vamseeachanta/workspace-hub

Pattern for building automation scripts that classify GitHub issues into prompt templates using label-based routing and extract contextual data for batch processing

batch-syntax-fix-with-regex-line-based-fallback

5
from vamseeachanta/workspace-hub

Fix repeated syntax errors across many files using regex, then fall back to line-based parsing when regex fails

agent-team-prompt-generation

5
from vamseeachanta/workspace-hub

Create self-contained execution prompts that define multi-role workflows for Codex sessions without external dependencies

interactive-Codex-to-file-based-fallback

5
from vamseeachanta/workspace-hub

Switch from tmux/interactive Codex to file-based Codex -p execution when interactive runs fail with upstream errors or analysis-only stalls, then verify landing from git/GitHub state.

gtm-workflow-gif-generation

5
from vamseeachanta/workspace-hub

Generate workflow-style GTM GIFs from validated HTML demo reports using synthetic scene slides plus Playwright/Pillow scroll capture, with Python 3.12 fallback and GIF size optimization.

gtm-demo-workflow-gif-generation

5
from vamseeachanta/workspace-hub

Generate GTM demo GIF assets from validated HTML reports, including both report-scroll GIFs and one higher-fidelity workflow-style GIF, while avoiding Playwright/Python environment traps.

python-debugpy

5
from vamseeachanta/workspace-hub

Debug Python: pdb REPL + debugpy remote (DAP).

stable-diffusion-image-generation

5
from vamseeachanta/workspace-hub

State-of-the-art text-to-image generation with Stable Diffusion models via HuggingFace Diffusers. Use when generating images from text prompts, performing image-to-image translation, inpainting, or building custom diffusion pipelines.

orcawave-mesh-generation

5
from vamseeachanta/workspace-hub

Panel mesh generation for OrcaWave diffraction analysis. Use when converting CAD/STL to panel mesh, validating mesh quality, running convergence studies, or generating GDF files for hydrodynamic computations.