/tune-agent — Reflexion patch for an agent's prompt
/tune-agent <name> spawns the agent-tuner agent with collected evidence and proposes a focused patch to that agent's .md file.
When to invoke
/mine-transcriptsproducedagent-tuning.mdlisting agents with ≥2 failures/evalshows a regression for a specific agent vs prior runs- Verifier or critic flagged the same failure pattern from the same agent twice in this session
- The user says "this agent keeps doing X — fix it"
What you do
Resolve the agent.
~/.claude/agents/<name>.mdmust exist. If not, stop.Collect evidence. Pull from:
- Most recent
~/.claude/telemetry/mining-runs/*/agent-tuning.md(if applicable) - Verifier/critic outputs in this session that mention the agent
- Any context the user just provided
Need ≥2 pieces. If you have only 1, tell the user — wait for more before tuning.
- Most recent
Spawn agent-tuner. Use the
Agenttool withsubagent_type: agent-tuner. Pass the evidence as a structured prompt:Agent to tune: <name> Evidence: 1. <task summary> — <what went wrong> — session=<id> 2. <task summary> — <what went wrong> — session=<id> 3. <task summary> — <what went wrong> — session=<id> Desired behavior: <if user specified, otherwise infer>Read the tuner's output. It ends with one of:
RESULT_agent-tuner=PATCHED— surface the diff and rationale to the user; ask "apply or revert?"RESULT_agent-tuner=INSUFFICIENT_EVIDENCE— tell user, suggest waitingRESULT_agent-tuner=AMBIGUOUS— surface options to userRESULT_agent-tuner=NO_PATCH_NEEDED— evidence didn't add up; explain
Apply or revert.
- On user approval: leave the change in place (the tuner already wrote it).
- On rejection:
cp ~/.claude/agents/.history/<name>-<ISO>.md ~/.claude/agents/<name>.mdto restore. - Either way, log to
~/.claude/agents/.history/CHANGELOG.md(the tuner already did this).
Re-eval. After applying, run
/eval <name>to confirm the patch doesn't regress other behaviors.
Cost note
The tuner runs on Opus (precise prompt engineering matters). One invocation is typically <$0.50. If you find yourself tuning the same agent more than weekly, the agent's design is wrong — propose a redesign, not another patch.
Anti-patterns to refuse
- Tuning on a single occurrence (refuse — collect more evidence first)
- Tuning based on user vibes rather than logged failures
- Tuning multiple agents in one shot — each
/tune-agentis one agent - Skipping the post-patch
/eval— you must verify the patch doesn't regress