From agent-patterns
Design and run a self-improving evaluator/optimizer loop. Use this skill when asked to "set up an eval loop", "build an optimizer", "improve this output iteratively", or "create a generate-evaluate-improve cycle" for any agent output.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agent-patterns:agent-loopThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Design and execute a **generate -> evaluate -> improve -> repeat** loop that
Design and execute a generate -> evaluate -> improve -> repeat loop that iteratively refines an agent output until a quality threshold is met.
[Generator] --> output --> [Evaluator] --> score + feedback
|
score >= threshold? --> YES --> done
|
NO
|
[Optimizer] --> improved prompt
|
[Generator] --> new output
Before starting the loop, specify:
/agent-review criteria)Define the initial generation prompt:
System: <system prompt for the generator>
User: <task description>
The generator should produce a single, structured output per run. Avoid generating lists of alternatives -- the evaluator handles iteration.
The evaluator scores the generator's output and produces structured feedback:
{
"score": 3.5,
"passed": false,
"issues": [
"Issue description 1",
"Issue description 2"
],
"suggestions": [
"Specific improvement 1",
"Specific improvement 2"
]
}
The evaluator must be deterministic about scoring criteria -- define them explicitly before starting the loop.
The optimizer receives the current prompt and evaluator feedback, and produces an improved prompt for the next generator run:
Previous prompt: <current generator prompt>
Evaluator score: <score>
Issues found: <list of issues>
Suggestions: <list of suggestions>
Produce an improved generator prompt that addresses these issues.
Execute iterations until the threshold is met or max iterations reached:
Iteration 1:
Generator output: <output>
Evaluator score: <score> / 5.0
Passed threshold: Yes/No
Issues: <issues if any>
Iteration 2 (if needed):
Improved prompt: <what changed>
Generator output: <new output>
Evaluator score: <new score>
Passed threshold: Yes/No
Final result: <the output that passed, or the best output if max iterations reached>
After the loop completes, provide:
npx claudepluginhub ats-kinoshita-iso/agent-workshop --plugin agent-patternsRuns autonomous optimization loops to iteratively improve prompts, templates, configs, or code using four-way separation of main agent, eval agent, test runner, and deterministic eval.py judge. Invoke via /autoresearch or 'optimize this prompt'.
Improves existing AI agents through performance analysis, failure mode classification, prompt engineering, baseline metrics, and iterative testing workflows.
Guides iterative improvement loops with scored auditing and substrate-gated termination. Generic fallback for ad-hoc quality improvement when no domain workflow applies.