/skill-madness:loop-controllerfrom skill-madness
Provides a verifiable stop condition and mandatory guardrails (iteration cap, budget enforcement, no-progress detection) for autonomous loops. Use when work must continue until something is provably true, or to author a new loop.
Ships in skill-madness. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Why this is a deliberate (
disable-model-invocation) skill. A loop edits, commits, and spends tokens on its own. You want to type/loop-controller(or have the orchestrator dispatch it), not have Claude silently start an autonomous loop because a test happened to fail. The discipline below is what makes that safe.
A loop is only as good as its stopping condition. Loops converge when "done" is an external signal the agent cannot argue with — a test exit code, a coverage percentage, an empty queue, a fresh evaluator's verdict. They diverge — oscillate, thrash, or run the budget to zero — when "done" is a subjective judgment the agent grades itself on. Agents are pathological optimists about their own work; left to self-assess, they declare victory early.
There is a subtler failure an objective proof does not cure: a signal that is mechanical, default-FAIL, and un-gameable can still measure the wrong thing. A test suite green against a mock, a stub, or a fixture is all three of those — and proves nothing about whether the real product works. That is convergence on a fiction, and because it wears the costume of rigor (an exit code! a number!) it slips past review more easily than a subjective claim would. 65 green tests against a mocked backend look exactly like 65 green tests against the real one. So the proof must measure the real goal, not a stand-in for it (Step 2) — un-gameable and pointed at the thing that actually matters.
So the entire job of this skill is to turn a fuzzy "keep working on X" into a convergent loop: a mechanical proof of the real goal, the right execution primitive, and a guardrail stack that stops the loop whether or not the proof is ever met.
Everything else here — fix-until-green, coverage-loop, perf-loop — is a config of this harness: a specific proof plugged into the same machinery. Author new loops against this skill; don't reinvent the loop engine.
Twelve configs of this harness already ship in skills/loops/. Route the intent
to one of them before authoring anything — Steps 0–6 below are for the loop that
doesn't exist yet. (Every one of these is disable-model-invocation: true:
dispatch it by its slash command, or let the orchestrator dispatch the build
loops. None auto-fires.)
| The intent is… | Dispatch |
|---|---|
| "make tests / lint / typecheck pass", red CI, "run until green" | fix-until-green |
| Drain a multi-agent build's shared task list until every task passes its gate (Agent Teams) | orchestrator-task-loop |
| Build until an authored contract's criteria all hold (build-until-spec) | contract-conformance-loop |
| "Keep my PR green / rebased / answer review comments while I'm away" | babysit |
| "Raise test coverage to N%" | coverage-loop |
| "Get this metric under its budget" (latency, bundle size, memory) | perf-loop |
| "Watch the logs / CI and fix what breaks" | self-healing-loop |
| "Migrate / transform every file in this enumerated set" | migration-loop |
| "Keep the docs + changelog from rotting" (nightly) | nightly-docs-and-changelog |
| "Keep dependencies current and audited" | dependency-health-loop |
| "Map this unfamiliar codebase until my questions are answered" | codebase-exploration-loop |
| "Weekly repo hygiene — stale branches, PRs, worktrees" | repo-cleanup-loop |
No row fits → continue below and author the new loop against this harness.
A loop has real setup cost and its own failure modes; the mistake is looping things that don't earn one. Before building anything, put the task through four questions — a "no" on any of them is a strong signal to just do the work manually (or once) instead:
Pass all four and the 5-part contract below will fill in cleanly. Fail one and the honest move is to not build the loop.
Before running anything, write the loop's contract. A loop that can't fill in all five lines isn't ready — the blank is the bug.
| Part | Question it answers | Example |
|---|---|---|
| trigger | What starts this loop? | "red CI on branch X" / "every 30m" / "user runs /fix-until-green" |
| action | What does one iteration do? | "run the gate, fix one root-cause failure, re-run the whole gate" |
| proof | What mechanical signal proves done? | "npm test exits 0 and lint exits 0 and typecheck exits 0" |
| memory | What state survives between iterations? | "PROGRESS.md, the feature-list JSON, git history" |
| stop | Every way this loop ends | "proof passes OR 20 iterations OR no-progress for 3 rounds OR budget cap" |
The proof and stop lines are load-bearing. Keep this contract in the loop
skill's body (or at the top of the run) so any reviewer can audit convergence at
a glance. This is the Forward Future "loop library" 5-part schema, adopted as the
required contract. The taxonomy of common loop shapes (fix-until-green,
build-until-spec, refine-until-quality, research, review, migration, coverage,
perf, self-healing, exploration) lives in references/authoring.md.
The first decision is which engine runs the loop. Get this wrong and you burn money: a scheduler pointed at finishable work re-runs blindly on the clock; a "work until done" wrapper pointed at an external poll spins forever.
The decision rule: Are you pushing work to a finish line, or watching for something to change?
| If the job is… | Use | Because |
|---|---|---|
| Push to a finish line, proof is provable from Claude's own output (test exits 0, git clean) | /goal | A small fast model judges the transcript each turn; "no" feeds the reason back. The closest native "loop until done." |
| Push to a finish line, proof needs a script/file/tool check the model can't just assert | Stop-hook gate | A hook runs the real check and blocks exit until it passes — ships with the skill. |
| Watch / poll for an external change on a cadence | /loop | A thin scheduler that re-runs a prompt or slash command on an interval; it does not push to a finish line. |
| One big mechanical change across many files in parallel | /batch / dynamic workflow | Fans out across worktree-isolated subagents; compose with the orchestrator's Workflow mode. |
| Greenfield, want a fresh context window every iteration | claude -p bash loop (Ralph) | State lives on disk; each pass starts clean. Needs a sandbox (--dangerously-skip-permissions). |
Do not conflate /goal (finish line) with /loop (watch). They are different
primitives with different failure modes. Full mechanics, constraints, and the
exact invocations for each — including /goal's evaluator-can't-read-files
limit and /loop's session-scope/expiry/no-catch-up rules — are in
references/primitives.md. Read it before authoring.
Hosts without these primitives (Gemini CLI, Codex, Cursor, OpenCode, a bare
API agent): the table above is Claude Code-native — do not pretend /goal,
/loop or a Stop hook exist. Two routes remain. In-session: state the
proof command and iteration cap up front, get the owner's one approval (or use
the plan the orchestrator already had approved), then iterate in the live host
session without further prompts, running every guardrail in Step 3 yourself;
stop at the cap or on HITL triggers (Step 3, guardrail 4). Unattended: only through scripts/run_guarded.py around an
owner-approved bounded adapter for the host's non-interactive CLI — one whose
per-call token/cost ceiling is known — with declared call/token/cost/wall-time
limits (see Executable external controller below). With neither, refuse
unattended work rather than looping on prompt discipline alone.
A convergent loop needs a proof signal the agent cannot rationalize past.
test/auth pass and lint is
clean," not "the auth code looks correct." If the proof is a number, name the
artifact that produces it (coverage report, benchmark output, the gate's exit
code).false and only flips on evidence.
Store the criteria as JSON, not prose — a model is far less likely to quietly
rewrite a JSON "passed": false than to soften a sentence. (Anthropic's
long-running-agent harness stores the feature list as JSON for exactly this
reason.)references/authoring.md.Every loop ships with all of these. They are not optional polish — a documented multi-agent loop ran 11 days and burned tens of thousands of dollars because it had observability but no enforcement. Alerting is not a guardrail; termination is.
--max-iterations (or "stop after N turns" baked
into the /goal condition — /goal has no native cap). This is the primary
backstop when the proof is never met./goal has no built-in budget — embed an explicit turn
cap and abort condition; watching /cost in prompt prose is advisory only, not
hard cancellation. Unattended or bash/Ralph execution requires an external
process wrapper enforcing max calls, wall-clock timeout, token budget, and
process locks with SIGTERM/SIGKILL cancellation. Unattended runs must
produce a durable proof artifact and run within external budget ceilings. A
50-iteration run on a large codebase can cost $50–100+. The number that
actually tells you whether the loop is worth running is cost per accepted
result, not tokens spent or iterations run: a loop that opens five PRs where
you merge one, or emits a daily report no one reads, can cost more than doing
the work by hand. Track yield, not spend — a low accept rate means the loop is
manufacturing review debt, and the fix is a tighter proof (Step 2), not a
bigger budget.The full stack — including the stop_hook_active guard for Stop-hook loops, the
oscillation thresholds, and the staged-adoption / rollback ladder — is in
references/safety.md.
Use scripts/run_guarded.py from the actual SKILL_ROOT for POSIX bounded
adapters. It reserves worst-case call/token/cost liability before dispatch,
checks a frozen verifier manifest before/during/after commands, uses an exclusive
lock, and cancels the whole process group at the wall-time ceiling. Failed calls
keep their reservations; consumed state cannot be restarted with reset counters.
Read references/safety.md for the budget/manifest interface and proof boundary.
A command with unknown internal calls or cost is BLOCKED: this wrapper is not a
provider traffic meter. Native primitives without a verified hard-bound adapter
still refuse unattended use. Completion of bounded dispatches is not task/QE acceptance.
A loop that remembers across iterations only through the conversation breaks the moment context compacts or a fresh-context pass starts. Externalize to path-addressable files:
PROGRESS.md / claude-progress.txt) — what's done, what's next;fix_plan.md) — rewritten freely each pass;init.sh — how to build and run;Each iteration starts by reading these, does one increment, then updates
them and commits. Read the caps (max-iterations, budget) and the state-file
paths from .claude/profile.yaml when present, so the same loop skill works
across projects without hard-coding. (This is the orchestrator/role-skill
convention; loops follow it.)
Steps 1–5 make the loop converge. This step keeps the model's behavior honest over
a long run on the Claude 5 family, where a single turn can run for
minutes and an autonomous run for hours. These are prompt-level additions to the loop's
brief — the harness enforces convergence; these keep the agent from lying, quitting early,
or panicking about context on the way there. Drop-in instruction text and the 5-part
mapping for each are in model-adaptation/references/long-run-hygiene.md; wire what the
loop needs:
/goal + Stop-hooks catch this
mechanically (Step 1); add the prompt-level last-paragraph self-check and, for unattended
runs, the autonomous-operation reminder so the agent doesn't lean on the hook.high
default, xhigh for the hardest proof/verify steps, medium/low for routine passes.
Set it explicitly per iteration rather than relying on the API default.
Lower effort on the Claude 5 family often beats xhigh on prior models — reduce it if a
loop converges but each iteration runs longer than the work needs. Model tiers the same
way — pick both per model-adaptation's Model & effort tiering policy: workers and
routine passes tier down, but the fresh-context evaluator (Step 2) stays on the top tier.send_to_user tool plus the elicitation
line, declared from the loop's first request (changing the tool list mid-run invalidates
the prompt cache) — never route the model's reasoning through it (that's the reasoning_extraction
refusal landmine; see model-adaptation).The fresh-context evaluator (Step 2) is itself one of these patterns — the guide's "fresh verifiers beat self-critique" — so it's already wired; just run it periodically on a long build, not only at the end.
Steps 1–6 keep the machine honest. There is one failure they don't catch, because it lands on the human, not the loop: a loop that ships correct, green diffs faster than anyone reads them. Each merge feels like progress, but the codebase starts moving faster than the team's understanding of it — the tests pass, yet nobody can say why the code is shaped the way it is. That's comprehension debt, and it's the antidote's mirror image of convergence-on-a- fiction: there the proof was too weak, here the proof was fine but human understanding silently fell behind. The bill arrives at the next bug, in a module no one can reason about.
The guardrails don't fix this because it isn't a convergence problem — it's a
review problem. Keep it in check by keeping loops on small, readable diffs,
having a human actually read the diff a red→green flip produced (guardrail 6
already asks for this), and — for any substantial or fully agent-driven change —
running a comprehension quiz before merge: find-unknowns owns that move
(explain the diff and what it touches, then test that you can pass a quiz on the
non-obvious behavior). Autonomy that outruns understanding isn't a faster team;
it's a deferred debugging session.
Concrete loop skills don't re-implement any of the above — they fill in the contract and inherit the machinery:
fix-until-green — proof = test+lint+typecheck all exit 0; primitive =
/goal or a Stop-hook gate; the canonical first instance.skills/loops/<name>/ whose SKILL.md states its 5-part
contract, names its proof artifact, and points back here for the guardrails.
The authoring walkthrough (with the loop taxonomy and a frontmatter template)
is references/authoring.md.Under the orchestrator, loops slot in at two levels — and both are built:
orchestrator-task-loop is the outer loop over the shared task list (re-assign
until every task passes its gate), while the inner loops run per role —
fix-until-green at the wave/QA gates, and contract-conformance-loop /
coverage-loop / perf-loop / migration-loop dispatched when the mission
calls for them (see the orchestrator's references/phase-guide.md, Optional
build loops).
references/primitives.md — /goal, /loop, /batch, dynamic workflows,
Stop-hooks, and the bash-Ralph loop: exact mechanics, constraints, invocations,
and the implementation-approach tradeoff table. Read before choosing a primitive.references/safety.md — the full guardrail stack, stop_hook_active,
oscillation/no-progress detection, the cost footguns, and the staged-adoption
and rollback ladder.references/authoring.md — the 10-archetype loop taxonomy, the fresh-context
evaluator / default-FAIL pattern in detail, and a step-by-step template for
writing a new loop skill that composes on this one.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub ivy00johns/skill-madness --plugin skill-madness87 skills in this plugin
/accessibility-auditAudit and fix web accessibility against WCAG 2.2 AA, Section 508 and the ADA: axe scan, keyboard, screen-reader and zoom checks, plain-language content and PDFs, source fixes, and an honest conformance report (ACR/VPAT draft). Use for any a11y review, fix or compliance question. Trigger on "accessibility audit", "is this ADA compliant", "Section 508", "WCAG", "VPAT", "a11y"./andonRun work through a live Andon board (the kanban that dispatches cards to Claude Code, Codex and Gemini on your machines): push a plan's cards with the skills each run must load, read the board, answer what needs you, administer a machine, and refresh this skill when Andon changes. Trigger on "/andon", "put this plan on andon", "what needs me on andon", "why isn't my card running".
/architecture-rescueFind deepening opportunities in a codebase (shallow modules, missing seams, leaky abstractions) and present them as numbered candidates for a grilling session before any interface is proposed. Use when the code feels tangled or hard to test. Trigger on "improve architecture", "rescue this codebase", "find refactoring opportunities", "ball of mud", "shallow modules"./artifact-publishPublish a visual or interactive result as a Claude Code Artifact: a self-contained HTML or Markdown page on a private, shareable claude.ai link instead of a local file. Use when a dashboard, report, chart, diagram or prototype reads better as a page. Not the claude.ai design canvas (claude-design-brief). Trigger on "publish this as an artifact", "make a shareable link", "give me a link to this"./babysitKeep an open PR healthy on a schedule: poll for review activity, auto-address bot and Copilot nits and routine rebases, re-run the gate, until the PR is mergeable. HITL on anything irreversible; never auto-merges. The scheduled loop around git-pr-feedback, run as "/loop 5m /babysit". Trigger on "babysit my PR", "watch this PR", "keep my PR green", "keep the PR rebased"./backend-agentBuild API servers, business logic and data layers against authored contracts. Use in native orchestrator dispatch or explicitly requested solo backend implementation; load it when the orchestrator assigns this role or the user asks for it.Other plugins' skills for the same job