/experiment-loop:experiment-loopfrom experiment-loop
Runs a bounded, unattended optimize-and-measure loop on a dedicated git branch, one hypothesis per commit, with a fixed metric command, keep-or-revert decisions and a results log. Use when the user wants many experiments against a measurable goal such as benchmark time, bundle size, memory or test pass rate.
Ships in experiment-loop. 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.
Iterate on a measurable goal without supervision: change one thing, measure, keep the change only if the metric improves, and log everything. The loop runs autonomously inside a scope, a budget, and a boundary that the user confirmed up front. The user keeps the last switch, so the loop ends with a branch and a report and never merges or ships.
Not for a single optimization (coding, problem-solving), planning the surrounding work (planning), pure polling or scheduling (the /loop and /schedule built-ins), or goals with no command that measures them.
Build a loop only when all four hold. If one fails, do the work by hand or fix the gap first.
Settle these with the user before any experiment, then show them back as a table and wait for a yes. Autonomy starts only after that confirmation, because a loop can't ask mid-run and will carry a wrong assumption to the end.
| Item | What to pin down |
|---|---|
| Goal and metric | The exact command, how to extract one number from its output, and whether lower or higher is better |
| Scope | Files and directories the loop may edit, and files that are off limits |
| Boundary | What must not happen, such as tests staying green, none deleted or weakened, the public API unchanged, no new dependencies |
| Budget | Maximum experiments, a time limit per run, and any spend cap |
| Retry cap | How many failed fixes an experiment gets before it is abandoned (default 2) |
| Simplicity | Whether a small gain is worth added complexity (default no) |
Check that the goal is machine-decidable: someone who doesn't know the project can run one command and tell whether an experiment helped. "Make it faster" fails this test, and "p95 of bench.sh under 120 ms with make test green" passes. A done-criterion alone invites gaming, such as deleting the tests that fail, so always pair it with the boundary.
Keep the judge outside the loop's reach. The metric command, benchmark inputs, and acceptance tests sit outside the editable scope, so an experiment can't improve the number by changing how it is measured. Prefer a metric anchored to an external reference over one the code asserts about itself.
git worktree add ../<repo>-experiment -b experiment/<tag>, then work there). The loop's commits and reverts must never mix with the user's work.git switch -c experiment/<tag>, for example with today's date), unless the worktree above already made one. All experiments happen there.results.tsv and run.log in the repo root and add both names to the file at "$(git rev-parse --git-path info/exclude)" (in a linked worktree .git is a file, so don't hardcode the path), which keeps them untracked without touching a tracked file. Header for the log: experiment, commit, metric, status, description, separated by tabs.baseline. For a noisy metric, run it several times and note the spread. A later gain only counts when it exceeds that noise.For each experiment:
pre=$(git rev-parse HEAD).experiment: <what changed>) before measuring, so every attempt is a recoverable unit.run.log, which keeps long output out of the context. Kill a run that exceeds twice its expected time and treat it as a crash.run.log for the error.git revert --no-edit "$pre"..HEAD, which reverts only this experiment's commits. A revert adds a commit instead of discarding history, so it can't destroy anything the loop didn't create.results.tsv, then go back to step 1.Don't run git reset --hard, force-push, or rewrite history in this loop. Reverts keep the full record and can only undo commits the loop made.
The loop doesn't pause to ask whether to continue. It does stop and ask when something falls outside what the user confirmed: editing an out-of-scope file, adding a dependency, changing the environment, a goal that turns out to be ambiguous, or any write to shared state such as pushing, publishing, or opening a pull request. A wrong answer here costs more than a pause.
When the budget runs out, the user interrupts, or ideas are exhausted, print the results table and summarize the number of experiments (kept, discarded, crashed), baseline against final metric with the percentage change, and the few changes that mattered most. Show git diff --stat <start>..HEAD and the keep rows from results.tsv for the kept work (the log also holds reverts), and suggest what a person might try next, including ideas that were too risky to run unattended. Leave merging to the user.
Read references/loop-design.md when the loop will run on a schedule or without anyone watching, or when reviewing a loop someone else wrote.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin experiment-loop