# What Happens When Max Iterations Is Reached Before All Stories Pass in Ralph?

> Ralph terminates with exit code 1 when max iterations is reached before all stories pass. Learn how it preserves state and what to do next.

- Repository: [Ryan Carson/ralph](https://github.com/snarktank/ralph)
- Tags: internals
- Published: 2026-04-13

---

**When Ralph reaches its configured maximum iteration limit before all user stories pass, the script immediately terminates with exit code 1, prints a diagnostic message referencing progress.txt, and leaves remaining stories unprocessed while preserving the current state in prd.json for subsequent runs.**

Ralph (snarktank/ralph) is an AI-driven development automation tool that spawns bounded loops of AI instances (Amp or Claude Code) to iteratively implement stories from a Product Requirements Document (PRD). Understanding its failure mode when hitting iteration ceilings is critical for CI