How to Run a Ralph Loop With the Cursor CLI
A full end-to-end setup for running the Ralph loop with the Cursor CLI: install, create a task list, log in inside the sandbox, run cursor-agent in a loop, and review the commits in the morning.
A full end-to-end setup for running the Ralph loop with the Cursor CLI: install, create a task list, log in inside the sandbox, run cursor-agent in a loop, and review the commits in the morning.
ralph.sh is the open-source shell script behind the Ralph loop. Here is how to install it, the flags that drive it, what it does on every iteration, and why it stays hackable.
Claude Code is Ralph’s default agent. A full end-to-end walkthrough for running the Ralph loop with Claude Code: install, log in inside the sandbox, loop on your task list, and review the commits.
A full end-to-end walkthrough for running the Ralph loop with OpenAI Codex CLI: install, log in inside the sandbox, drive codex exec non-interactively, pick a model, and review the commits.
A full end-to-end walkthrough for running the Ralph loop with the Gemini CLI: install, log in inside the sandbox, loop on your task list, choose a model, and review the commits.
A full end-to-end walkthrough for running the Ralph loop with the GitHub Copilot CLI: install, authenticate with gh inside the sandbox, loop on your task list, and review the commits.
A full end-to-end walkthrough for running the Ralph loop with the open-source opencode CLI: install, log in inside the sandbox, loop on your task list with your own model provider, and review the commits.
A sandbox is not a black box. Here is how to find the running microVM, shell into it with sbx exec, reproduce the failure by hand, and read the network log.
A sandboxed agent should start with no outbound network and earn each domain it reaches. Here is how to allowlist exactly what a task needs with sbx policy, so package installs work and exfiltration does not.
Bypass-permissions mode hands an agent full shell access with no prompts. That is reckless on your host and a non-event inside a Docker Sandbox. Here is how to run YOLO mode when the blast radius is contained.
Vibe coding is fast for throwaways and dangerous for production. Here is an honest comparison with spec-driven development, why autonomous agents need a spec, and how to pick per task.
A plain Docker container is a start, not a boundary. Here is how Docker Sandboxes microVMs compare to a hand-rolled container for isolating an autonomous coding agent.
A flat task list stops working past a few dozen entries. A lookup table that indexes per-task spec files lets an autonomous agent grind through hundreds of tasks without losing track.
An autonomous coding agent runs with your full user permissions, which means it can read your SSH keys and push to your remotes. A sandbox is the only blast radius cheap enough to lose.
The most reliable rule for autonomous coding is one task per invocation, commit, then stop. Here is why batching tasks wrecks an agent loop and how Ralph enforces the rule.
A PRD is too big for an agent to build in one shot. Here is how to decompose it into atomic, independently verifiable task packets the loop finishes one at a time.
You do not have to kill a Ralph loop to redirect it. Edit .agent/STEERING.md mid-run and the agent reads it at the top of the next iteration, handles the critical work first, then resumes the task list.
There is no single best agentic CLI. Here is how Claude Code, Codex, Cursor, Gemini, Copilot, and opencode hold up over a long autonomous loop, and how to pick per task.
A Ralph loop fails in a handful of predictable ways. Here is each failure mode, why it happens, and the specific guardrail that stops it.
A PRD for an AI coding agent needs goals, constraints, and verifiable acceptance criteria, not a feature wishlist. Here is what goes in PRD.md and SUMMARY.md and how to draft it.
An autonomous agent only stays safe when every task ends in a machine-checkable result. Tests, type checks, lint, and screenshots are the feedback loop that lets the agent grade its own work.
Point Ralph at Google’s Gemini CLI with one flag, pick a model after the separator, log in once inside the sandbox, and let it grind through your task list with a fresh context each iteration.
A Ralph loop stops on an explicit signal, not a guess. How promise tags and exit codes tell the loop and your scripts when the agent is COMPLETE, BLOCKED, or needs a decision.
An autonomous agent is only as trustworthy as what it shows you. Here are the live stream, per-iteration history, progress log, screenshots, and timing metrics that make a Ralph loop auditable.
Point Ralph at the headless cursor-agent with one flag, log in once inside the sandbox, pass a model after the separator, and review a finished diff in the morning.
PROMPT.md is the instruction sent to the agent on every iteration. Here is how to structure it so a fresh-context agent reorients from disk and ships one verified task at a time.
An autonomous loop burns money when it thrashes. Cap iterations, match the model to the task, and gate every pass on tests so the loop stops instead of looping forever.
Wire OpenAI’s Codex CLI into a Ralph loop with one flag, pass model and approval flags after the separator, and let it grind through your task list inside a sandbox.
One-shot prompting solves small changes in a single response and stalls on hard ones. A Ralph loop iterates with fresh context and tests until the work is actually done.
Long-running agents lose the plot when one context window fills up. Start each iteration fresh and keep durable state on disk so progress never lives in chat history.
Run Claude Code in an autonomous loop that keeps a fresh context every iteration, stops on an explicit completion promise, and stays sandboxed.
Geoffrey Huntley popularized the Ralph technique by running a coding agent in a plain Bash loop until a working programming language fell out the other end. Here is where the idea came from and why it stuck.
Give an autonomous coding agent a real boundary instead of trusting its permission prompts. Here is how Docker Sandboxes isolate an agent in YOLO mode without exposing your machine.
Spec-driven development hands an AI coding agent a PRD, a task list, and acceptance criteria instead of a vague prompt. Here is the full workflow and how Ralph runs it.
Long autonomous runs fail on three axes (context, cost, crashes). Here is the architecture that keeps an AI coding agent productive overnight and across days.
An agentic coding CLI is an AI agent you drive from the terminal. Here is the field guide to the six Ralph supports and how to run any of them in a loop.
The Ralph technique runs a coding agent in a loop until it signals completion. Fresh context each iteration, state on disk, and a promise tag that tells the loop when to stop.