Ralph-style loops

Fresh-context iterations against a PROMPT.md backlog with guardrails — the Ralph Wiggum technique (Geoffrey Huntley). The pattern behind most production harnesses.

Karpathy-Style CLAUDE.md Self-Check Protocol for Loops

A self-check protocol embedded in CLAUDE.md that every loop iteration obeys before ending a turn: re-read the goal, diff the changes against it, run the verification command, and state what remains — a ritual that catches drift between iterations.

prompt
→ Claude
Preamble rules embedded in CLAUDE.md that every loop iteration obeys: before ending a turn, re-read the goal, diff your changes against it, run the verification command, and explicitly state what remains — a self-check ritual that catches drift between iterations. (Community template descended from Andrej Karpathy's circulated CLAUDE.md rules.)
qualitymedium risk

loop-init, loop-audit, loop-cost CLI patterns

/ralphnew

Three starter CLI tools that turn loop design into a repeatable workflow: scaffold a loop with a goal, budget, and verify step; audit an existing loop design; and estimate cost before you run.

prompt
→ Claude
Starter CLI tools: `loop-init` scaffolds a loop (goal, budget, verify step), `loop-audit` reviews an existing loop design, `loop-cost` estimates spend before running.
planningmedium risk

Ralph the PRD backlog

The canonical Ralph loop: each iteration starts fresh, reads the PRD and guardrails, ships exactly one backlog item end-to-end, and records what it learned.

prompt
→ Claude
/loop start each iteration with fresh context: read PROMPT.md, prd.json, and .ralph/guardrails.md; pick the single highest-priority item in prd.json not marked done, implement it with tests, run the full check suite, commit and mark it done only if green; if blocked or a check fails twice the same way, append the lesson to .ralph/guardrails.md and move on; stop when every item is done or after 30 turns
planninghigh risk

Cursor "Iterate Until Tests Pass, Never Touch the Tests"

/ralphnew

First-party Cursor guidance for the iterate-until-green loop, with the key anti-reward-hacking clause: the agent may never modify the tests it is trying to satisfy. Works in Cursor, Claude Code /goal, and Codex.

prompt
→ Claude
"Write code that makes these tests pass. Do NOT modify the tests. Keep iterating — run the suite, fix failures, run again — until all tests pass." (paraphrase of Cursor's official agent best-practices guidance)
testingmedium risk

Custom loop.md — Project-Level Default for Bare /loop

/ralphnew

A team-config pattern: a loop.md file in the project root overrides the built-in maintenance prompt, so any teammate running bare /loop gets your project's canonical loop — run lint, typecheck, and tests, fix anything red, stop when clean.

prompt
→ Claude
Put a `loop.md` in the project root to replace the built-in maintenance prompt when a user runs bare `/loop` — e.g., "run lint + typecheck + tests; fix anything red; update CHANGELOG; stop when clean." Every teammate's bare `/loop` now runs your loop.
automationmedium risk

Multi-repo autonomous dev team loop

/ralphnew

The fleet pattern: run agent loops across multiple repos in parallel, each isolated in its own git worktree, with a pluggable vendor layer spanning Claude Code, Codex, Cursor CLI, and OpenCode.

prompt
→ Claude
Register repos, run loops across them in parallel, each loop in its own git worktree; pluggable vendor layer (claude-code, codex, cursor-cli, opencode) — plan, review, fix, ship on a loop.
automationmedium risk

Codex CLI as an MCP Tool Inside an Agents-SDK Loop

/ralph★ OpenAInew

An outer-planner/inner-coder loop from an official OpenAI recipe: an Agents SDK orchestrator plans and verifies while Codex CLI, wrapped as an MCP server, performs one bounded code change per turn.

prompt
→ Claude
Wrap Codex CLI as an MCP server and drive it from an OpenAI Agents SDK orchestrator loop — the outer agent plans/verifies, the inner Codex call does one bounded code change per turn.
automationmedium risk

Architect-builder cross-vendor loop

/ralphnew

A two-vendor loop that pairs Claude as architect with Codex as builder, using the repo itself as shared memory: the architect writes specs, the builder implements one item per iteration, and the architect reviews the diffs on the next pass.

prompt
→ Claude
Claude as architect, Codex as builder, the repo as shared memory — architect writes plan/spec files, builder implements one item per iteration, architect reviews diffs next pass.
planningmedium risk

Ralph Overnight Builds — Progressive Curriculum Entry

/ralphnew

A graduated path to unattended Ralph runs: start with a single bounded task, add a PROMPT.md spec file, add verification, and only then remove the human from the loop for overnight builds.

prompt
→ Claude
Staged path from basic prompt → PROMPT.md spec → overnight Ralph run: start with a single bounded task, add a spec file, add verification, only then remove the human from the loop.
planningmedium risk

Agent-Loop-Skills bundle — loop until it's better

/ralphnew

Six verification-gated loops in one open-standard skill bundle — autoresearch, scientific writing, data analysis, code/SQL/prompt optimization, and red-teaming — portable across Claude Code, Codex, and Cursor. Use the red-teaming loop only against systems you own and are authorized to test.

prompt
→ Claude
"Loop until it's better" — verification-gated loops for autoresearch, scientific writing, data analysis, code/SQL/prompt optimization, red-teaming, packaged as open-standard Agent Skills portable across Claude Code, Codex, Cursor.
qualitymedium risk
Sponsored · ConnectMyEmail

Loops that read your inbox.

Email is the missing tool in your harness. ConnectMyEmail gives Claude Code and Codex a clean MCP into Gmail, Outlook, iCloud and IMAP — triage, drafts, follow-ups, on a loop.

connectmyemail.com →

Run autonomous task daemon with guardrails

/ralphnew

Claim tasks from a shared kanban queue and execute them with cost caps, retries, and peer recovery until the backlog clears.

prompt
→ Claude
/goal "<objective " + /subgoal (numbered criteria), or headless buddy goal . buddy --yolo grants 400 tool rounds under a $100 cap with guardrails, and the 24/7 autonomous daemon ( buddy autonomy install ) claims tasks from a shared queue and runs them free-first (local → Tailscale → paid). That queue is a unified kanban board : the agent's kanban tools and the daemon drive one shared board with a claim lease + heartbeat , zombie reclaim of a crashed peer's work, a retry budget that dead-letters a hopeless task to a review column, and a dependency DAG — view it as Hermes-style columns with buddy autonomy tasks board
automationmedium risk

Run an autonomous dev team across GitHub repos (looper)

/ralphnew

Runs Claude Code/Codex as an autonomous multi-role dev team — planner → reviewer ↔ fixer → worker — across all of a user's GitHub repos, entirely driven by issue labels. Each loop runs in its own git worktree so multiple repos/issues proceed in parallel without collisions.

prompt
→ Claude
Register a repo with looper, then label an issue `looper:plan` and assign it to yourself. The planner reads the issue, explores the repo, drafts a spec, critiques and revises it, and opens a spec PR labeled `looper:spec-reviewing`. A reviewer re-reads the PR on every commit and posts inline review threads; a fixer pulls those threads, addresses them in its own worktree, and pushes, ping-ponging with the reviewer until every thread is resolved. Once labeled `looper:spec-ready`, a worker implements the spec, runs checks, and iterates on its own output until checks pass and the PR is ready for human review and merge. Every phase transition is gated on a GitHub label via `looperd`, so a human can pause or take over at any boundary.
automationmedium risk

Continuous Claude — PR-gated Ralph loop

/ralphnew

The Ralph loop for teams: every iteration ships as a pull request that must pass CI before merging, giving each cycle a verifiable checkpoint. Keep branch protection and human PR approval enabled rather than letting it auto-merge to main unattended.

prompt
→ Claude
Run Claude Code in a continuous loop that opens a PR per iteration, waits for CI checks, and merges when green, then starts the next iteration.
cimedium risk

Codex CI Autofix Loop (Fix Failing GitHub Actions)

/ralph★ OpenAInew

An event-triggered loop where a red GitHub Actions build invokes `codex exec` non-interactively with the failing logs and repo, and Codex proposes a fix as a PR or patch artifact — one bounded iteration per CI failure.

prompt
→ Claude
CI job: on workflow failure, run `codex exec` non-interactively with the failing logs + repo, have it generate and propose a fix (PR or patch artifact) automatically. `codex exec` runs one task and exits, so each CI failure is one bounded iteration.
cimedium risk

Runaway-Bill Guardrail Loop (Watchdog Beside the Worker)

/ralphnew

A cost-safety pattern that pairs every overnight loop with a second, dumber loop whose only job is stopping the first: spend alerts, a hard iteration cap, and a cron check that kills the worker when token burn spikes or the same command keeps repeating.

prompt
→ Claude
Pair every overnight loop with a watchdog: spend/usage alert thresholds, a hard `MAX_ITER`, and a cron check that kills the loop process if tokens-per-minute spikes or the same command repeats N times. The watchdog is a second, dumber loop whose only job is stopping the first one.
automationmedium risk

Guardrails that learn from failure

A Ralph-style loop that writes its own rules: when a check fails the same way twice, the failure pattern gets appended to a guardrails file that every later iteration reads first.

prompt
→ Claude
/loop read .ralph/guardrails.md before doing anything, then run the full check suite and fix the first failure; if a check fails twice with the same error, append the failure pattern and a one-line rule for avoiding it to .ralph/guardrails.md before retrying; stop when all checks pass or after 15 turns
automationmedium risk

Run Ralph Loop toward persistent goals

/ralphnew

Execute Plan-Act-Test-Review-Iterate cycles on a goal until it succeeds, pauses, blocks, or token budget exhausts.

prompt
→ Claude
/goal <objective — a persistent objective that survives sessions and runs the Ralph Loop (Plan → Act → Test → Review → Iterate) until the goal is achieved, paused, cleared, blocked ( unmet ), or the token budget is exhausted
planninghigh risk

Ralph with circuit-breaker exit detection

/ralphnew

A safe Ralph variant that solves runaway loops with circuit-breaker heuristics: it halts automatically when iterations stop producing file changes or keep hitting the same error.

prompt
→ Claude
Ralph loop wrapped with exit heuristics: no file changes for 3 consecutive iterations = no progress → stop; same error 5 consecutive loops = stuck → stop.
automationmedium risk

Ralph the bug backlog

Work a triaged bug list one fix per fresh-context iteration: reproduce first, fix minimally, prove it with a regression test, and log root-cause patterns to guardrails.

prompt
→ Claude
/loop fresh context each iteration: read bugs.json and .ralph/guardrails.md, take the top open bug, write a failing test that reproduces it before touching any code, then apply the smallest fix that makes the test pass with the rest of the suite green, and mark the bug fixed; if you cannot reproduce it, mark it needs-info with your findings instead; append recurring root-cause patterns to .ralph/guardrails.md; stop when bugs.json is clear or after 25 turns
debugginghigh risk

Ralph a test backlog

Iterate over a prioritized list of untested modules with fresh context each pass, writing real behavioral tests for one module at a time and banking lessons in a guardrails file.

prompt
→ Claude
/loop each iteration with fresh context: read .ralph/test-backlog.json and .ralph/guardrails.md, pick the top unfinished module, write behavioral tests for its public API (no snapshot-only tests), run the suite, and mark the module done only when its tests pass and coverage for it exceeds 80%; append any discovered testing gotcha (fixtures, mocking rules, async traps) to .ralph/guardrails.md; stop when the backlog is empty or after 25 turns
testinghigh risk
Sponsored · ConnectMyEmail

Loops that read your inbox.

Email is the missing tool in your harness. ConnectMyEmail gives Claude Code and Codex a clean MCP into Gmail, Outlook, iCloud and IMAP — triage, drafts, follow-ups, on a loop.

connectmyemail.com →

Verification-gated self-running loop skill

/ralphnew

A drop-in Claude Code skill that keeps looping until an external verifier passes — not the model's own self-report — making it a strong anti-reward-hacking pattern for autonomous coding.

prompt
→ Claude
Drop-in Claude Code skill: self-running agent loop with a "real, un-foolable verification gate" — loop continues until an external verifier (not the model's self-report) passes.
testingmedium risk

AutoLoop — metric-driven optimization loops

/ralphnew

Agent-agnostic hill-climbing loops inspired by Karpathy's autoresearch: define a metric, let the agent propose a change, measure, keep it only if the number improved, and repeat.

prompt
→ Claude
Iterative optimization loops (inspired by Karpathy's autoresearch): define a metric, agent proposes change, harness measures, keep if improved, repeat. Works with Claude Code, Codex, Cursor, Gemini CLI.
performancemedium risk

Loop cost guardrails pattern

/ralphnew

The four-part cost guardrail every agent loop should ship with: a hard iteration cap, a stop-after-N-turns clause in the goal text, a budget limit on SDK loops, and a /cost check inside the loop body.

prompt
→ Claude
Every loop gets: `MAX_ITER=20` hard cap, "or stop after N turns" in the /goal text, `max_budget_usd` on SDK loops, and a /cost check in the loop body.
automationmedium risk

Codex App Automations (Scheduled Agent Runs)

/ralph★ OpenAInew

Codex's native answer to scheduled agent loops: define a prompt plus a schedule in the Codex app and it runs in the cloud on cadence — nightly dependency audits, morning issue triage — with no terminal open. The Codex-side equivalent of Claude Code Routines.

prompt
→ Claude
Define an Automation in the Codex app: a prompt + schedule that runs in the cloud on cadence (e.g., nightly dependency audit, morning triage of new issues), no terminal open.
automationmedium risk

The original Ralph Wiggum loop

The canonical Ralph Wiggum loop by Geoffrey Huntley: a bash while-loop that feeds Claude Code one fresh-context iteration at a time, using the filesystem and git as memory. Run it only in a sandboxed environment with permissions configured — never with permission checks disabled.

prompt
→ Claude
`while :; do cat PROMPT.md | claude -p ; done` — PROMPT.md holds the spec + "pick ONE task from the plan, implement, test, commit, exit." Fresh context every iteration; filesystem + git = memory.
automationmedium risk

Official Ralph Wiggum plugin (Anthropic)

/ralph★ Anthropicnew

Anthropic's first-party take on the Ralph loop: a Claude Code plugin that runs the iterate-fresh-context pattern with a managed stop and iteration mechanism built in.

prompt
→ Claude
Install the `ralph-wiggum` plugin from the anthropics/claude-code repo; it wraps the Ralph loop with a managed stop/iteration mechanism inside Claude Code.
automationmedium risk

Boris Cherny loop methodology + agent-loop skill

/ralphnew

A fact-checked knowledge base of Claude Code creator Boris Cherny's loop methodology, packaged as a runnable agent-loop skill you can drop straight into Claude Code.

prompt
→ Claude
Fact-checked knowledge base of Cherny's loop methodology for running Claude Code, shipped as a runnable `agent-loop` skill in `skill/agent-loop/`.
planningmedium risk

Looper — design-review your loop before running it

/ralphnew

A plan-the-loop-first skill: it interviews you about the automation idea, previews the flow as ASCII art, and only writes final loop artifacts after you confirm — a safe on-ramp for loop beginners.

prompt
→ Claude
Skill interviews you about the automation idea, writes loop artifacts to `looper-output/`, shows an ASCII flow preview, and only finalizes after you confirm — design the loop before any runner touches files.
planningmedium risk

Autonomous overnight ML research loop with stall detection (ARIS)

/ralphnew

Framework-agnostic (Claude Code, Codex, OpenClaw, or any LLM agent), markdown-only skill bundle (79+ skills) for running ML research unattended overnight: literature search, idea generation, experiment execution, and cross-model paper review, with a silent-death watchdog and a stall/pivot mechanism so a stuck loop changes approach instead of looping forever on minor variants.

prompt
→ Claude
Install the ARIS markdown-only skills, then run the overnight research loop: the agent reviews relevant literature, proposes and critiques experiment ideas, runs GPU experiments, updates a persistent Research Wiki, and has a second model cross-review the draft paper each round. A watchdog checks the state file's modification time and flags the run STALE/MISSING/COMPLETED if it goes silent. An iteration log counts new findings per round; at 2 consecutive stale rounds it forces a structural pivot (reframe and try a new direction), and at 4 it escalates to a human instead of continuing to retry near-identical variants.
evaluationmedium risk

Issue-to-Merge GitHub-Native Loop (Engineer the Reload)

/ralphnew

A full-lifecycle loop where every piece of workflow state lives in GitHub — issues, labels, PR comments — and repo files, so each cold-start session rehydrates from GitHub rather than a conversation. Built on the official claude-code-action.

prompt
→ Claude
Run Claude Code across the full lifecycle — issue intake → branch → implement → PR → review fixes → merge — with ALL workflow state externalized to GitHub (issues, labels, PR comments) and repo files. Each session starts cold and rehydrates from GitHub state; "the chat being gone doesn't cost you anything."
cimedium risk
Sponsored · ConnectMyEmail

Loops that read your inbox.

Email is the missing tool in your harness. ConnectMyEmail gives Claude Code and Codex a clean MCP into Gmail, Outlook, iCloud and IMAP — triage, drafts, follow-ups, on a loop.

connectmyemail.com →

Schedules + goals + subagents design framework

A design framework for AI agent loops built on three questions — when should it run (schedule), what does done mean (goal), and who does the isolated pieces (subagents) — with worked examples in Claude Code and Codex.

prompt
→ Claude
Design framework: choose schedule (when), goal (what done means), subagents (who does isolated pieces) — with worked examples in Claude Code and Codex.
planningmedium risk

Ralph a refactor, module by module

Break a large refactor into a JSON backlog of modules and let fresh-context iterations convert one module per pass, with guardrails capturing every pattern decision so the result stays consistent.

prompt
→ Claude
/loop fresh context each iteration: read refactor-plan.json and .ralph/guardrails.md, take the next module not marked converted, migrate it to the target pattern described in PROMPT.md, run tests and typecheck, and mark it converted only when green; record every convention decision you make (naming, file layout, error handling) in .ralph/guardrails.md so later modules match earlier ones; stop when all modules are converted or after 30 turns
refactoringhigh risk

Codex Iterative Repair Loop (JSON-Schema Review → Repair)

/ralph★ OpenAInew

OpenAI's first-party loop recipe: a script alternates a Codex review pass that emits machine-readable findings with a repair pass fed those findings verbatim, looping until validation passes, attempts run out, progress stalls, or a decision needs human review.

prompt
→ Claude
Script alternates two `codex exec` calls: (a) review pass with a JSON schema output ("list remaining issues as machine-readable findings"), (b) repair pass fed those findings verbatim. Loop while findings remain, capped by max attempts. Stops for one of four reasons: validation passes, max attempts reached, remaining delta stops changing, or next decision needs human review.
reviewmedium risk

Spec-first Ralph (PLAN.md-driven)

/ralphHumanLayernew

The spec-driven maturation of the Ralph loop: each fresh-context iteration reads PLAN.md, implements the highest-priority unchecked item, checks it off, and commits — so the spec file evolves alongside the codebase.

prompt
→ Claude
Ralph variant where the loop prompt is "read PLAN.md, pick highest-priority unchecked item, implement, check it off, commit, exit" — spec file evolves with the codebase.
planningmedium risk

Stop-Hook Ralph (Deterministic Loop Without Bash)

/ralphnew

A Ralph variant that lives inside a single Claude Code session: a stop hook re-injects the task prompt whenever the agent tries to end its turn, trading the bash while-loop's fresh context for a persistent session.

prompt
→ Claude
Use a Claude Code stop hook that re-injects the task prompt whenever the agent tries to end its turn, until a completion condition or hard iteration cap is met — Ralph semantics inside one session instead of a bash `while` wrapper.
automationmedium risk

Ralph the docs backlog

Document one undocumented public module per fresh-context iteration, verifying every code sample compiles and accumulating style rules in guardrails so the docs read like one author wrote them.

prompt
→ Claude
/loop fresh context each iteration: read docs-backlog.json, docs/STYLE.md, and .ralph/guardrails.md; pick the top undocumented module, write its reference page with a runnable example, execute the example to prove it works, and mark the module done; add any style or structure decision to .ralph/guardrails.md; stop when the backlog is empty or after 20 turns
docsmedium risk

Deterministic backlog loop for Codex CLI

/ralphnew

A Codex-first autonomous runner that pulls exactly one task per iteration from a JSON backlog with fresh context each run and a JSONL audit log for full traceability.

prompt
→ Claude
Autonomous runner: exactly one task per iteration pulled from a JSON backlog, fresh context each run, JSONL audit log for traceability; optional Claude Code interleaving.
automationmedium risk

claudex — Adversarial Claude+Codex Plan Review Loop

/ralphnew

A Claude Code plugin that pressure-tests a plan before any code is written: Claude writes PLAN.md, Codex adversarially reviews it from three different reviewer angles in rotation, and a Stop hook drives the draft-critique-revise cycle autonomously in one terminal window until the plan survives review or a round cap is reached.

prompt
→ Claude
/claudex:plan <feature> — Claude drafts PLAN.md from a one-line feature description. A Claude Code Stop hook blocks the turn and runs Codex (via `codex exec`) against the plan using a rotating reviewer persona: round 1 senior engineer, round 2 security/data-integrity, round 3+ ops/SRE. Claude reads Codex's findings and either revises PLAN.md or calls mark-done. The hook re-fires each turn, incrementing the round and rotating the persona, until Codex reports no material findings or the max-rounds cap (default 3, configurable via --rounds) is hit.
planningmedium risk

claude-progress.txt harness pattern (Anthropic)

/ralph★ Anthropicnew

Anthropic's first-party file-as-memory harness for long-running agents: every fresh-context session recovers state from a progress file and the git log, does one unit of work, updates the file, commits, and exits.

prompt
→ Claude
Long-running agent harness: each fresh-context session starts by reading `claude-progress.txt` + git log to recover state, does one unit of work, updates the progress file, commits, exits. Initializer session sets up the file; coder sessions loop.
automationmedium risk

claude-loop — iterative sessions with cost tracking

/ralphnew

An automation harness that runs repeated Claude Code sessions while tracking cost and tokens per iteration — the reference answer to the number-one objection to agent loops: runaway spend.

prompt
→ Claude
Automation toolkit running repeated `claude` sessions with per-iteration cost and token monitoring; inspired by Dex Horthy's context-engineering talk.
automationmedium risk
Sponsored · ConnectMyEmail

Loops that read your inbox.

Email is the missing tool in your harness. ConnectMyEmail gives Claude Code and Codex a clean MCP into Gmail, Outlook, iCloud and IMAP — triage, drafts, follow-ups, on a loop.

connectmyemail.com →