"That's the beauty of Ralph - the technique is deterministically bad in an undeterministic world." - Geoffrey Huntley
The Ralph Wiggum Technique is a method for autonomous, incremental software development using AI agents in a continuous loop. Based on research from Anthropic's long-running agent harness and the Ralph Wiggum loop pattern, this approach enables AI agents to build complex applications systematically across multiple context windows.
At its core, Ralph is simple:
while :; do cat PROMPT.md | claude-code ; doneBut effective long-running agents require structure to work incrementally across many sessions. This document provides everything you need to implement the Ralph Wiggum Technique.
A JSON file containing all features to be implemented, each with a test specification and completion status.
A plain text file where agents document their work, decisions, and learnings.
The reusable prompt given to the AI agent each iteration.
A script that sets up and runs the development environment. Only needed for new projects or complex setups. Existing projects typically use standard npm/pnpm scripts instead.
The bash script that orchestrates the agent loop in either:
- Human-in-the-loop mode (default): Runs one iteration, pauses for review
- Continuous AFK mode: Runs until all features complete
All Ralph workflow files are stored in this directory which is gitignored to prevent accidental commits to the codebase.
Phase 1: Initializer Agent (First run only)
- Creates the initial project structure
- Creates
.ralph/directory and adds to.gitignore - Generates comprehensive
.ralph/prd.jsonfrom requirements - Sets up
.ralph/progress.txtand.ralph/init.sh - Makes initial git commit
Phase 2: Coding Agent (All subsequent runs)
- Gets bearings (reads git log, .ralph/progress.txt, .ralph/prd.json)
- Tests existing functionality
- Implements ONE feature
- Verifies end-to-end with testing tools
- Updates
.ralph/prd.jsononly if fully verified - Logs to .ralph/progress.txt and commits
- One Feature Per Iteration: Never attempt multiple features in a single session
- Clean State: Always leave code in a mergeable state with no bugs
- Comprehensive Testing: Use browser automation and end-to-end tests
- Clear Documentation: Update progress log and write descriptive commits
- Incremental Progress: Small, verified steps prevent context overflow
See the companion files in this directory:
prd.json.template- Example feature list structureAGENT_PROMPT.md- Ready-to-use agent promptralph.sh- Bash orchestration scriptinit.sh.template- Example initialization script
| Problem | Solution |
|---|---|
| Agent declares victory too early | Comprehensive feature list with explicit pass/fail |
| Agent tries to do too much at once | Enforce one-feature-per-iteration rule |
| Code left in broken/undocumented state | Require testing, progress logging, and git commits |
| Features marked done without proper testing | Mandate browser automation and end-to-end verification |
| Agent wastes time figuring out how to run app | Provide .ralph/init.sh script |
| Ralph files accidentally committed to repo | Store all workflow files in gitignored .ralph/ dir |
- Create your initial requirements in a simple text file
- Run the initializer agent with initialization prompt
- Review generated
.ralph/prd.jsonand adjust if needed - Verify
.ralph/is in.gitignore - Start the Ralph loop:
- Human-in-the-loop:
./ralph.sh(recommended for learning) - Continuous mode:
RUN_MODE=continuous ./ralph.sh(for AFK runs)
- Human-in-the-loop:
- Create
.ralph/directory:mkdir -p .ralph - Add to gitignore:
echo ".ralph/" >> .gitignore - Manually create
.ralph/prd.jsonwith your feature list - Create empty
.ralph/progress.txt - (Optional) Create
.ralph/init.shonly if needed - most projects can skip this - Ensure your project has git initialized
- Start the Ralph loop:
- Human-in-the-loop:
./ralph.sh - Continuous mode:
RUN_MODE=continuous ./ralph.sh
- Human-in-the-loop:
- Anthropic: Effective harnesses for long-running agents
- Geoffrey Huntley: Ralph Wiggum as a "software engineer"
When all features in .ralph/prd.json have "passes": true, the agent outputs:
PROMISE COMPLETE
This signals the loop can terminate successfully.