This is Part 2 of a series on the Ralph Loop. Today we dissect RALPH_PROMPT.md—the instruction document that makes autonomous AI development work.
The Prompt is Everything
When Claude runs in a loop, it starts fresh each iteration. No memory of what it did last time. No context about your project beyond what you provide.
RALPH_PROMPT.md is that context. Get it wrong and Claude wastes iterations confused. Get it right and it becomes a tireless implementation machine.
Anatomy of a Ralph Prompt
Every effective Ralph prompt has these sections:
1. The Mission Statement
Start with exactly what Claude is doing and why.
# Phase 8: Fish Genetics & Battle System
You are implementing the genetics and battle system for Aqua-tics,an idle aquarium game. This phase adds Pokemon-style battles wherefish stats are inherited through breeding.This isn’t just documentation—it’s priming. Claude performs better when it understands the big picture.
2. The Task Discovery Instructions
Tell Claude exactly how to find its next task:
## Finding Your Next Task
1. Read `IMPLEMENTATION_PLAN.md`2. Find the first unchecked task `- [ ]`3. This is your task for this iteration4. Do NOT skip ahead or work on multiple tasksThe “do NOT skip ahead” is crucial. Without it, Claude tries to be helpful by tackling multiple items, creating merge conflicts with itself.
3. Implementation Standards
Define what “done” means:
## Definition of Done
A task is complete when:- [ ] Code compiles with no TypeScript errors- [ ] All tests pass (`bun test`)- [ ] New code has tests (aim for 80% coverage)- [ ] Exports are updated in package index files- [ ] The checkbox in IMPLEMENTATION_PLAN.md is marked [x]Without explicit standards, Claude marks tasks complete prematurely.
4. Codebase Context
Point Claude to relevant patterns:
## Key Files & Patterns
**Game Logic**: `packages/game-core/src/`- Fish definitions: `fish.ts`- Breeding logic: `breeding.ts`- Battle system: `battle/` directory
**Existing Patterns to Follow**:- Use Zod for all schemas- Export types from `types.ts` files- Tests go in `__tests__/` directoriesThis saves Claude from exploring your entire monorepo each iteration.
5. Completion Markers
Define how to signal “all done”:
## When Everything is Complete
When ALL tasks in IMPLEMENTATION_PLAN.md are checked [x]:1. Run the full test suite2. Verify no TypeScript errors3. Output exactly: IMPLEMENTATION_COMPLETE
Do NOT output this marker until truly finished.The ralph.sh script watches for these markers to know when to stop.
Common Prompt Mistakes
Too vague:
# BadImplement the battle system.# GoodImplement the turn-based battle state machine inpackages/game-core/src/battle/state-machine.ts.Use the existing BattleState type from types.ts.No file paths:
# BadAdd tests for the breeding system.# GoodAdd tests in packages/game-core/src/__tests__/breeding.test.tscovering edge cases for incompatible fish pairings.Ambiguous completion:
# BadMark the task done when you think it's ready.# GoodMark the checkbox [x] only after:1. `bun run typecheck` shows no errors2. `bun test breeding` passesThe Full Template
Here’s the template we use for every Ralph prompt:
# [Phase Name]: [Feature Description]
## Overview[2-3 sentences about what this phase accomplishes]
## Your Workflow1. Read IMPLEMENTATION_PLAN.md2. Find the first unchecked `- [ ]` task3. Implement it completely4. Mark it `- [x]` when done5. If all tasks complete, output: IMPLEMENTATION_COMPLETE
## Definition of Done- Code compiles (`bun run typecheck`)- Tests pass (`bun test`)- New functionality has tests- Exports updated in index files- Checkbox marked in IMPLEMENTATION_PLAN.md
## Key Files[List of important files and what they contain]
## Patterns to Follow[Code style, naming conventions, architectural patterns]
## Completion MarkersWhen truly finished, output one of:- IMPLEMENTATION_COMPLETE- ALL_TASKS_COMPLETE- RALPH_COMPLETE
## Notes[Any phase-specific gotchas or requirements]Iteration is Key
Your first Ralph prompt will be wrong. Claude will misinterpret something, skip steps, or mark tasks done too early.
That’s fine. Watch the first few iterations, see where Claude goes astray, and refine the prompt. After 2-3 revisions, you’ll have instructions that work reliably.
The time invested in prompt refinement pays off across dozens of autonomous iterations.
Next up in Part 3: We’ll cover the task breakdown system and how /breakdown converts PRDs into executable task lists.