| name | agentic-loop |
| description | Run a bounded change → verify → fix cycle until an objective check passes (tests green, lint clean, build/type-check ok) or a hard iteration cap is hit. Use for any task that needs repeated attempts against a verifiable signal instead of a single one-shot edit. |
| model | inherit |
| effort | medium |
| allowed-tools | ["Read","Edit","Bash","Grep","Glob"] |
| triggers | ["keep trying until","make the tests pass","fix until green","iterate on this","loop until"] |
| tags | ["loop","iterate","verify","tests","autonomous"] |
Agentic Loop
Drive work with a verifiable signal, not by eyeballing. Change, run the
check, read the failure, fix, repeat — bounded by a hard cap so it can never
spin forever.
When to use
Use this whenever there's an objective pass/fail signal to close on:
- Make failing tests pass.
- Get lint/format clean.
- Make the build or type-check succeed.
- Reach a coverage or benchmark threshold.
If there's no machine-checkable signal, don't loop — do the edit once and
ask the user to confirm.
The loop
Read the cap and verify command from ${CLAUDE_PLUGIN_ROOT}/config.json
(loop.max_iterations, default 5; loop.verify_command). If no command is
configured, infer the project's own (e.g. npm test, pytest, cargo test,
make check) and confirm it with the user before the first run.
iteration = 0
loop:
1. Run the verify command. Capture full output.
2. PASS → stop, report success (iterations used).
3. FAIL → read the error. Form ONE concrete hypothesis for the top failure.
4. Make the smallest change that addresses that hypothesis.
5. iteration += 1
6. iteration >= max_iterations → STOP. Report status + remaining failures.
else → loop.
Rules that keep it honest
- The check is the judge. A change isn't done because it looks right — it's
done because the command passes. Re-run every iteration; never trust a prior run.
- One hypothesis per iteration. Fix the top failure, not five things at once —
otherwise you can't tell what worked.
- Smallest change that could work. Big rewrites mid-loop hide regressions.
- Never weaken the check to pass it. Don't delete/skip tests, lower a
threshold, or
catch and swallow to force green. If the check itself is wrong,
stop and say so.
- No progress after 2 iterations on the same failure → stop and escalate
with what you tried and the current error. Don't burn the cap thrashing.
- Hard cap is absolute. At the cap, stop and report — success is not required
to end cleanly.
Routing (optional)
For a heavier loop, pair with model-router: plan the fix at the plan role,
apply it at execute/cheap. Keep the verify step deterministic (it's a
command, not a model call).
Report on exit
Always end with: pass or fail, iterations used out of the cap, the verify
command, and — if failed — the remaining errors and your best next step. If the
outcome is a standing fact ("test suite is pnpm test"), store it with
memory-keeper.