Convert a PRD markdown file to prd.json and set up Ralph loop infrastructure for autonomous development with feature branches and optional scaffold skills.
Convert a PRD markdown file to prd.json and set up Ralph loop infrastructure for autonomous development with feature branches and optional scaffold skills.
argument-hint
<prd-file.md> [--setup]
Purpose
Convert a Product Requirements Document (PRD) in markdown to structured prd.json for Ralph loop execution. Sets up autonomous development with:
Feature branches from main (independent PRs, no cascading conflicts)
Optional scaffold skills (e.g., /mern-add-feature before implementation)
Detailed commit messages and PRs (full story context)
Arguments
<prd-file> — Path to PRD markdown file (e.g., docs/PRD.md)
--setup — Also copy template files (ralph.sh, CLAUDE.md, etc.)
Output
Creates scripts/ralph/ with:
File
Purpose
prd.json
User stories with status, scaffold skills, acceptance criteria
CLAUDE.md
Prompt for each iteration
ralph.sh
Main loop script (autonomous, auto-merge between stories)
ralph-once.sh
Single iteration (human-in-the-loop)
progress.txt
Progress log
Git Workflow: Feature Branches from Main
All PRs Target Main Directly
Every story creates a feature branch from main and a PR back to main:
main ─────┬─────────────────────────────────
│
├── feat/story-001 ──→ PR #1 → main
│
├── feat/story-002 ──→ PR #2 → main
│
└── feat/story-003 ──→ PR #3 → main
Benefits
Benefit
Description
No cascading conflicts
Merging one PR doesn't break others
Independent PRs
Each PR can be reviewed/merged separately
Simple merges
No rebasing or base updates needed
Clear history
Each feature is a single squash commit
Sequential Dependencies
Stories often build on each other (story-002 needs story-001's code). The workflow handles this:
Run ralph-once.sh → story-001 gets PR created
Merge PR #1 (via github-merge-stack or manually)
Run ralph-once.sh → pulls latest main (now has story-001 code)
story-002 implementation has access to story-001's code
In full autonomous mode (ralph.sh), PRs are auto-merged between stories so each iteration starts with all prior code in main.
Scaffold Skills
Stories can specify a scaffoldSkill to run before implementation. This is useful for:
Creating feature structure with /mern-add-feature
Adding authentication with /mern-add-auth
Setting up new modules with /nean-add-feature
prd.json with Scaffold Skill
{"userStories":[{"id":"user-001","title":"Create User CRUD","scaffoldSkill":"mern-add-feature","description":"Implement user management","acceptanceCriteria":["..."],"passes":false}]}
Scaffold Skill Examples
The /ralph skill automatically addsscaffoldSkill to stories matching these patterns. Use the scaffold skill matching the detected stack:
Story Type
MERN
NEAN
iOS
New CRUD feature
mern-add-feature
nean-add-feature
ios-add-feature
Authentication
mern-add-auth
nean-add-auth
ios-add-auth
Bug fix / Refactor / Config
(none)
(none)
(none)
Detailed Commits and PRs
Commit Message Format
feat(story-id): Short title
Description from prd.json
Acceptance Criteria:
- criterion 1
- criterion 2
Files changed (N):
- path/to/file1.ts
- path/to/file2.tsx
Notes: Any notes from prd.json
Story-ID: story-id
PR Body Format
## Story Title
Description from prd.json
### Acceptance Criteria- [x] criterion 1
- [x] criterion 2
### Files Created- path/to/file1.ts
- path/to/file2.tsx
### Notes
Any notes from prd.json
---
**Story ID:**`story-id`**Ralph Iteration:** N
*Generated by Ralph loop*
prd.json Schema
{"projectName":"string","description":"string","userStories":[{"id":"string (kebab-case, e.g., auth-001)","title":"string (short, imperative)","priority":"number (1 = highest)","description":"string (what to implement)","acceptanceCriteria":["string (testable criteria)"],"testCriteria":["string (specific test assertions to write)"],"testFiles":["string (test file paths to create)"],"filesToCreate":["string (expected file paths)"],"scaffoldSkill":"string (optional: mern-add-feature, mern-add-auth, etc.)","notes":"string (optional: hints for implementation)","passes":false}]}
Test Fields (TDD Support)
Field
Purpose
testCriteria
Specific assertions to write (derived from acceptanceCriteria)
testFiles
Test file paths to create BEFORE implementation
Example:
{"id":"layout-001","title":"Create page header","acceptanceCriteria":["Header displays logo","Header includes navigation links"],"testCriteria":["Header renders logo image with correct alt text","Header contains Home, About, Contact links","Navigation links have correct href attributes"],"testFiles":["apps/web/src/components/layout/__tests__/Header.test.tsx"],"filesToCreate":["apps/web/src/components/layout/Header.tsx"]}
Environment Variables
Variable
Default
Purpose
RALPH_MAIN_BRANCH
main
Base branch name
Commands
Single Iteration (Recommended Start)
# Run one story (create PR, stop for review)
./scripts/ralph/ralph-once.sh
# Run one story and auto-merge the PR
./scripts/ralph/ralph-once.sh --merge
# Custom merge timeout (default: 600s)
./scripts/ralph/ralph-once.sh --merge --merge-timeout 900
Full Autonomous Loop
# Run up to 10 stories (auto-merge between each)
./scripts/ralph/ralph.sh
# Custom max iterations
./scripts/ralph/ralph.sh 50
# Create PRs without auto-merging
./scripts/ralph/ralph.sh 50 --no-merge