Ralph Loops Skill
Autonomous multi-iteration build methodology. Based on Geoffrey Huntley's Ralph technique.
Architecture
Core insight: State lives in FILES, not the context window.
Each iteration gets a fresh context and follows: read progress → do ONE task → save state → repeat
This prevents context pollution — the #1 reason AI fails on complex builds. By iteration 15 of a normal session, the context is so polluted the AI edits files that don't exist. Ralph Loops solve this by externalizing all state.
code
┌─────────────────────────────────────────────────┐ │ RALPH LOOP │ │ │ │ INTERVIEW → PLAN → BUILD → DONE │ │ (5 iter) (1 iter) (N iter) (signal) │ │ │ │ │ ▼ │ │ progress.md ◀── Fresh context │ │ (ground truth) each iteration │ └─────────────────────────────────────────────────┘
Phases
1. Interview (max 5 iterations)
- •Gather requirements from user
- •Ask clarifying questions
- •Output: specs files
2. Plan (1 iteration)
- •Read specs, create numbered implementation plan
- •Output: numbered task checklist in progress.md
- •Each task = ONE atomic unit of work
3. Build (N iterations)
- •Each iteration: read progress.md → find next unchecked task → do it → mark done → save
- •ONE task per iteration. Never two.
- •Screenshot after visual changes
- •Run tests/lint before marking done
4. Done
- •All tasks checked off
- •Emit
RALPH_DONEsignal - •Final screenshot
Files
| File | Purpose |
|---|---|
progress.md | Ground truth — plan, task checklist, iteration log |
| Screenshots | Visual proof after UI changes |
| Iteration log | Timestamped entries at bottom of progress.md |
progress.md Structure
markdown
# Ralph Loop: [Project Name] ## Started: [timestamp] ## Status: IN_PROGRESS | RALPH_DONE ## Plan - [ ] 1. First task (atomic, specific) - [ ] 2. Second task - [x] 3. Completed task ... ## Iteration Log ### Iteration 1 (YYYY-MM-DD HH:MM UTC) - Task: #1 — description - Result: Done/Failed - Screenshot: /path/if/visual
Usage
Starting a Ralph Loop
- •Create
/data/ralph-loop-progress.mdwith plan (or let Interview phase create it) - •Set cron: every 30min, payload reads progress, does ONE task, saves state
- •Or use
sessions_spawnfor each iteration - •Each iteration reads
progress.mdFIRST, finds next unchecked- [ ]task - •Does ONE task only, marks it
- [x], logs iteration - •Takes screenshot if visual change
- •Emits
RALPH_DONEwhen all tasks are[x]
Cron Payload Template
code
Read /data/ralph-loop-progress.md. Find the next unchecked task (- [ ]). Do ONLY that one task. Mark it done (- [x]). Add an iteration log entry with timestamp. If visual change, take a screenshot. If ALL tasks are done, change Status to RALPH_DONE. Do NOT do more than one task.
Iteration Prompt (what each iteration does)
code
1. Read /data/ralph-loop-progress.md 2. If Status = RALPH_DONE → reply "RALPH_DONE" and stop 3. Find first unchecked task (- [ ]) 4. Execute ONLY that task 5. Mark it [x] in progress.md 6. Add iteration log entry with timestamp 7. If visual change → screenshot 8. If no unchecked tasks remain → set Status: RALPH_DONE
Key Rules
- •ONE task per iteration — never two. This is non-negotiable.
- •State lives in FILES — never trust context memory across iterations.
- •Always read progress.md FIRST — before doing anything.
- •Always update progress.md AFTER — mark task done, log iteration.
- •Screenshot after visual changes — proof of progress.
- •Kill and restart if stuck — failures are data, not bugs. Tune prompts.
- •Numbered guardrails — hard priorities prevent scope creep.
- •Tests before marking done — mistakes don't compound.
When to Use Ralph
| Use Ralph | Don't Use Ralph |
|---|---|
| Build a dashboard | Fix a typo |
| Create an API | Explain an error |
| Refactor a system | Walk through code |
| Overnight builds | Live pairing |
| Anything >5 tasks | Anything <5 min |
Economics
| Complexity | Iterations | Approx Cost | Time |
|---|---|---|---|
| Simple | ~10 | ~$0.50 | ~15 min |
| Medium | ~30 | $2–5 | 1–2 hrs |
| Complex | 100+ | $15–30 | 4–8 hrs |
Reference
See references/ralph-article.txt for the full methodology article.
Based on Geoffrey Huntley's Ralph technique (ghuntley.com/ralph).