/agent-loops:prompt-optimizefrom agent-loops
Iteratively improves a user's prompt by making targeted edits, re-running their evaluation command, and keeping changes only when the metric improves. Use when you have a prompt and a way to score it.
Ships in agent-loops. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
An evolutionary optimizer for a prompt (OpenEvolve / AlphaEvolve-style). The artifact is a prompt that feeds the user's system; the feedback signal is a scalar metric printed by the user's own evaluation command. Each iteration proposes one quality-focused edit, re-runs the eval, and keeps the edit only if the metric improves — evolving the prompt toward higher scores. The eval is a black-box oracle the loop runs but never edits, so the optimization tracks what actually matters rather than gaming a number.
Use this when the user has a prompt and a command that scores the system using it, and wants the prompt improved to raise that score. Default to diagnosing the prompt's biggest current weakness each round and applying the one operator that addresses it; if the eval feedback points elsewhere, follow the feedback. Not for authoring a prompt from nothing, tuning weights/hyperparameters, or making a single manual edit with no score to compare against.
Resolve bindings interactively. If loop.run.yaml exists in the working dir, load it, confirm the
values in one line, and skip to the loop. Otherwise: on Claude Code (the AskUserQuestion tool is
available) infer a likely value for each binding and present it as the recommended option; on other
hosts ask each as a quoted plain-text prompt. Then write loop.run.yaml (format:
examples/run.example.yaml) and confirm the values before creating any other files.
| binding | meaning | default | how to infer |
|---|---|---|---|
<prompt_file> | the prompt to optimize — the artifact the loop evolves | — | scan the working dir for the prompt/template file the eval reads |
<eval_cmd> | required. Command that scores the current <prompt_file>; prints the metric (see output convention below). Treated as a black box — never edited | — | ask the user; look for eval/score/bench scripts |
<objective> | maximize or minimize, plus one line on what the metric measures | maximize | ask the user |
<target> | optional score at which to stop early | — | ask the user; else leave unbound |
<sandbox_root> | where prompt snapshots + ledger live | ./sandbox | — |
<budget> | max iterations | 10 | — |
<patience> | stop after N consecutive non-improving iterations (plateau) | 3 | — |
Eval output convention. <eval_cmd> must print, on its last line, either a JSON object
{"score": <number>, "feedback": "<optional notes/errors>", ...any extra metrics...} or a bare
number. Higher is better unless <objective> is minimize. The feedback field, when present, is
the richest signal — read it like AlphaEvolve's artifacts side-channel to decide the next edit.
Eval runs in the user's environment. <eval_cmd> may call an inference endpoint or any tooling the
user has installed; the loop just shells out and reads the last line. If instead the prompt is executed
by you (interactive development with no separate endpoint), first run the current prompt over the
user's eval inputs to produce outputs, write them where <eval_cmd> reads, then run <eval_cmd> to
score them.
Copy this checklist and tick items off:
<eval_cmd> on <prompt_file>, record its score as the current best, snapshot the prompt.<prompt_file>.<eval_cmd> and read the new score from its last line.<target>, plateau (<patience>), or <budget>.Iteration 0 — baseline. Run <eval_cmd>, record its score as the best, snapshot <prompt_file>
to <sandbox_root>/iter0/, and start the history ({iter, edit, score, feedback} per row).
Then, until stop (target, plateau, or budget):
Diagnose. From the latest score, the <eval_cmd> feedback, and recent history, name the
prompt's single biggest current weakness — the one thing most likely holding the metric back.
Make one targeted edit — pick the toolkit operator that addresses that weakness:
One change per iteration, so its effect on the metric is attributable.
Measure. Snapshot the edited prompt to <sandbox_root>/iter<N>/, run <eval_cmd>, and read the
new score off the last line.
Keep or revert. Keep if the metric improves per <objective> (if the eval is stochastic,
require a small margin so noise alone does not drive a keep); otherwise revert <prompt_file>
to the previous best snapshot. Append {edit, score, feedback} to the history either way.
Escape local optima. If the score has not improved for a couple of iterations, stop making tiny tweaks — branch from an earlier high-scoring snapshot, or try a bolder restructuring (a different decomposition, a fresh set of examples). Diversity beats grinding the same local hill.
When stopping, restore the best prompt to <prompt_file> and report the score trajectory, which
edits moved the metric (and which did not), and the final prompt.
<sandbox_root>/ledger.tsv, tab-separated, never commas in the text. Header:
iter score status edit
status ∈ {baseline, keep, revert}. Example (metric = task accuracy, maximize):
iter score status edit
0 0.42 baseline original prompt
1 0.61 keep specificity: define each output label and the exact output format
2 0.61 revert examples: add 3 few-shot demos — no metric gain
3 0.78 keep context: add the domain rules the task assumes but never states
Report the best iteration, not necessarily the last.
<eval_cmd>, its data, or its scoring — that games the
number instead of improving the prompt, and the eval is the only ground truth the loop has.<eval_cmd>, not a single
sample, so each score delta is attributable to that one edit.../ escapes.<target> (if set).<patience> consecutive rounds (every non-improving
iteration counts toward patience; a keep resets it).<budget> iterations reached.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gaasher/agent-loop-skills --plugin agent-loops25 skills in this plugin
/alpha-evolveUse when the user wants to evolve an ML model/program through population-based search rather than a single sequential refine loop — a generational evolution where parallel proposers each apply one small SEARCH/REPLACE diff to a parent, scored by a cascade-evaluated training run, and children are kept in a MAP-Elites archive across islands (with migration + checkpointing) so diverse high performers survive. A finite, bounded-parallelism re-creation of AlphaEvolve/OpenEvolve, bent for ML autoresearch. Runs to a fixed compute budget or until interrupted. Not for the sequential single-thread autoresearch loops (one change → measure → keep/revert), and not for verifying a known bug or external claim — this is parallel, diversity-preserving search over a program.
/anomaly-investigationUse when the user has a known, already-observed anomaly in their data — a metric spike or drop, an outlier, an unexpected number — and wants its root cause diagnosed, not guessed. Forms a slate of candidate causes, tests each against the data, and eliminates the ones the data refutes, narrowing the live candidates until exactly one survives refutation and passes a positive confirming test. The result is an investigation log with the confirmed root cause and the evidence that ruled out the alternatives. Not for open-ended discovery over a dataset with no specific anomaly in hand (that is data-analysis), and not for checking an external claim against sources (that is claim-verify) — this is reactive diagnosis of one anomaly you already know about.
/blue-teamUse when the user has concrete failing cases in code or a guardrail/classifier/filter/prompt/API they own — a red-team failure catalogue OR a CI/CD test-failure report (failing pytest/JUnit tests) — and wants the target patched until those failures are closed without breaking what already works. It points straight at the failed cases (normalize any source with tools/ingest.py), fixes one root-cause class per iteration, and re-checks with tools/verify.py — oracle mode against a red-team oracle, or tests mode against the test suite — keeping a patch only if it closes a class while nothing that passed before regresses, else reverting; loops until every class is closed (dry) or the budget runs out, then opens a pull request with the patch set. The defensive fixer half of a find→fix setup. Not for discovering new failures (that is red-team), and not for editing the oracle, tests, or holdout that define ground truth.
/claim-verifyUse when the user has a results draft or a set of data-backed claims and wants each one adversarially verified against the underlying dataset before publishing — a pre-publication red-team of the findings. Extracts the discrete checkable claims from the draft, reproduces each claim's number against the data, stress-tests it against the threats most likely to kill it (outliers, confounds, Simpson's reversals, tiny subgroups, alternative specifications), and marks it verified, fragile, or refuted; fragile and refuted claims are revised — hedged, scoped, or retracted — until every claim is verified or appropriately qualified. The result is a draft where every surviving claim has been reproduced and survived a stress test. Not for open-ended discovery of new findings over a dataset (that is a data-analysis task), and not for diagnosing a single known anomaly or pipeline failure — this is a gate over an existing draft.
/data-analysisUse when the user wants an iterative, self-checking exploratory analysis of a dataset — surfacing findings that are each verified by re-running the computation, not asserted. Proposes one specific hypothesis at a time, writes and runs analysis code to test it, and records the finding only if the numbers support it at a meaningful effect size; loops until no new verified finding appears or the budget is hit. The result is a findings report where every claim is backed by a reproducible number. Not for diagnosing a single known anomaly or pipeline failure, and not for verifying an external claim against sources (that is a claim-verification task) — this is open-ended discovery over a bound dataset.
/dueling-autoresearchUse when the user wants two approaches raced head-to-head on a single shared metric — e.g. a classical/algorithmic lane vs an ML/learned lane, or any two strategies for the same task. Each lane runs its own analysis-first research loop confined to its lane, the lanes share a scoreboard and may borrow ideas across the boundary without abandoning their identity, and a shared eval keeps the head-to-head honest; loops until interrupted, reporting the current leader. Not for improving a single approach in isolation (use a single-track research loop), and not for picking between two finished artifacts in one shot (that is a one-time comparison).
Other plugins' skills for the same job