- spec-interview → Gather comprehensive requirements through guided discovery
- generate-prd → Create actionable Product Requirements Document
- ralph-convert-prd → Transform PRD into atomic user stories (prd.json)
- Subagent execution → Spawn ralph-coder/ralph-tester subagents via Task tool
This skill coordinates these tools while keeping you in control at decision points.
ALL code implementation MUST happen through subagents — ralph-coder implements production code, ralph-tester writes tests and verifies. You are the orchestrator, NOT the implementer. Do not write code, create files, modify source files, or make any project changes directly.
If you catch yourself about to write code or modify project files: STOP. Spawn a subagent instead.
Do NOT try to fix issues yourself, retry automatically, or continue past errors. Present the error clearly to the user and wait for their instructions.
This maximizes throughput while maintaining correct dependency ordering.
Separation gives each agent a focused context window. The orchestrator wraps ANY agent with Ralph context (story spec, return format, constraints) so even non-Ralph agents integrate seamlessly.
This lets users configure best-practice agents for their stack, and Ralph automatically uses them.
Both agents also update the docs/ folder with documentation about new features, APIs, test setup, and architecture changes. The tasks/test-log.md and tasks/review-notes.md files are updated by tester agents with test registries and improvement recommendations.
Never assume agents "remember" previous stories — but they CAN read shared knowledge files.
Right-sized:
- Add a database column
- Create a UI component
- Update a server action
- Implement a filter
Too large (will fail):
- Build entire dashboard
- Add authentication system
- Refactor entire API
- API stories: curl endpoints with real data, check response codes and bodies
- UI stories: Playwright e2e tests that navigate and interact with real UI
- Database stories: Run migrations, query DB directly to confirm schema
- Infra stories: Health checks, config validation, service startup
Static checks (typecheck, lint) are baseline. Runtime validation is required.
After each story, the tester runs ALL existing tests (via testCommands in prd.json root) to catch regressions. A story is NOT done until the entire test suite passes.
Stories track attempts / maxAttempts to prevent infinite retries on broken stories.
Don't rush. Bad requirements = wasted iterations.
Expect matchers for verificationCommands:
exit_code:0 — command exits with code 0
exit_code:N — command exits with specific code N
contains:STRING — stdout contains STRING
not_empty — stdout is non-empty
matches:REGEX — stdout matches regex pattern
- Full pipeline - Start from scratch (spec → PRD → prd.json → execute)
- Continue from PRD - Already have PRD, convert and execute
- Execute only - Already have prd.json, run Ralph
- Check status - View current prd.json progress
Wait for response before proceeding.
After reading the workflow, follow it exactly.
Key Files:
| File |
Purpose |
| SPEC.md |
Comprehensive requirements from spec-interview |
| tasks/prd-*.md |
Product Requirements Document |
| tasks/prd.json |
Atomic user stories for Ralph |
| tasks/progress.txt |
Learnings between iterations |
| tasks/test-log.md |
Registry of all tests created per story (updated by tester agents) |
| tasks/review-notes.md |
Improvement recommendations after each story (updated by tester agents) |
| tasks/common_knowledge.md |
Shared knowledge base — patterns, conventions, gotchas discovered across stories (updated by both coder and tester agents, read by orchestrator between batches) |
| docs/ |
Project documentation — updated by both coder and tester agents with new features, APIs, test setup, etc. |
Agents:
| Agent |
Role |
Fallback |
| ralph-coder |
Implements production code + docs for one story |
Default coder when no project-specific agent matches |
| ralph-tester |
Writes tests + runs verification for one story |
Default tester when no project-specific agent matches |
| Project agents |
Discovered from .claude/agents/ and ~/.claude/agents/ |
Matched to storyTypes by description keywords |
Execution model:
BATCH 1 (independent stories):
Phase 1: Task(coder, US-001, worktree) + Task(coder, US-005, worktree) ← parallel
Phase 2: Task(tester, US-001) + Task(tester, US-005) ← parallel
Merge: US-001 → main, US-005 → main ← sequential
BATCH 2 (stories that depended on BATCH 1):
Phase 1: Task(coder, US-002, worktree) + Task(coder, US-003, worktree)
Phase 2: Task(tester, US-002) + Task(tester, US-003)
Merge: US-002 → main, US-003 → main
Commands:
# Check story status
cat tasks/prd.json | jq '.userStories[] | {id, title, status, attempts}'
# View learnings
cat tasks/progress.txt
# View test registry
cat tasks/test-log.md
# View review notes
cat tasks/review-notes.md
1---2name: ralph-orchestrator3description: Orchestrates the full Ralph autonomous agent pipeline from requirements gathering to execution. Use when building new features, platforms, or complex tasks that need structured development through spec-interview, PRD generation, and autonomous implementation.4---5
6<objective>
7Orchestrate the complete Ralph pipeline for autonomous feature development:
8
91. **spec-interview** → Gather comprehensive requirements through guided discovery
102. **generate-prd** → Create actionable Product Requirements Document
113. **ralph-convert-prd** → Transform PRD into atomic user stories (prd.json)
124. **Subagent execution** → Spawn ralph-coder/ralph-tester subagents via Task tool
13
14This skill coordinates these tools while keeping you in control at decision points.
15</objective>
16
17<essential_principles>
18
19<principle name="CRITICAL_never_implement_directly">
20**NEVER implement user stories yourself.** The orchestrator's ONLY job is to:
211. Run spec-interview, generate-prd, ralph-convert-prd skills
222. Spawn ralph-coder and ralph-tester subagents via the Task tool to execute stories
233. Manage prd.json state, git operations (commit/merge), and progress tracking
24
25**ALL code implementation MUST happen through subagents** — ralph-coder implements production code, ralph-tester writes tests and verifies. You are the orchestrator, NOT the implementer. Do not write code, create files, modify source files, or make any project changes directly.
26
27If you catch yourself about to write code or modify project files: **STOP. Spawn a subagent instead.**
28</principle>
29
30<principle name="CRITICAL_stop_on_errors">
31**STOP and ask the user for instructions** whenever:
32- A subagent returns a failed result
33- A pre-execution check fails (invalid prd.json, missing files, dirty git state)
34- A merge conflict occurs during worktree merge
35- Any unexpected error occurs during the pipeline
36- You are unsure about any decision
37
38**Do NOT** try to fix issues yourself, retry automatically, or continue past errors. Present the error clearly to the user and wait for their instructions.
39</principle>
40
41<principle name="parallel_batch_execution">
42Stories with no dependencies between them run in parallel. The orchestrator:
431. Groups independent stories into batches
442. Spawns multiple ralph-coder subagents simultaneously (each in its own worktree)
453. After coders complete, spawns ralph-tester subagents in parallel (in the same worktrees)
464. Merges successful worktree branches to main sequentially
475. Updates prd.json and moves to the next batch
48
49This maximizes throughput while maintaining correct dependency ordering.
50</principle>
51
52<principle name="two_phase_pipeline">
53Each story goes through a two-phase pipeline:
54- **Phase 1: Code** — ralph-coder (or matched project agent) implements production code + docs
55- **Phase 2: Test** — ralph-tester (or matched project agent) writes tests + runs verification
56
57Separation gives each agent a focused context window. The orchestrator wraps ANY agent with Ralph context (story spec, return format, constraints) so even non-Ralph agents integrate seamlessly.
58</principle>
59
60<principle name="orchestrator_owns_state">
61**The orchestrator owns all state:**
62- **prd.json** — only the orchestrator reads/writes story status. Agents return JSON results, orchestrator updates prd.json. This prevents race conditions during parallel execution.
63- **Git operations** — only the orchestrator commits and merges. Neither coder nor tester commits. Orchestrator commits only after tester confirms all verification passes.
64- **Worktree lifecycle** — orchestrator creates worktrees (via Task isolation), merges branches, and manages cleanup.
65</principle>
66
67<principle name="agent_discovery">
68The orchestrator **prefers existing project/user agents** over defaults. At startup:
691. Scan `.claude/agents/*.md` and `~/.claude/agents/*.md`
702. Match agents to storyTypes by description keywords
713. Fall back to ralph-coder/ralph-tester when no better match exists
72
73This lets users configure best-practice agents for their stack, and Ralph automatically uses them.
74</principle>
75
76<principle name="shared_knowledge">
77Both coder and tester agents update `tasks/common_knowledge.md` with patterns, conventions, gotchas, and architectural decisions they discover. The orchestrator reads this file between batches to:
78- Pass accumulated knowledge to subsequent subagent prompts
79- Detect actionable discoveries (e.g., manual steps needed, environment issues)
80- Make informed routing decisions for upcoming stories
81
82Both agents also update the `docs/` folder with documentation about new features, APIs, test setup, and architecture changes. The `tasks/test-log.md` and `tasks/review-notes.md` files are updated by tester agents with test registries and improvement recommendations.
83</principle>
84
85<principle name="fresh_context_per_story">
86Each subagent runs with a fresh context for each story. Memory persists only through:
87- Git history (committed code in worktrees)
88- tasks/progress.txt (learnings between iterations)
89- tasks/prd.json (story status tracking)
90- tasks/common_knowledge.md (shared patterns and conventions across stories)
91- tasks/test-log.md (test registry across stories)
92- tasks/review-notes.md (improvement recommendations across stories)
93
94**Never assume agents "remember" previous stories — but they CAN read shared knowledge files.**
95</principle>
96
97<principle name="atomic_stories">
98Each user story MUST be completable in ONE context window.
99
100**Right-sized:**
101- Add a database column
102- Create a UI component
103- Update a server action
104- Implement a filter
105
106**Too large (will fail):**
107- Build entire dashboard
108- Add authentication system
109- Refactor entire API
110</principle>
111
112<principle name="real_verification">
113Every story must be verified with **real runtime checks** — not just that it compiles.
114
115- **API stories**: curl endpoints with real data, check response codes and bodies
116- **UI stories**: Playwright e2e tests that navigate and interact with real UI
117- **Database stories**: Run migrations, query DB directly to confirm schema
118- **Infra stories**: Health checks, config validation, service startup
119
120Static checks (typecheck, lint) are baseline. Runtime validation is required.
121</principle>
122
123<principle name="quality_gates">
124All checks must pass before the orchestrator commits:
125- Story-specific verification commands pass (real runtime checks)
126- **Full test suite passes** (unit + integration + e2e) — no regressions allowed
127- TypeCheck passes
128- UI verified via Playwright (for frontend stories)
129
130After each story, the tester runs ALL existing tests (via `testCommands` in prd.json root) to catch regressions. A story is NOT done until the entire test suite passes.
131</principle>
132
133<principle name="status_tracking">
134Stories use structured status tracking:
135- `"pending"` → not started
136- `"in_progress"` → being worked on by subagents
137- `"done"` → verified, committed, and merged to main
138- `"failed"` → attempted but verification failed
139- `"blocked"` → dependencies not met
140
141Stories track `attempts` / `maxAttempts` to prevent infinite retries on broken stories.
142</principle>
143
144<principle name="user_control_points">
145You approve at each stage:
1461. After spec-interview → Review SPEC.md
1472. After generate-prd → Review PRD
1483. After ralph-convert-prd → Review prd.json stories
1494. Before execution → Confirm ready to execute
1505. Between batches → View progress (if issues arise)
151
152Don't rush. Bad requirements = wasted iterations.
153</principle>
154
155</essential_principles>
156
157<prd_json_schema>
158```json
159{
160 "project": "[Project Name]",
161 "branchName": "ralph/[feature-name-kebab-case]",
162 "description": "[Feature description]",
163 "testCommands": {
164 "unit": "npm test",
165 "integration": "npm run test:integration",
166 "e2e": "npx playwright test",
167 "typecheck": "npm run typecheck"
168 },
169 "userStories": [
170 {
171 "id": "US-001",
172 "title": "[Story title]",
173 "description": "As a [user], I want [feature] so that [benefit]",
174 "storyType": "backend | frontend | database | api | infra | test",
175 "acceptanceCriteria": ["Specific criterion 1", "Typecheck passes"],
176 "verificationCommands": [
177 { "command": "npm run typecheck", "expect": "exit_code:0" },
178 { "command": "curl -s http://localhost:3000/api/...", "expect": "contains:expected" }
179 ],
180 "status": "pending",
181 "priority": 1,
182 "attempts": 0,
183 "maxAttempts": 3,
184 "notes": "",
185 "blockedBy": [],
186 "docsToUpdate": ["README.md", "docs/api.md"],
187 "completedAt": null,
188 "lastAttemptLog": ""
189 }
190 ]
191}
192```
193
194**Expect matchers for verificationCommands:**
195- `exit_code:0` — command exits with code 0
196- `exit_code:N` — command exits with specific code N
197- `contains:STRING` — stdout contains STRING
198- `not_empty` — stdout is non-empty
199- `matches:REGEX` — stdout matches regex pattern
200</prd_json_schema>
201
202<intake>
203What would you like to do?
204
2051. **Full pipeline** - Start from scratch (spec → PRD → prd.json → execute)
2062. **Continue from PRD** - Already have PRD, convert and execute
2073. **Execute only** - Already have prd.json, run Ralph
2084. **Check status** - View current prd.json progress
209
210**Wait for response before proceeding.**
211</intake>
212
213<routing>
214| Response | Workflow |
215|----------|----------|
216| 1, "full", "start", "new feature" | `workflows/full-pipeline.md` |
217| 2, "continue", "have PRD", "convert" | `workflows/from-prd.md` |
218| 3, "execute", "run ralph", "have prd.json" | `workflows/execute-only.md` |
219| 4, "status", "check", "progress" | `workflows/check-status.md` |
220
221**After reading the workflow, follow it exactly.**
222</routing>
223
224<quick_reference>
225
226**Key Files:**
227| File | Purpose |
228|------|---------|
229| SPEC.md | Comprehensive requirements from spec-interview |
230| tasks/prd-*.md | Product Requirements Document |
231| tasks/prd.json | Atomic user stories for Ralph |
232| tasks/progress.txt | Learnings between iterations |
233| tasks/test-log.md | Registry of all tests created per story (updated by tester agents) |
234| tasks/review-notes.md | Improvement recommendations after each story (updated by tester agents) |
235| tasks/common_knowledge.md | Shared knowledge base — patterns, conventions, gotchas discovered across stories (updated by both coder and tester agents, read by orchestrator between batches) |
236| docs/ | Project documentation — updated by both coder and tester agents with new features, APIs, test setup, etc. |
237
238**Agents:**
239| Agent | Role | Fallback |
240|-------|------|----------|
241| ralph-coder | Implements production code + docs for one story | Default coder when no project-specific agent matches |
242| ralph-tester | Writes tests + runs verification for one story | Default tester when no project-specific agent matches |
243| Project agents | Discovered from .claude/agents/ and ~/.claude/agents/ | Matched to storyTypes by description keywords |
244
245**Execution model:**
246```
247BATCH 1 (independent stories):
248 Phase 1: Task(coder, US-001, worktree) + Task(coder, US-005, worktree) ← parallel
249 Phase 2: Task(tester, US-001) + Task(tester, US-005) ← parallel
250 Merge: US-001 → main, US-005 → main ← sequential
251
252BATCH 2 (stories that depended on BATCH 1):
253 Phase 1: Task(coder, US-002, worktree) + Task(coder, US-003, worktree)
254 Phase 2: Task(tester, US-002) + Task(tester, US-003)
255 Merge: US-002 → main, US-003 → main
256```
257
258**Commands:**
259```bash
260# Check story status
261cat tasks/prd.json | jq '.userStories[] | {id, title, status, attempts}'
262
263# View learnings
264cat tasks/progress.txt
265
266# View test registry
267cat tasks/test-log.md
268
269# View review notes
270cat tasks/review-notes.md
271```
272
273</quick_reference>
274
275<workflows_index>
276| Workflow | Purpose |
277|----------|---------|
278| full-pipeline.md | Complete flow: spec → PRD → prd.json → execute |
279| from-prd.md | Convert existing PRD and execute |
280| execute-only.md | Run Ralph on existing prd.json |
281| check-status.md | View current progress |
282</workflows_index>
283
284<success_criteria>
285Pipeline is complete when:
286- [ ] Requirements gathered through spec-interview (including verification environment)
287- [ ] PRD created with verifiable acceptance criteria
288- [ ] prd.json has atomic stories with storyType, verificationCommands, and blockedBy
289- [ ] All stories have `status: "done"` in prd.json
290- [ ] All verification commands passed (real runtime checks, not just typecheck)
291- [ ] Code committed and merged to main via worktree branches
292</success_criteria>