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.
claude-code

Implementation note

When to use: long-horizon autonomous builds where a single session's context would degrade — you have a spec and a plan and want the agent to grind through it iteration by iteration, possibly overnight. This is the pattern everything else in the Ralph family descends from. How it works: a bash while-loop pipes PROMPT.md into claude -p forever; the prompt tells each run to pick ONE task from the plan, implement it, test it, commit, and exit. Every iteration starts with fresh context, and the filesystem plus git history serve as the only memory between runs. Safety: the while-loop is infinite by construction — there is no built-in stop condition, so supervise it or add your own iteration cap and exit checks. Run it only in a sandboxed environment with permissions properly configured, and never with permission checks disabled; an unattended agent with full permissions is the entire risk surface here.

Source: Geoffrey Huntley

More automation loops

Run workflows with dynamic sub-agents

/goalnew

Split a task into packets, run sub-agents in parallel, synthesize results, and verify completion.

prompt
→ Claude
/goal loop and verify until complete
automationlow risk

Run agent turns until goal met

/goalnew

Agent executes repeated turns toward a condition, with a lightweight evaluator checking progress after each turn until the goal is reached.

prompt
→ Claude
/goal <condition turns a prompt into a durable objective. Thanos immediately starts a turn toward the condition, and after each turn a fresh, tool-less side-channel evaluator (a one-shot completeSimple call, not a subagent — so no extra agent turn and no re-entrancy) reads the last turn's evidence and returns MET / NOT MET . NOT MET auto-continues another turn with the reason as guidance; MET clears the goal and records the achievement. Unparseable evaluator output is treated as NOT MET (fail-safe: it never declares a false "done
automationmedium risk

Run agent until goal met

/goalnew

Queue agent turns with goal context until your objective is achieved, treating the goal as untrusted data.

prompt
→ Claude
/goal <objective , after /goal resume , and after every agent turn that leaves the goal active , the extension queues Codex's goal continuation prompt as hidden model-visible context. The objective is XML-escaped and wrapped as untrusted user data so it does not become higher-priority instructions
automationlow risk