# How Ralph Automatically Detects Branch Changes and Archives Previous Runs

> Discover how Ralph automatically detects branch changes by comparing prd.json to a cached value. It archives previous runs to timestamped folders when changes are identified.

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

---

**Ralph detects branch changes by comparing the current `branchName` value in [`prd.json`](https://github.com/snarktank/ralph/blob/main/prd.json) against a cached value stored in `.last-branch`, and automatically archives the previous run's artifacts to a timestamped folder when they differ.**

Ralph, an open-source feature development workflow tool maintained in the `snarktank/ralph` repository, preserves your work history through an intelligent state-tracking mechanism. The system continuously monitors your Product Requirements Document (PRD) to detect when you begin work on a new feature branch, triggering an archival process that safeguards your progress before