Prompting skill

Meta-prompting standard library for generating, optimizing, and composing prompts programmatically via Standards, Handlebars Templates, and Tools.

by danielmiessler·MIT license·★ 19,269 Stars on the repo·GitHub ↗

Use now

Files of Prompting

danielmiessler/main1 file shown
SKILL.md
Show the full text211 lines

Customization

Before executing, check for user customizations at: ~/.claude/LIFEOS/USER/CUSTOMIZATIONS/SKILLS/Prompting/

If this directory exists, load and apply any PREFERENCES.md, configurations, or resources found there. These override default behavior. If the directory does not exist, proceed with skill defaults.

🚨 MANDATORY: Voice Notification (REQUIRED BEFORE ANY ACTION)

You MUST send this notification BEFORE doing anything else when this skill is invoked.

  1. Send voice notification:

    curl -s -X POST http://localhost:31337/notify \
      -H "Content-Type: application/json" \
      -d '{"message": "Running the WORKFLOWNAME workflow in the Prompting skill to ACTION"}' \
      > /dev/null 2>&1 &
    
  2. Output text notification:

    Running the **WorkflowName** workflow in the **Prompting** skill to ACTION...
    

This is not optional. Execute this curl command immediately upon skill invocation.

Prompting - Meta-Prompting & Template System

What It Does

Generates, optimizes, and composes prompts programmatically. It's the standard library for prompt engineering — other skills call it when they need to build or improve a prompt. The output is always a prompt to be used elsewhere, never the final content itself.

Invoke when: meta-prompting, template generation, prompt optimization, programmatic prompt composition, creating dynamic agents, generating structured prompts from data.

The Problem

Prompt engineering tends to get copy-pasted and rewritten by hand across every skill that needs it, so the same patterns drift apart and best practices live in one person's head. When you want to compose a prompt from data — spin up a custom agent, build an eval judge, generate a phased workflow — there's no clean way to separate the structure from the content. This skill makes structure code and content data: one Handlebars template plus different data renders specialized agents, workflows, and eval frameworks, and the engineering standards live in one place every skill can reference.

Ideal-State Prompting — the Default Standard

Every prompt this library generates or optimizes articulates the ideal state, not the procedure. Say WHAT done looks like (as testable outcomes), the CONSTRAINTS, and the high-quality TOOLS available — then trust the model to find HOW. Reasoning choreography ("first analyze, then consider, then decide") is BPE-violating scaffolding: it caps a capable model and rots as models improve. Ideal-state prompting is more precise, not vaguer — the specificity moves to the outcome.

Four keep-classes are legitimate HOW and survive the cut: safety-gate, verified-gotcha, tool-contract, output-format-contract. Deterministic tools (*.ts) are exempt. The test for any procedural line: would a smarter model make this rule unnecessary? Yes → cut; No → it's a keep-class. Full standard: Standards.md § Ideal-State Prompting.

How It Works

Three pillars carry the work:

  • Standards - Anthropic best practices, Claude 4.x patterns, empirical research (markdown-first design, context engineering, the Fabric pattern system, 1,500+ academic papers on prompt optimization). Full guide in Standards.md.
  • Templates - Handlebars-based system for programmatic prompt generation: Primitives (Briefing, Structure, Gate, Roster, Voice) plus eval templates (Judge, Rubric, TestCase, Comparison, Report). The agent-specific DynamicAgent.hbs lives in the Agents skill (Agents/Templates/DynamicAgent.hbs), not here.
  • Tools - Template rendering (RenderTemplate.ts), validation, and data-content separation.

Workflow Routing

Library skill — no Workflows/ directory. Requests route to the rendering tools and reference docs:

Trigger Workflow File
Render a template / compose a prompt from data / Handlebars template RenderTemplate (tool) Tools/RenderTemplate.ts
Validate a template ValidateTemplate (tool) Tools/ValidateTemplate.ts
Prompt engineering standards / best practices / prompt optimization Standards (reference) Standards.md

