ralph is auto-research for software developers. Where autoresearch loops an agent over an open-ended research problem, ralph loops an agent over a fixed backlog of user stories — it’s suited to non-exploratory tasks where the goal (e.g. a set of user stories) is already defined and the acceptance criteria are already determined.
The loop
In the root directory you have three files:
| |
You ask your agent to build these, then run the loop:
| |
What’s inside ralph.sh
At its core it’s just a bash loop that runs your agent up to MAX_ITERATIONS times:
| |
The max iteration count (10, in this example) is fixed in the .sh file, whereas autoresearch
uses phrases like NEVER STOP or LOOP FOREVER inside the .md prompt itself. That’s a
subtle but important change: bounding the loop in the shell script rather than the prompt
makes it deterministic. Conceptually the two are the same idea, but the nature of the task —
software development versus open-ended research — pushes the looping mechanics in slightly
different directions.
What’s inside prompt.md
Again, similar to the experiment loop in autoresearch,
prompt.md is a list of steps the agent should follow each iteration:
- Read the PRD at
prd.json(in the same directory as this file). - Read the progress log at
progress.txt(check the Codebase Patterns section first). - Check you’re on the correct branch from the PRD’s
branchName. If not, check it out or create it frommain. - Pick the highest-priority user story where
passes: false. - Implement that single user story.
- Run quality checks (typecheck, lint, test — whatever the project requires).
- Update
AGENTS.mdfiles if you discover reusable patterns (see below). - If checks pass, commit all changes with the message
feat: [Story ID] - [Story Title]. - Update the PRD to set
passes: truefor the completed story. - Append your progress to
progress.txt.
What’s inside prd.json
prd.json is the list of user stories you want the agent to complete:
| |
Example of prd.json
The passes field is what keeps the agent from redoing work it’s already finished — each
iteration, it just picks the highest-priority story that’s still false. That’s the whole
mechanism.