prompt-template
БесплатноБез исполняемых скриптовНе проверенCreate and manage reusable prompt templates
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
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
- Separation of concerns - Structure, content, and variables are separate
- Composability - Small templates combine into larger ones
- Testability - Templates can be validated before use
- Versioning - Track prompt changes like code
Template Structure
Basic Template Format
# 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
#!/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 fou
Установить prompt-template в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл prompt-template?
Create and manage reusable prompt templates
Как установить скилл prompt-template?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл prompt-template запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic