Documentation Index
Fetch the complete documentation index at: https://mintlify.com/snarktank/ralph/llms.txt
Use this file to discover all available pages before exploring further.
How Ralph Works
Ralph is an autonomous AI agent loop that runs AI coding tools (Amp or Claude Code) repeatedly until all PRD items are complete. Each iteration spawns a fresh AI instance with clean context.The Ralph Loop
Initialize
Ralph starts by reading the
prd.json file and checking the current branch matches the PRD’s branchName.Quality Checks
The agent runs quality checks configured for your project:
- Type checking
- Linting
- Unit tests
- Integration tests
Update State
The agent updates
prd.json to mark the story as passes: true and appends learnings to progress.txt.Execution Flow Diagram
The Bash Script
Theralph.sh script is the orchestrator that manages the loop:
Default is 10 iterations. The script will exit early if all tasks complete before reaching the maximum.
What the Script Does
- Parses arguments - Determines which AI tool to use (Amp or Claude Code) and max iterations
- Archives previous runs - If the branch name changed, archives old
prd.jsonandprogress.txt - Spawns AI instances - For each iteration:
- Pipes the prompt template (
prompt.mdorCLAUDE.md) to the AI tool - Captures the output
- Checks for the
<promise>COMPLETE</promise>signal - Continues to next iteration if work remains
- Pipes the prompt template (
Key Script Features
Prompt Templates
Ralph uses different prompt templates for each AI tool:prompt.md- Instructions for Amp instancesCLAUDE.md- Instructions for Claude Code instances
- Where to find the PRD and progress log
- How to select the next task
- What quality checks to run
- How to format progress reports
- When to signal completion
Archiving
When you start a new feature (differentbranchName in prd.json), Ralph automatically archives the previous run:
Interactive Flowchart
For a visual, step-by-step walkthrough of how Ralph works, check out the interactive flowchart:- View Interactive Flowchart
- Run locally:
cd flowchart && npm run dev

