# How Ralph Tracks and Switches Between Feature Branches During Execution

> Learn how Ralph tracks and switches feature branches during execution by comparing prd.json with .last-branch, archiving old states, and updating the tracker automatically.

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

---

**Ralph tracks feature branches by comparing the `branchName` field in [`prd.json`](https://github.com/snarktank/ralph/blob/main/prd.json) against a persisted `.last-branch` file; when they differ, it archives the previous run's state to a timestamped `archive/` directory before updating the tracker.**

In the `snarktank/ralph` repository, branch management is handled entirely within the driver script [`ralph.sh`](https://github.com/snarktank/ralph/blob/main/ralph.sh) through a simple state persistence mechanism. This ensures that when you switch between feature branches—such as moving from `ralph/auth-refactor` to `ralph/ui-cleanup`—