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.
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. Hardened 2026-07-27: explicit stop/cap/verification guardrails appended; regraded D→A.
More automation loops
Ship production-grade apps autonomously
Hand an idea to Claude Code; it authors specs, designs, builds, tests, secures, and ships until enterprise done or budget exhausted.
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.
Complete all tasks in tasks.md
Work through your tasks.md file, completing each task until none remain or max iterations is reached.