← all repositories
snarktank/ralph

A bash script that babysits AI coding agents until your PRD is done

Ralph runs Amp or Claude Code in a loop, killing context windows on purpose so they don't drift.

20k stars TypeScript AgentsCoding Assistants
ralph
Velocity · 7d
+132
★ / day
Trend
steady
star history

What it does

Ralph is a bash loop that spawns fresh instances of AI coding tools—Amp or Claude Code—to chew through a prd.json task list one user story at a time. Each iteration gets clean context, with memory limited to git commits, an append-only progress.txt, and the JSON task list itself. When all stories pass quality checks, it prints <promise>COMPLETE</promise> and exits.

The interesting bit

The project treats context-window amnesia as a feature, not a bug. By deliberately resetting the AI every story, Ralph avoids the slow drift that turns long sessions into spaghetti. The real cleverness is in the feedback loops: typechecks, tests, and browser verification (for UI stories) gate each commit, so bad code doesn’t compound across iterations. It also auto-updates AGENTS.md files with discovered patterns, meaning future loops—and human developers—inherit the lore.

Key highlights

  • Supports both Amp CLI (default) and Claude Code via --tool flag
  • PRD skills generate markdown requirements, then convert them to structured prd.json
  • Auto-archives previous runs by branchName to archive/YYYY-MM-DD-feature-name/
  • Interactive flowchart visualizes the entire loop (source in flowchart/)
  • Available as Claude Code marketplace plugin: /plugin marketplace add snarktank/ralph

Caveats

  • Requires jq and an authenticated AI tool; setup is manual file copying or global skill installation
  • The README warns that tasks must fit one context window—“Build the entire dashboard” will fail
  • No built-in retry or backoff logic mentioned; max iterations is a hard cap

Verdict

Worth a look if you’re already using Amp or Claude Code and want guardrails for autonomous coding. Skip it if you need a fully managed agent platform—this is glue code with opinions, not a product.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.