12
Ralph Loop
The original Ralph Wiggum technique - a dead-simple bash loop that repeatedly feeds Claude a prompt until your task is done. Set it and forget it.
# Ralph Loop - Simple Autonomous Development
The simplest form of autonomous AI development. Named after Geoffrey Huntley's technique.
## The Core Loop
```bash
while :; do cat PROMPT.md | claude ; done
```
That's it. That's the tweet.
## How It Works
1. Write your task in `PROMPT.md`
2. Run the loop
3. Claude executes, fails, learns, retries
4. Eventually it succeeds
5. Kill the loop (Ctrl+C)
## Example PROMPT.md
```markdown
# Task: Add dark mode to the settings page
## Requirements
- Toggle switch in settings
- Persist preference to localStorage
- Apply theme class to document root
- Respect system preference as default
## Completion Criteria
When you're done:
1. Run `npm test` - all tests pass
2. Run `npm run build` - no errors
3. Say "TASK COMPLETE" at the end of your response
## Current Status
Check git status and continue from where you left off.
```
## Why It Works
- **Failures are information** - Each failed attempt teaches Claude what doesn't work
- **Tests as guardrails** - Automated validation catches mistakes
- **Fresh context each loop** - No context window bloat
- **Persistence wins** - Keep trying until it works
## Tips
1. **Clear completion criteria** - How does Claude know when to stop?
2. **Verifiable success** - Tests, builds, linters
3. **Incremental progress** - Commit after each successful step
4. **Watch the costs** - Each loop is an API call
## When to Use
- Tasks with clear pass/fail criteria
- Overnight unattended runs
- Iterative refinement (styling, tests, refactoring)
- Bug fixes with reproduction steps
## When NOT to Use
- Subjective decisions ("make it prettier")
- Production debugging
- Anything needing human judgment mid-task
## The Philosophy
> "Instead of trying to get it right the first time, let the machine iterate until it converges on a solution."
Stop prompt engineering. Start loop engineering.
Comments
No comments yet
Be the first to share your thoughts!