Run one Better Ralph iteration: PRD-driven autonomous coding. Read prd.json, pick next story, implement it, run checks, commit, mark story passed, append progress. Uses only standard OpenClaw tools (read, write, exec, git). Triggers on: run better ralph, better ralph iteration, do one ralph story, next prd story, ralph loop.
Execute one iteration of the Better Ralph workflow: pick the next PRD story, implement it, run quality checks, commit, update the PRD, and append progress. Uses only standard tools (read_file, write_file, edit, exec, git). No external runner or Aether-Claw required.
prd.json in the workspace root (see Output Format below for schema).Do these steps in order. Use only your standard file, exec, and git tools.
prd.json (workspace root). Parse the JSON.progress.txt## Codebase Patterns##prd.json.userStories, find all with passes === false.priority ascending (lower number = higher priority).passes === true, reply: "All PRD stories are complete. Nothing left to do." and stop.git branch --show-current or use your git tool).prd.json has a branchName and it differs from the current branch, checkout or create that branch (e.g. git checkout -b <branchName> or git checkout <branchName>).id, title, description, acceptanceCriteria, priority, passes.acceptanceCriteria is satisfied.npm test, npm run lint, npm run typecheck, or whatever the project uses).prd.json or progress.txt for a failed story.git add -A or your git tool’s equivalent).feat: [Story ID] - [Story Title]feat: US-002 - Display priority on task cardsprd.json again (in case it changed).id you just completed. Set its passes to true.prd.json back (preserve structure and other fields; only change that story’s passes).progress.txt with this format:## [Current date/time] - [Story ID]
- What was implemented (1–2 sentences)
- Files changed (list paths)
- **Learnings for future iterations:**
- Patterns or gotchas (e.g. "this codebase uses X for Y", "remember to update Z when changing W")
---
progress.txt does not exist, create it with a first line like # Better Ralph Progress then the block above.passes === false, say: "Run another iteration to do the next story." If all are complete, say: "All PRD stories are complete."If the user wants to create a new prd.json (no file yet), create it with this shape:
{
"project": "ProjectName",
"branchName": "ralph/feature-kebab-case",
"description": "Short feature description",
"userStories": [
{
"id": "US-001",
"title": "Short title",
"description": "As a [role], I want [thing] so that [benefit].",
"acceptanceCriteria": [
"Verifiable criterion 1",
"Verifiable criterion 2",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": ""
}
]
}
false; set to true only after the story is implemented and committed.Optionally keep a Codebase Patterns section at the top of progress.txt so future iterations (or you in the next run) see it first:
# Better Ralph Progress
## Codebase Patterns
- Use X for Y in this codebase
- Always run Z after changing W
- Tests require PORT=3000
---
When you read progress.txt at the start of an iteration, use this section as context. When you discover a reusable pattern, add it here (edit the top of the file and keep the rest intact). Do not put story-specific details in Codebase Patterns.
feat: [ID] - [Title]