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.
loop-init, loop-audit, loop-cost CLI patterns
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.
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.
Cursor "Iterate Until Tests Pass, Never Touch the Tests"
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.
Custom loop.md — Project-Level Default for Bare /loop
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.
Multi-repo autonomous dev team loop
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.
Codex CLI as an MCP Tool Inside an Agents-SDK Loop
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.
Architect-builder cross-vendor loop
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.
Ralph Overnight Builds — Progressive Curriculum Entry
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.
Agent-Loop-Skills bundle — loop until it's better
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.
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
Claim tasks from a shared kanban queue and execute them with cost caps, retries, and peer recovery until the backlog clears.
Run an autonomous dev team across GitHub repos (looper)
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.
Continuous Claude — PR-gated Ralph loop
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.
Codex CI Autofix Loop (Fix Failing GitHub Actions)
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.
Runaway-Bill Guardrail Loop (Watchdog Beside the Worker)
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.
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.
Run Ralph Loop toward persistent goals
Execute Plan-Act-Test-Review-Iterate cycles on a goal until it succeeds, pauses, blocks, or token budget exhausts.
Ralph with circuit-breaker exit detection
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.
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.
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.
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
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.
AutoLoop — metric-driven optimization loops
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.
Loop cost guardrails pattern
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.
Codex App Automations (Scheduled Agent Runs)
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.
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.
Official Ralph Wiggum plugin (Anthropic)
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.
Boris Cherny loop methodology + agent-loop skill
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.
Looper — design-review your loop before running it
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.
Autonomous overnight ML research loop with stall detection (ARIS)
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.
Issue-to-Merge GitHub-Native Loop (Engineer the Reload)
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.
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.
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.
Codex Iterative Repair Loop (JSON-Schema Review → Repair)
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.
Spec-first Ralph (PLAN.md-driven)
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.
Stop-Hook Ralph (Deterministic Loop Without Bash)
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.
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.
Deterministic backlog loop for Codex CLI
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.
claudex — Adversarial Claude+Codex Plan Review Loop
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.
claude-progress.txt harness pattern (Anthropic)
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.
claude-loop — iterative sessions with cost tracking
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.
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 →