Examples

Example 1: Using Briefing Template (compose an agent brief)
// Render a structured agent brief from data before launching general-purpose
import { renderTemplate } from '${LIFEOS_SKILL_DIR}/Tools/RenderTemplate.ts';

const prompt = renderTemplate('Primitives/Briefing.hbs', {
  briefing: { type: 'research' },
  agent: { id: 'EN-1', name: 'Skeptical Thinker', personality: {...} },
  task: { description: 'Analyze security architecture', questions: [...] },
  output_format: { type: 'markdown' }
});
Example 2: Using Structure Template (Workflow)
# Data: phased-analysis.yaml
phases:
  - name: Discovery
    purpose: Identify attack surface
    steps:
      - action: Map entry points
        instructions: List all external interfaces...
  - name: Analysis
    purpose: Assess vulnerabilities
    steps:
      - action: Test boundaries
        instructions: Probe each entry point...
bun run RenderTemplate.ts \
  --template Primitives/Structure.hbs \
  --data phased-analysis.yaml
Example 3: Render an Agent Brief from Data
// Render a structured agent brief, then launch general-purpose with it
const brief = renderTemplate('Primitives/Briefing.hbs', {
  agent: { name: 'Skeptical Security Reviewer', role: 'auth bypass and input validation' },
  task: { description: 'Review the auth flow', questions: [...] },
});
// Pass `brief` as the prompt to Agent(subagent_type="general-purpose")

Integration with Other Skills

Agents Skill
  • Uses Templates/Primitives/Briefing.hbs for agent context handoff
  • Uses RenderTemplate.ts to compose dynamic agents
  • Maintains agent-specific template: Agents/Templates/DynamicAgent.hbs
Evals Skill
  • Uses eval-specific templates: Judge, Rubric, TestCase, Comparison, Report
  • Leverages RenderTemplate.ts for eval prompt generation
  • Eval templates may be stored in Evals/Templates/ but use Prompting's engine
Development Skill
  • References Standards.md for prompt best practices
  • Uses Structure.hbs for workflow patterns
  • Applies Gate.hbs for validation checklists

Token Efficiency

The templating system eliminated ~35,000 tokens (65% reduction) across LifeOS:

Area Before After Savings
SKILL.md Frontmatter 20,750 8,300 60%
Agent Briefings 6,400 1,900 70%
Voice Notifications 6,225 725 88%
Workflow Steps 7,500 3,000 60%
TOTAL ~53,000 ~18,000 65%

Best Practices

1. Separation of Concerns
  • Templates: Structure and formatting only
  • Data: Content and parameters (YAML/JSON)
  • Logic: Rendering and validation (TypeScript)
2. DRY Principle
  • Extract repeated patterns into partials
  • Use presets for common configurations
  • Single source of truth for definitions
3. Version Control
  • Templates and data in separate files
  • Track changes independently
  • Enable A/B testing of structures

References

Primary Documentation:

  • Standards.md - Complete prompt engineering guide
  • Templates/README.md - Template system overview
  • Tools/RenderTemplate.ts - Implementation details

Official anchors (drift check): the two authoritative Anthropic sources this skill's standards derive from:

When authoring or auditing Standards.md (not on routine template renders), fetch both and flag where our standards diverge from the current official guidance — these pages change with each model family, and standards written against an older one rot silently. Advisory only: report drift, never auto-adopt; unreachable URLs never block the work.

Research Foundation:

  • Anthropic: "Claude 4.x Best Practices" (November 2025)
  • Anthropic: "Effective Context Engineering for AI Agents"
  • Anthropic: "Prompt Templates and Variables"
  • The Fabric System (January 2024)
  • "The Prompt Report" - arXiv:2406.06608
  • "The Prompt Canvas" - arXiv:2412.05127

