prompt-template
Create and manage reusable prompt templates
What this skill does
# Prompt Template Skill
> Standardize prompt construction for agents with reusable, composable templates.
## Overview
Consistent, well-structured prompts lead to better agent behavior. This skill provides:
- Template patterns for common prompt structures
- Variable interpolation for dynamic content
- Composition patterns for building complex prompts
- Testing approaches for prompt quality
## Core Principles
1. **Separation of concerns** - Structure, content, and variables are separate
2. **Composability** - Small templates combine into larger ones
3. **Testability** - Templates can be validated before use
4. **Versioning** - Track prompt changes like code
## Template Structure
### Basic Template Format
```yaml
# prompts/templates/example.yaml
name: example_template
version: "1.0"
description: Brief description of this template's purpose
# Variables that must be provided
variables:
- name: task_description
required: true
description: What the agent should do
- name: context
required: false
default: ""
description: Additional context
# The actual prompt template
template: |
You are a helpful assistant.
## Task
{task_description}
## Context
{context}
## Instructions
- Be concise
- Cite sources when possible
```
### Template Directory Structure
```
prompts/
├── templates/ # Reusable templates
│ ├── base/ # Foundation templates
│ │ ├── researcher.yaml
│ │ ├── coder.yaml
│ │ └── writer.yaml
│ ├── components/ # Composable parts
│ │ ├── output_format.yaml
│ │ ├── safety_guidelines.yaml
│ │ └── tool_usage.yaml
│ └── agents/ # Full agent prompts
│ ├── research_agent.yaml
│ └── code_review_agent.yaml
├── rendered/ # Compiled prompts (git-ignored)
└── tests/ # Prompt tests
```
## Template Engine
### Implementation
```python
#!/usr/bin/env python3
"""Prompt template engine."""
import re
import yaml
from pathlib import Path
from typing import Dict, Any, Optional, List
from dataclasses import dataclass
@dataclass
class TemplateVariable:
name: str
required: bool
default: Optional[str] = None
description: str = ""
class PromptTemplate:
"""A reusable prompt template."""
def __init__(self, path: str):
with open(path) as f:
data = yaml.safe_load(f)
self.name = data["name"]
self.version = data.get("version", "1.0")
self.description = data.get("description", "")
self.template = data["template"]
self.path = path
# Parse variables
self.variables = []
for var in data.get("variables", []):
self.variables.append(TemplateVariable(
name=var["name"],
required=var.get("required", False),
default=var.get("default"),
description=var.get("description", "")
))
# Parse includes
self.includes = data.get("includes", [])
def render(self, **kwargs) -> str:
"""Render the template with provided variables."""
# Check required variables
for var in self.variables:
if var.required and var.name not in kwargs:
raise ValueError(f"Missing required variable: {var.name}")
# Apply defaults
context = {}
for var in self.variables:
if var.name in kwargs:
context[var.name] = kwargs[var.name]
elif var.default is not None:
context[var.name] = var.default
else:
context[var.name] = ""
# Handle includes
result = self.template
for include in self.includes:
include_template = PromptTemplate(include)
include_content = include_template.render(**kwargs)
result = result.replace(f"{{{{include:{include}}}}}", include_content)
# Substitute variables
for key, value in context.items():
result = result.replace(f"{{{key}}}", str(value))
return result.strip()
def get_variable_names(self) -> List[str]:
"""Get all variable names in template."""
# Find {variable_name} patterns
pattern = r'\{(\w+)\}'
found = set(re.findall(pattern, self.template))
return list(found)
def validate(self) -> List[str]:
"""Validate template structure."""
errors = []
# Check all referenced variables are defined
referenced = set(self.get_variable_names())
defined = {v.name for v in self.variables}
undefined = referenced - defined
if undefined:
errors.append(f"Undefined variables: {undefined}")
unused = defined - referenced
if unused:
errors.append(f"Unused variables: {unused}")
# Check includes exist
for include in self.includes:
if not Path(include).exists():
errors.append(f"Include not found: {include}")
return errors
class TemplateRegistry:
"""Registry of all available templates."""
def __init__(self, templates_dir: str = "prompts/templates"):
self.templates_dir = Path(templates_dir)
self.templates: Dict[str, PromptTemplate] = {}
self._load_templates()
def _load_templates(self):
"""Load all templates from directory."""
for yaml_file in self.templates_dir.rglob("*.yaml"):
try:
template = PromptTemplate(str(yaml_file))
self.templates[template.name] = template
except Exception as e:
print(f"Warning: Failed to load {yaml_file}: {e}")
def get(self, name: str) -> Optional[PromptTemplate]:
"""Get a template by name."""
return self.templates.get(name)
def list(self) -> List[str]:
"""List all template names."""
return list(self.templates.keys())
def render(self, name: str, **kwargs) -> str:
"""Render a template by name."""
template = self.get(name)
if not template:
raise ValueError(f"Template not found: {name}")
return template.render(**kwargs)
```
## Template Patterns
### Pattern 1: Base Agent Template
```yaml
# prompts/templates/base/agent_base.yaml
name: agent_base
version: "1.0"
description: Base template for all agents
variables:
- name: role
required: true
description: The agent's role (e.g., "researcher", "coder")
- name: capabilities
required: true
description: What the agent can do
- name: constraints
required: false
default: ""
description: Limitations or rules
template: |
You are a {role} agent.
## Capabilities
{capabilities}
## Constraints
{constraints}
## Response Format
- Be concise and actionable
- Structure responses with clear sections
- Cite sources when making claims
```
### Pattern 2: Task-Specific Template
```yaml
# prompts/templates/tasks/code_review.yaml
name: code_review_task
version: "1.0"
description: Template for code review tasks
variables:
- name: code
required: true
description: The code to review
- name: language
required: true
description: Programming language
- name: focus_areas
required: false
default: "security, performance, readability"
description: Areas to focus on
template: |
Review the following {language} code:
```{language}
{code}
```
## Focus Areas
{focus_areas}
## Review Checklist
- [ ] Security vulnerabilities
- [ ] Performance issues
- [ ] Code style and readability
- [ ] Error handling
- [ ] Test coverage considerations
Provide specific, actionable feedback with line references.
```
### Pattern 3: Composable Components
```yaml
# prompts/templates/components/output_json.yaml
name: output_json
version: "1.0"
description: JSON output format instructions
variables:
- name: schema
required: true
description: JSON schema to follow
teRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.