Ralph is an autonomous AI agent loop that runs a coding agent repeatedly until all PRD items are complete. Each iteration is a fresh agent instance with clean context. Supports multiple providers: AMP, Claude Code, Antigravity, CODEX.
# Run the flowchart dev server
cd flowchart && npm run dev
# Build the flowchart
cd flowchart && npm run build
# Run Ralph (from your project that has prd.json)
./ralph.sh [max_iterations]
# Sandboxed mode (permission-restricted)
RALPH_SANDBOXED=1 ./ralph.sh 10
# Parallel execution
./scripts/ralph-parallel.sh -w 3ralph.sh- The bash loop that spawns fresh agent instancesprompt.md- Instructions given to each agent instanceconfig/providers.json- Provider definitions and command patternsconfig/ralph.config.sh- Configuration loader scriptprd.json.example- Example PRD formatflowchart/- Interactive React Flow diagram explaining how Ralph worksconfig/permissions.json- Permission allowlists for sandboxed modescripts/ralph-parallel.sh- Parallel execution orchestratorskills/dev-browser/- Browser verification skillskills/README.md- Skills documentation
The flowchart/ directory contains an interactive visualization built with React Flow. It's designed for presentations - click through to reveal each step with animations.
To run locally:
cd flowchart
npm install
npm run dev- Each iteration spawns a fresh agent instance with clean context
- Memory persists via git history,
progress.txt, andprd.json - Cross-iteration scratchpad lives in
.agent/scratchpad.md(local, ignored by git) - Stories should be small enough to complete in one context window
- Default safety/backpressure is controlled via env vars (
RALPH_MODE,RALPH_AUTO_APPROVE,RALPH_HUMANS_WRITE_TESTS) - Provider selection via
RALPH_PROVIDERenv var (default:amp) - Git safety hooks live in
hooks/(install with./hooks/install.sh, use./hooks/safe-rmfor TRASH deletes) - Always update AGENTS.md with discovered patterns for future iterations
- Sandboxed mode available via
RALPH_SANDBOXED=1for safer operation - Parallel execution available for independent stories via
scripts/ralph-parallel.sh - Use subagents for exploration to preserve main context (documented in prompt.md)
Deterministic quality enforcement (unlike AGENTS.md which is advisory). Install with ./hooks/install.sh.
Git Hooks (auto-installed):
pre-commit- Blocks deletions (use TRASH/), secrets, large diffs, test editspre-push- Enforces branch matchesprd.json.branchName
Utilities:
safe-rm- Move files to TRASH/ instead of deleting
Example hooks (copy and customize):
post-edit.example- Auto-format files after editguardrails.example- Block edits to sensitive files
Key env vars:
RALPH_HOOKS_BYPASS=1- Emergency override for all hooksRALPH_TRASH_DIR- Custom trash directory (default:TRASH/)
When documenting metrics, use a bulleted sub-list under each metric with the following structure:
**Metric Name**
- **What it measures:** Brief description
- **Better values:** High / Low / Optimal range
- **Indicates:** What the metric reveals about the system
- **Related metrics:** Cross-references to paired metrics (if any)
- **Recommended Action:** What to do when out of range