Related Skills:

  • Agents - Dynamic agent composition
  • Evals - LLM-as-Judge prompting
  • Development - Spec-driven development patterns

Philosophy: Prompts that write prompts. Structure is code, content is data. Meta-prompting enables dynamic composition where the same template with different data generates specialized agents, workflows, and evaluation frameworks. This is core LifeOS DNA - programmatic prompt generation at scale.

Gotchas

  • Meta-prompting generates PROMPTS, not content. The output is a prompt that gets used elsewhere — not the final deliverable.
  • Templates should be model-agnostic. Don't write prompts that depend on specific model quirks.
  • Test generated prompts before declaring them ready. A prompt that looks good may perform poorly.

Execution Log

After completing any workflow, append a single JSONL entry:

echo '{"ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","skill":"Prompting","workflow":"WORKFLOW_USED","input":"8_WORD_SUMMARY","status":"ok|error","duration_s":SECONDS}' >> ~/.claude/LIFEOS/MEMORY/SKILLS/execution.jsonl

Replace WORKFLOW_USED with the workflow executed, 8_WORD_SUMMARY with a brief input description, and SECONDS with approximate wall-clock time. Log status: "error" if the workflow failed.

1---
2name: Prompting
3version: 1.1.27
4description: "Meta-prompting standard library for generating, optimizing, and composing prompts programmatically via Standards, Handlebars Templates, and Tools; output is always a prompt to use elsewhere, not final content. USE WHEN meta-prompting, template generation, prompt optimization, prompt engineering, write a prompt, create system prompt, Handlebars template, eval prompt, judge prompt. NOT FOR generating final content (use the appropriate domain skill)."
5---
6 
7## Customization
8 
9**Before executing, check for user customizations at:**
10`~/.claude/LIFEOS/USER/CUSTOMIZATIONS/SKILLS/Prompting/`
11 
12If this directory exists, load and apply any PREFERENCES.md, configurations, or resources found there. These override default behavior. If the directory does not exist, proceed with skill defaults.
13 
14 
15## 🚨 MANDATORY: Voice Notification (REQUIRED BEFORE ANY ACTION)
16 
17**You MUST send this notification BEFORE doing anything else when this skill is invoked.**
18 
191. **Send voice notification**:
20 ```bash
21 curl -s -X POST http://localhost:31337/notify \
22 -H "Content-Type: application/json" \
23 -d '{"message": "Running the WORKFLOWNAME workflow in the Prompting skill to ACTION"}' \
24 > /dev/null 2>&1 &
25 ```
26 
272. **Output text notification**:
28 ```
29 Running the **WorkflowName** workflow in the **Prompting** skill to ACTION...
30 ```
31 
32**This is not optional. Execute this curl command immediately upon skill invocation.**
33 
34# Prompting - Meta-Prompting & Template System
35 
36## What It Does
37 
38Generates, optimizes, and composes prompts programmatically. It's the standard library for prompt engineering — other skills call it when they need to build or improve a prompt. The output is always a prompt to be used elsewhere, never the final content itself.
39 
40**Invoke when:** meta-prompting, template generation, prompt optimization, programmatic prompt composition, creating dynamic agents, generating structured prompts from data.
41 
42## The Problem
43 
44Prompt engineering tends to get copy-pasted and rewritten by hand across every skill that needs it, so the same patterns drift apart and best practices live in one person's head. When you want to compose a prompt from data — spin up a custom agent, build an eval judge, generate a phased workflow — there's no clean way to separate the structure from the content. This skill makes structure code and content data: one Handlebars template plus different data renders specialized agents, workflows, and eval frameworks, and the engineering standards live in one place every skill can reference.
45 
46## Ideal-State Prompting — the Default Standard
47 
48**Every prompt this library generates or optimizes articulates the ideal state, not the procedure.** Say WHAT done looks like (as testable outcomes), the CONSTRAINTS, and the high-quality TOOLS available — then trust the model to find HOW. Reasoning choreography ("first analyze, then consider, then decide") is BPE-violating scaffolding: it caps a capable model and rots as models improve. Ideal-state prompting is *more* precise, not vaguer — the specificity moves to the outcome.
49 
50Four keep-classes are legitimate HOW and survive the cut: **safety-gate**, **verified-gotcha**, **tool-contract**, **output-format-contract**. Deterministic tools (`*.ts`) are exempt. The test for any procedural line: *would a smarter model make this rule unnecessary?* Yes → cut; No → it's a keep-class. Full standard: `Standards.md` § Ideal-State Prompting.
51 
52## How It Works
53 
54Three pillars carry the work:
55 
56- **Standards** - Anthropic best practices, Claude 4.x patterns, empirical research (markdown-first design, context engineering, the Fabric pattern system, 1,500+ academic papers on prompt optimization). Full guide in `Standards.md`.
57- **Templates** - Handlebars-based system for programmatic prompt generation: Primitives (Briefing, Structure, Gate, Roster, Voice) plus eval templates (Judge, Rubric, TestCase, Comparison, Report). The agent-specific `DynamicAgent.hbs` lives in the Agents skill (`Agents/Templates/DynamicAgent.hbs`), not here.
58- **Tools** - Template rendering (`RenderTemplate.ts`), validation, and data-content separation.
59 
60## Workflow Routing
61 
62Library skill — no `Workflows/` directory. Requests route to the rendering tools and reference docs:
63 
64| Trigger | Workflow | File |
65|---------|----------|------|
66| Render a template / compose a prompt from data / Handlebars template | RenderTemplate (tool) | `Tools/RenderTemplate.ts` |
67| Validate a template | ValidateTemplate (tool) | `Tools/ValidateTemplate.ts` |
68| Prompt engineering standards / best practices / prompt optimization | Standards (reference) | `Standards.md` |
69 
70## Examples
71 
72### Example 1: Using Briefing Template (compose an agent brief)
73 
74```typescript
75// Render a structured agent brief from data before launching general-purpose
76import { renderTemplate } from '${LIFEOS_SKILL_DIR}/Tools/RenderTemplate.ts';
77 
78const prompt = renderTemplate('Primitives/Briefing.hbs', {
79 briefing: { type: 'research' },
80 agent: { id: 'EN-1', name: 'Skeptical Thinker', personality: {...} },
81 task: { description: 'Analyze security architecture', questions: [...] },
82 output_format: { type: 'markdown' }
83});
84```
85 
86### Example 2: Using Structure Template (Workflow)
87 
88```yaml
89# Data: phased-analysis.yaml
90phases:
91 - name: Discovery
92 purpose: Identify attack surface
93 steps:
94 - action: Map entry points
95 instructions: List all external interfaces...
96 - name: Analysis
97 purpose: Assess vulnerabilities
98 steps:
99 - action: Test boundaries
100 instructions: Probe each entry point...
101```
102 
103```bash
104bun run RenderTemplate.ts \
105 --template Primitives/Structure.hbs \
106 --data phased-analysis.yaml
107```
108 
109### Example 3: Render an Agent Brief from Data
110 
111```typescript
112// Render a structured agent brief, then launch general-purpose with it
113const brief = renderTemplate('Primitives/Briefing.hbs', {
114 agent: { name: 'Skeptical Security Reviewer', role: 'auth bypass and input validation' },
115 task: { description: 'Review the auth flow', questions: [...] },
116});
117// Pass `brief` as the prompt to Agent(subagent_type="general-purpose")
118```
119 
120## Integration with Other Skills
121 
122### Agents Skill
123- Uses `Templates/Primitives/Briefing.hbs` for agent context handoff
124- Uses `RenderTemplate.ts` to compose dynamic agents
125- Maintains agent-specific template: `Agents/Templates/DynamicAgent.hbs`
126 
127### Evals Skill
128- Uses eval-specific templates: Judge, Rubric, TestCase, Comparison, Report
129- Leverages `RenderTemplate.ts` for eval prompt generation
130- Eval templates may be stored in `Evals/Templates/` but use Prompting's engine
131 
132### Development Skill
133- References `Standards.md` for prompt best practices
134- Uses `Structure.hbs` for workflow patterns
135- Applies `Gate.hbs` for validation checklists
136 
137## Token Efficiency
138 
139The templating system eliminated **~35,000 tokens (65% reduction)** across LifeOS:
140 
141| Area | Before | After | Savings |
142|------|--------|-------|---------|
143| SKILL.md Frontmatter | 20,750 | 8,300 | 60% |
144| Agent Briefings | 6,400 | 1,900 | 70% |
145| Voice Notifications | 6,225 | 725 | 88% |
146| Workflow Steps | 7,500 | 3,000 | 60% |
147| **TOTAL** | ~53,000 | ~18,000 | **65%** |
148 
149## Best Practices
150 
151### 1. Separation of Concerns
152- **Templates**: Structure and formatting only
153- **Data**: Content and parameters (YAML/JSON)
154- **Logic**: Rendering and validation (TypeScript)
155 
156### 2. DRY Principle
157- Extract repeated patterns into partials
158- Use presets for common configurations
159- Single source of truth for definitions
160 
161### 3. Version Control
162- Templates and data in separate files
163- Track changes independently
164- Enable A/B testing of structures
165 
166## References
167 
168**Primary Documentation:**
169- `Standards.md` - Complete prompt engineering guide
170- `Templates/README.md` - Template system overview
171- `Tools/RenderTemplate.ts` - Implementation details
172 
173**Official anchors (drift check):** the two authoritative Anthropic sources this skill's standards derive from:
174- Prompt engineering: https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview
175- Context engineering: https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
176 
177When authoring or auditing `Standards.md` (not on routine template renders), fetch both and flag where our standards diverge from the current official guidance — these pages change with each model family, and standards written against an older one rot silently. Advisory only: report drift, never auto-adopt; unreachable URLs never block the work.
178 
179**Research Foundation:**
180- Anthropic: "Claude 4.x Best Practices" (November 2025)
181- Anthropic: "Effective Context Engineering for AI Agents"
182- Anthropic: "Prompt Templates and Variables"
183- The Fabric System (January 2024)
184- "The Prompt Report" - arXiv:2406.06608
185- "The Prompt Canvas" - arXiv:2412.05127
186 
187**Related Skills:**
188- Agents - Dynamic agent composition
189- Evals - LLM-as-Judge prompting
190- Development - Spec-driven development patterns
191 
192---
193 
194**Philosophy:** Prompts that write prompts. Structure is code, content is data. Meta-prompting enables dynamic composition where the same template with different data generates specialized agents, workflows, and evaluation frameworks. This is core LifeOS DNA - programmatic prompt generation at scale.
195 
196## Gotchas
197 
198- **Meta-prompting generates PROMPTS, not content.** The output is a prompt that gets used elsewhere — not the final deliverable.
199- **Templates should be model-agnostic.** Don't write prompts that depend on specific model quirks.
200- **Test generated prompts before declaring them ready.** A prompt that looks good may perform poorly.
201 
202## Execution Log
203 
204After completing any workflow, append a single JSONL entry:
205 
206```bash
207echo '{"ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","skill":"Prompting","workflow":"WORKFLOW_USED","input":"8_WORD_SUMMARY","status":"ok|error","duration_s":SECONDS}' >> ~/.claude/LIFEOS/MEMORY/SKILLS/execution.jsonl
208```
209 
210Replace `WORKFLOW_USED` with the workflow executed, `8_WORD_SUMMARY` with a brief input description, and `SECONDS` with approximate wall-clock time. Log `status: "error"` if the workflow failed.
211 

Discussion