Prompt Optimizer
Optimize prompts with evals. Keep every instruction, example, and external context reference causal.
Load Only What You Need
| Need |
Read |
| New prompt |
references/core-patterns.md, references/model-family-notes.md, references/transformed-examples.md |
| Existing prompt |
references/meta-optimization-loop.md, references/core-patterns.md, references/model-family-notes.md |
| Model-family port |
references/model-family-notes.md, references/core-patterns.md |
| Repeated failures |
references/meta-optimization-loop.md, references/core-patterns.md |
| Weak or ambiguous draft |
references/transformed-examples.md |
| Provenance |
SOURCES.md |
Step 1: Capture Contract
Record before editing:
- task type: new, refine, port, or debug
- target model family and snapshot, if known
- prompt surface:
system, developer, user, tool descriptions, examples, schemas
- layer owners: platform, deployer/persona, retrieved context, user payload
- objective and non-goals
- inputs, tools, and external files available
- required output shape
- success criteria and failure cases
- hard constraints: latency, verbosity, safety, budget, tool use, style
If success criteria or examples are missing, create a small eval set first.
If the bottleneck is model choice, retrieval, tool schema, or missing evals, say so before rewriting.
Step 2: Inventory External Context
For repo or agent prompts, list stable context by exact path:
| Context type |
Examples |
| Agent rules |
AGENTS.md, CLAUDE.md |
| Specs |
specs/*.md, docs/api.md |
| Policies |
SECURITY.md, docs/releasing.md |
| Examples |
examples/, tests/fixtures/ |
Rules:
- Reference stable files by repo-relative path instead of copying them.
- Paste only excerpts needed for the prompt or eval case.
- Mark whether a file is
loaded, referenced, or out of scope.
- Avoid vague context pointers such as "read the docs".
Step 3: Choose Model Strategy
Read references/model-family-notes.md.
- Known family: optimize for that family.
- Unknown family: write a portable base plus short adapter notes.
- Snapshot changes: rerun evals.
- Cross-family divergence: specialize only the failing layer.
Step 4: Shape Prompt
Read references/core-patterns.md.
- Put stable policy in
system or developer.
- Put task-local facts, retrieved context, and variables in user-facing sections.
- Keep one owner per behavior rule.
- Use headings or tags only to separate content types.
- Put tool policy in prompt text; keep schemas in provider-native tools.
- Keep persona light unless it changes behavior.
- Use the shortest wording that preserves the constraint.
- Cut filler, repeated reminders, dead examples, and rationale that does not affect evals.
Step 5: Optimize
Read references/meta-optimization-loop.md for refinements.
- Baseline the current prompt on the same eval slice.
- Cluster failures by root cause.
- Write concrete edit criticisms.
- Generate two to four candidates:
- minimal-diff repair
- structure-first rewrite
- examples-first or tool-rule variant
- provider adapter when needed
- Compare candidates on the same cases.
- Keep a short optimization log.
- Validate the winner on holdout cases.
- Stop on plateau, oscillation, overfit, excessive cost, or non-prompt bottleneck.
Step 6: Return Package
Return:
Target
Success Criteria
External Context
Optimized Prompt
Adapter Notes
Eval Set
Optimization Log
Residual Risks
For existing prompts, include a concise diff-style note of the main behavioral changes.
Failure Modes
- editing before defining the eval target
- mixing policy, examples, and raw context without boundaries
- duplicating rules across layers
- putting durable policy in user payloads
- asking for chain-of-thought
- keeping contradictory legacy instructions
- overfitting to one or two examples
- retaining examples that no longer improve evals
- fixing tool-use failures only in prompt text when tool descriptions or schemas are weak
- adding markup that does not reduce ambiguity
- using persona as a substitute for behavior rules
1---2name: prompt-optimizer3description: Creates, optimizes, and iteratively refines agent prompts, system prompts, developer prompts, and reusable prompt templates. Use when asked to improve a prompt, optimize a system prompt, rewrite an agent prompt, tune prompt wording, make a prompt more reliable, port prompts between OpenAI, Claude, or Gemini, or build prompt evals. Scope boundary — this skill owns agent PROMPT authoring and optimization: the instruction text itself, its layering, its examples, and the evals that score it. Agent ARCHITECTURE and scaffolding belong elsewhere: generic "build/create/design/scaffold an agent" requests go to `build-agents`, and eve project structure, runtime, channels, and tooling go to `eve`. Do not claim a request just because it mentions an agent; claim it when the artifact under edit is a prompt.4---5# Prompt Optimizer67Optimize prompts with evals. Keep every instruction, example, and external context reference causal.89## Load Only What You Need1011| Need | Read |12|------|------|13| New prompt | `references/core-patterns.md`, `references/model-family-notes.md`, `references/transformed-examples.md` |14| Existing prompt | `references/meta-optimization-loop.md`, `references/core-patterns.md`, `references/model-family-notes.md` |15| Model-family port | `references/model-family-notes.md`, `references/core-patterns.md` |16| Repeated failures | `references/meta-optimization-loop.md`, `references/core-patterns.md` |17| Weak or ambiguous draft | `references/transformed-examples.md` |18| Provenance | `SOURCES.md` |1920## Step 1: Capture Contract2122Record before editing:2324- task type: new, refine, port, or debug25- target model family and snapshot, if known26- prompt surface: `system`, `developer`, `user`, tool descriptions, examples, schemas27- layer owners: platform, deployer/persona, retrieved context, user payload28- objective and non-goals29- inputs, tools, and external files available30- required output shape31- success criteria and failure cases32- hard constraints: latency, verbosity, safety, budget, tool use, style3334If success criteria or examples are missing, create a small eval set first.35If the bottleneck is model choice, retrieval, tool schema, or missing evals, say so before rewriting.3637## Step 2: Inventory External Context3839For repo or agent prompts, list stable context by exact path:4041| Context type | Examples |42|--------------|----------|43| Agent rules | `AGENTS.md`, `CLAUDE.md` |44| Specs | `specs/*.md`, `docs/api.md` |45| Policies | `SECURITY.md`, `docs/releasing.md` |46| Examples | `examples/`, `tests/fixtures/` |4748Rules:4950- Reference stable files by repo-relative path instead of copying them.51- Paste only excerpts needed for the prompt or eval case.52- Mark whether a file is `loaded`, `referenced`, or `out of scope`.53- Avoid vague context pointers such as "read the docs".5455## Step 3: Choose Model Strategy5657Read `references/model-family-notes.md`.5859- Known family: optimize for that family.60- Unknown family: write a portable base plus short adapter notes.61- Snapshot changes: rerun evals.62- Cross-family divergence: specialize only the failing layer.6364## Step 4: Shape Prompt6566Read `references/core-patterns.md`.6768- Put stable policy in `system` or `developer`.69- Put task-local facts, retrieved context, and variables in user-facing sections.70- Keep one owner per behavior rule.71- Use headings or tags only to separate content types.72- Put tool policy in prompt text; keep schemas in provider-native tools.73- Keep persona light unless it changes behavior.74- Use the shortest wording that preserves the constraint.75- Cut filler, repeated reminders, dead examples, and rationale that does not affect evals.7677## Step 5: Optimize7879Read `references/meta-optimization-loop.md` for refinements.80811. Baseline the current prompt on the same eval slice.822. Cluster failures by root cause.833. Write concrete edit criticisms.844. Generate two to four candidates:85 - minimal-diff repair86 - structure-first rewrite87 - examples-first or tool-rule variant88 - provider adapter when needed895. Compare candidates on the same cases.906. Keep a short optimization log.917. Validate the winner on holdout cases.928. Stop on plateau, oscillation, overfit, excessive cost, or non-prompt bottleneck.9394## Step 6: Return Package9596Return:97981. `Target`992. `Success Criteria`1003. `External Context`1014. `Optimized Prompt`1025. `Adapter Notes`1036. `Eval Set`1047. `Optimization Log`1058. `Residual Risks`106107For existing prompts, include a concise diff-style note of the main behavioral changes.108109## Failure Modes110111- editing before defining the eval target112- mixing policy, examples, and raw context without boundaries113- duplicating rules across layers114- putting durable policy in user payloads115- asking for chain-of-thought116- keeping contradictory legacy instructions117- overfitting to one or two examples118- retaining examples that no longer improve evals119- fixing tool-use failures only in prompt text when tool descriptions or schemas are weak120- adding markup that does not reduce ambiguity121- using persona as a substitute for behavior rules