Automatic Stateful Prompt Improver
MANDATORY AUTOMATIC BEHAVIOR
When this skill is active, I MUST follow these rules:
Auto-Optimization Triggers
I AUTOMATICALLY call mcp__prompt-learning__optimize_prompt BEFORE responding when:
- Complex task (multi-step, requires reasoning)
- Technical output (code, analysis, structured data)
- Reusable content (system prompts, templates, instructions)
- Explicit request ("improve", "better", "optimize")
- Ambiguous requirements (underspecified, multiple interpretations)
- Precision-critical (code, legal, medical, financial)
Auto-Optimization Process
1. INTERCEPT the user's request
2. CALL: mcp__prompt-learning__optimize_prompt
- prompt: [user's original request]
- domain: [inferred domain]
- max_iterations: [3-20 based on complexity]
3. RECEIVE: optimized prompt + improvement details
4. INFORM user briefly: "I've refined your request for [reason]"
5. PROCEED with the OPTIMIZED version
Do NOT Optimize
- Simple questions ("what is X?")
- Direct commands ("run npm install")
- Conversational responses ("hello", "thanks")
- File operations without reasoning
- Already-optimized prompts
Learning Loop (Post-Response)
After completing ANY significant task:
1. ASSESS: Did the response achieve the goal?
2. CALL: mcp__prompt-learning__record_feedback
- prompt_id: [from optimization response]
- success: [true/false]
- quality_score: [0.0-1.0]
3. This enables future retrievals to learn from outcomes
Quick Reference
Iteration Decision
| Factor |
Low (3-5) |
Medium (5-10) |
High (10-20) |
| Complexity |
Simple |
Multi-step |
Agent/pipeline |
| Ambiguity |
Clear |
Some |
Underspecified |
| Domain |
Known |
Moderate |
Novel |
| Stakes |
Low |
Moderate |
Critical |
Convergence (When to Stop)
- Improvement < 1% for 3 iterations
- User satisfied
- Token budget exhausted
- 20 iterations reached
- Validation score > 0.95
Performance Expectations
| Scenario |
Improvement |
Iterations |
| Simple task |
10-20% |
3-5 |
| Complex reasoning |
20-40% |
10-15 |
| Agent/pipeline |
30-50% |
15-20 |
| With history |
+10-15% bonus |
Varies |
Anti-Patterns
Over-Optimization
| What it looks like |
Why it's wrong |
| Prompt becomes overly complex with many constraints |
Causes brittleness, model confusion, token waste |
| Instead: Apply Occam's Razor - simplest sufficient prompt wins |
|
Template Obsession
| What it looks like |
Why it's wrong |
| Focusing on templates rather than task understanding |
Templates don't generalize; understanding does |
| Instead: Focus on WHAT the task requires, not HOW to format it |
|
Iteration Without Measurement
| What it looks like |
Why it's wrong |
| Multiple rewrites without tracking improvements |
Can't know if changes help without metrics |
| Instead: Always define success criteria before optimizing |
|
Ignoring Model Capabilities
| What it looks like |
Why it's wrong |
| Assumes model can't do things it can |
Over-scaffolding wastes tokens |
| Instead: Test capabilities before heavy prompting |
|
Reference Files
Load for detailed implementations:
| File |
Contents |
references/optimization-techniques.md |
APE, OPRO, CoT, instruction rewriting, constraint engineering |
references/learning-architecture.md |
Warm start, embedding retrieval, MCP setup, drift detection |
references/iteration-strategy.md |
Decision matrices, complexity scoring, convergence algorithms |
Goal: Simplest prompt that achieves the outcome reliably. Optimize for clarity, specificity, and measurable improvement.
1---2name: automatic-stateful-prompt-improver3description: Automatically intercepts and optimizes prompts using the prompt-learning MCP server. Learns from performance over time via embedding-indexed history. Uses APE, OPRO, DSPy patterns. Activate on "optimize prompt", "improve this prompt", "prompt engineering", or ANY complex task request. Requires prompt-learning MCP server. NOT for simple questions (just answer them), NOT for direct commands (just execute them), NOT for conversational responses (no optimization needed).4---5
6# Automatic Stateful Prompt Improver
7
8## MANDATORY AUTOMATIC BEHAVIOR
9
10**When this skill is active, I MUST follow these rules:**
11
12### Auto-Optimization Triggers
13
14I AUTOMATICALLY call `mcp__prompt-learning__optimize_prompt` BEFORE responding when:
15
161. **Complex task** (multi-step, requires reasoning)
172. **Technical output** (code, analysis, structured data)
183. **Reusable content** (system prompts, templates, instructions)
194. **Explicit request** ("improve", "better", "optimize")
205. **Ambiguous requirements** (underspecified, multiple interpretations)
216. **Precision-critical** (code, legal, medical, financial)
22
23### Auto-Optimization Process
24
25```
261. INTERCEPT the user's request
272. CALL: mcp__prompt-learning__optimize_prompt
28 - prompt: [user's original request]
29 - domain: [inferred domain]
30 - max_iterations: [3-20 based on complexity]
313. RECEIVE: optimized prompt + improvement details
324. INFORM user briefly: "I've refined your request for [reason]"
335. PROCEED with the OPTIMIZED version
34```
35
36### Do NOT Optimize
37
38- Simple questions ("what is X?")
39- Direct commands ("run npm install")
40- Conversational responses ("hello", "thanks")
41- File operations without reasoning
42- Already-optimized prompts
43
44## Learning Loop (Post-Response)
45
46After completing ANY significant task:
47
48```
491. ASSESS: Did the response achieve the goal?
502. CALL: mcp__prompt-learning__record_feedback
51 - prompt_id: [from optimization response]
52 - success: [true/false]
53 - quality_score: [0.0-1.0]
543. This enables future retrievals to learn from outcomes
55```
56
57## Quick Reference
58
59### Iteration Decision
60
61| Factor | Low (3-5) | Medium (5-10) | High (10-20) |
62|--------|-----------|---------------|--------------|
63| Complexity | Simple | Multi-step | Agent/pipeline |
64| Ambiguity | Clear | Some | Underspecified |
65| Domain | Known | Moderate | Novel |
66| Stakes | Low | Moderate | Critical |
67
68### Convergence (When to Stop)
69
70- Improvement < 1% for 3 iterations
71- User satisfied
72- Token budget exhausted
73- 20 iterations reached
74- Validation score > 0.95
75
76### Performance Expectations
77
78| Scenario | Improvement | Iterations |
79|----------|-------------|------------|
80| Simple task | 10-20% | 3-5 |
81| Complex reasoning | 20-40% | 10-15 |
82| Agent/pipeline | 30-50% | 15-20 |
83| With history | +10-15% bonus | Varies |
84
85## Anti-Patterns
86
87### Over-Optimization
88
89| What it looks like | Why it's wrong |
90|--------------------|----------------|
91| Prompt becomes overly complex with many constraints | Causes brittleness, model confusion, token waste |
92| **Instead**: Apply Occam's Razor - simplest sufficient prompt wins |
93
94### Template Obsession
95
96| What it looks like | Why it's wrong |
97|--------------------|----------------|
98| Focusing on templates rather than task understanding | Templates don't generalize; understanding does |
99| **Instead**: Focus on WHAT the task requires, not HOW to format it |
100
101### Iteration Without Measurement
102
103| What it looks like | Why it's wrong |
104|--------------------|----------------|
105| Multiple rewrites without tracking improvements | Can't know if changes help without metrics |
106| **Instead**: Always define success criteria before optimizing |
107
108### Ignoring Model Capabilities
109
110| What it looks like | Why it's wrong |
111|--------------------|----------------|
112| Assumes model can't do things it can | Over-scaffolding wastes tokens |
113| **Instead**: Test capabilities before heavy prompting |
114
115## Reference Files
116
117Load for detailed implementations:
118
119| File | Contents |
120|------|----------|
121| `references/optimization-techniques.md` | APE, OPRO, CoT, instruction rewriting, constraint engineering |
122| `references/learning-architecture.md` | Warm start, embedding retrieval, MCP setup, drift detection |
123| `references/iteration-strategy.md` | Decision matrices, complexity scoring, convergence algorithms |
124
125---
126
127**Goal**: Simplest prompt that achieves the outcome reliably. Optimize for clarity, specificity, and measurable improvement.