Loops

61
The best agentic loops by category: what each one does, what it runs in, when it stops, and a prompt you can paste in.

What's a loop?

A repeating cycle for your agent: act, check the result, improve, and stop only when a condition you can verify is true.
A skill teaches an agent how to do something. A loop keeps it going until it is actually done.

How to run one

Paste a loop's prompt into Claude Code, Codex or Cursor. To keep it running on its own, use a runner: /goal or /loop in Claude Code, Codex Goal Mode, or the Ralph loop.
Good loops have a clear stop condition, proof of done, and a human check before anything public or irreversible.

Where these come from

Loops.fyi ↗ The broadest directory: copyable loops for Claude Code, Codex and Cursor, plus the runners and plugins.
Loop Library ↗ Forward Future's catalog, with the Loopy skill that finds, adapts and runs loops for you.
Awesome Agentic Loops ↗ Production-grade loops: each has proof of completion, saved state, a stop condition and approval gates.
AetherAI3 agentic-loops ↗ Audit-and-fix loops for backends, frontends, infrastructure, security, tests and tech debt.
The built-ins, plugins and harnesses that keep an agent looping until the job is done: Claude Code /goal and /loop, the Ralph loop, Codex Goal Mode and the rest.
1
Claude Code /goalBuilt-inTop pick
Keeps Claude working until a condition you can verify is true. The built-in version of the Ralph loop, no script needed.
Claude Code · Stops when: the condition you set is verifiably true
2
Claude Code /loopBuilt-inTop pick
Runs a task on a cadence you describe in plain English, like a scheduler inside your session.
Claude Code · Stops when: you stop it, or the task says it is finished
3
Ralph Wiggum pluginPluginTop pick
The official Ralph loop: a stop hook feeds your prompt back in every time Claude tries to finish, until the task is done.
Claude Code · Stops when: Claude outputs the completion phrase, or the iteration cap is hit
4
The original pattern: a bash loop that starts a fresh agent session on the same prompt each time, with progress kept in files.
Claude Code · Stops when: the plan file has nothing left, or you kill the loop
5
Codex's built-in long-horizon mode: it keeps working toward an objective you set until it is met.
Codex · Stops when: the objective is met
6
A skill that finds, adapts, creates and runs loops for you from the Loop Library, and audits loops that misbehave.
Claude Code, Codex, Cursor · Stops when: each run is bounded; it never starts schedules or touches production without your approval
Loops that turn a request into working code: a precise goal first, then build, check and fix until the evidence says done.
1
Goal meta-skill loopPromptTop pick
Rewrites a vague request into a precise, checkable goal before any code is written.
Claude Code, Codex, Cursor and other coding agents · Stops when: the goal has checks a machine can verify
2
Writes down the done-criteria first, then refuses to call anything done without evidence for each one.
Claude Code, Codex, Cursor and other coding agents · Stops when: every criterion has evidence attached
3
Reads the code and plans first, waits for your OK, then builds with tests and commits.
Claude Code, Codex, Cursor and other coding agents · Stops when: the plan is built, tests pass and the work is committed
4
Two roles, a builder and a checker. Every failure goes back to the builder until everything is green.
Claude Code, Codex, Cursor and other coding agents · Stops when: the checker finds nothing to send back
5
Reproduces the bug first, then tests one hypothesis at a time until the cause is proven.
Claude Code, Codex, Cursor and other coding agents · Stops when: the reproduction passes and stays as a regression test
Red-green TDD, flaky-test hunts, refactors under tests and dependency upgrades, each kept honest by the test suite.
1
Writes failing tests first, then implements without touching the tests until they pass.
Claude Code, Codex, Cursor and other coding agents · Stops when: all the new tests pass and none were weakened
2
Finds tests that pass and fail at random and fixes the root cause instead of retrying them.
Claude Code, Codex, Cursor and other coding agents · Stops when: the test passes on every one of many runs
3
Small refactors that keep behaviour identical, reverting any step that turns a test red.
Claude Code, Codex, Cursor and other coding agents · Stops when: the refactor is complete with the suite green throughout
4
Upgrades a dependency in small steps against a test baseline, so you know exactly what broke.
Claude Code, Codex, Cursor and other coding agents · Stops when: the target version is in and the baseline still passes
5
Fills coverage gaps, finds tests that verify nothing, and injects failures into dependencies.
Claude Code, Codex, Cursor and other coding agents · Stops when: coverage and mutation targets are met
Loops that review and get reviewed: PR feedback, two-model review, CI babysitting and adversarial review.
1
PR-feedback loopPromptTop pick
Works through review comments one at a time and replies to each with what changed.
Claude Code, Codex, Cursor and other coding agents · Stops when: every comment is addressed or answered
2
Alternates reviews between models from different providers, so one model's blind spots get caught.
Claude Code with Codex or Gemini · Stops when: the second model finds nothing material
3
claude-review-loopPluginTop pick
Claude writes the code, Codex reviews it, and they go back and forth until the review passes.
Claude Code + Codex · Stops when: Codex's review passes
4
Watches a PR's CI, fixes each failure, and pushes until the checks go green.
Claude Code, Codex, Cursor and other coding agents · Stops when: all required checks pass
5
Clears old PRs stuck on unresolved review threads, one thread at a time.
Claude Code, Codex, Cursor and other coding agents · Stops when: no stale threads are left without an answer
6
A generator and a hostile reviewer argue over each change until the reviewer runs out of objections.
Claude Code, Codex, Cursor and other coding agents · Stops when: the reviewer has no material objections left
Karpathy-style autoresearch and keep-or-revert experiments, claim checking and competitor scans, where only measured gains survive.
1
autoresearchHarnessTop pick
Karpathy's overnight research loop: one editable file, a frozen evaluator, one number. Only changes that beat the best result are kept.
Any agent · Stops when: the time or run budget is spent; you wake up to the best version
2
Single-metric experiments where only measured gains survive. Works for prompts, pages, build times and more.
Claude Code, Codex, Cursor and other coding agents · Stops when: the target is reached or the experiment budget is spent
3
AutoloopHarness
Metric-driven propose, evaluate and keep loop, with all its state in plain markdown files.
Any agent · Stops when: the metric target or run budget is reached
4
Karpathy's autoresearch pattern packaged as an installable skill, for any metric you can measure.
Any agent that reads SKILL.md · Stops when: its run budget is spent
5
One change at a time, measured, kept only if it proves better. The ratchet never slips backwards.
Claude Code, Codex, Cursor and other coding agents · Stops when: no further gains, or the budget is spent
6
Labels every factual claim in a draft as proven, weak or unsupported, then fixes or cuts the weak ones.
Any agent with web search · Stops when: every claim left is backed by a source
Recurring upkeep: status reports, queue triage, error sweeps, cost watching and agent health checks.
1
Timed, small, verified repo improvements: one fix per cycle, one commit each.
Claude Code, Codex, Cursor and other coding agents · Stops when: the time box ends or nothing small is left
2
Updates STATUS.md each week from your real sources and carries open threads forward.
Any agent with your tools connected · Stops when: STATUS.md is current; it runs again next week
3
Works through a queue (issues, tickets, inbox) one item at a time and logs a note for each.
Any agent · Stops when: the queue is empty or the batch size is reached
4
Reads production errors, groups them, and fixes the most frequent real one.
Claude Code, Codex, Cursor and other coding agents · Stops when: the top errors are fixed or ticketed
5
Checks whether source-of-truth docs have drifted from the code and flags contradictions in one bounded pass.
Claude Code, Codex, Cursor and other coding agents · Stops when: one pass is complete and the drift list is written
6
Turns API spend and provider failures into a short list of decisions, before the bill surprises you.
Any agent · Stops when: the decision list is written; runs again on schedule
Audit-and-fix sweeps for web security headers, APIs, agent tooling and AI red-teaming.
1
Sweeps a web app for missing security headers and common OWASP issues, fixing one at a time.
Claude Code, Codex, Cursor and other coding agents · Stops when: no high-risk findings remain
2
Audits APIs for security flaws, N+1 queries, dead code and logging problems, and fixes them.
Claude Code, Codex, Cursor and other coding agents · Stops when: no high-severity findings remain
3
Checks your own agents against OWASP's agentic risks: tool schemas, excess privilege and prompt injection.
Claude Code, Codex, Cursor and other coding agents · Stops when: each tool has least privilege and injection tests pass
4
Attacks your AI features for injection, data poisoning, jailbreaks and supply-chain risk.
Claude Code, Codex, Cursor and other coding agents · Stops when: the attack suite no longer gets through
Visual iteration against a mock, accessibility blockers, first-run UX and visual regression.
1
Visual iteration loopPromptTop pick
Builds from a mock, screenshots the result, compares, and iterates until it matches.
Claude Code, Codex, Cursor with a browser · Stops when: the screenshot matches the mock closely enough
2
Checks against WCAG 2.2 AA and fixes the single most harmful blocker each pass.
Any agent with a browser · Stops when: no blockers remain at AA
3
Goes through onboarding as a brand-new user and fixes the worst obstacle each pass.
Any agent with a browser · Stops when: a new user gets through without a blocker
4
Visual regression, stateful UI checks and graceful degradation, across every screen.
Claude Code, Codex, Cursor and other coding agents · Stops when: no visual regressions remain
5
Reviews components and bundle size, then checks the live accessibility tree for roles, focus and contrast.
Claude Code, Codex, Cursor and other coding agents · Stops when: the checks pass
Keep docs true to the product, and grow a website with evidence-based simplification and SEO.
1
Doc-drift loopPromptTop pick
Finds docs that disagree with how the product actually behaves, and updates them.
Claude Code, Codex, Cursor and other coding agents · Stops when: every doc statement checked matches reality
2
At each milestone, sweeps the README and docs so they describe what just shipped.
Claude Code, Codex, Cursor and other coding agents · Stops when: docs match the milestone
3
An evidence-based website overhaul: simpler pages, technical SEO, accurate entity data for AI answers, and accessibility.
Claude Code, Codex, Cursor and other coding agents · Stops when: the audit's top issues are fixed