1---2name: ralph-convert-prd3description: Converts Product Requirements Documents into prd.json format for the Ralph autonomous agent system. Use when preparing PRDs for Ralph execution, breaking down features into atomic user stories, or when the user mentions Ralph, prd.json, or autonomous agent workflows.4---56<objective>7Transform existing Product Requirements Documents into the structured `prd.json` format used by the Ralph autonomous agent system. Each story must be completable in one LLM context window to prevent broken code from context overflow. Each story must include real runtime verification commands.8</objective>910<quick_start>111. Read the user's PRD or feature requirements122. Read SPEC.md if available (for verification environment info)133. Break down into atomic user stories (one context window each)144. Classify each story with `storyType`155. Generate `verificationCommands` with real runtime checks166. Set `blockedBy` dependencies177. Order stories by dependency (schema → backend → UI → dashboard)188. Output valid `tasks/prd.json`19</quick_start>2021<essential_principles>22<principle name="story_size">23**Critical Rule**: Each story must be completable in ONE Ralph iteration (one context window).2425Stories that are too large cause the LLM to run out of context before completion, resulting in broken code.2627**Right-sized stories**:28- Add a database column29- Create a UI component30- Update server actions31- Implement a filter3233**Too large (split these)**:34- Build entire dashboards35- Add authentication systems36- Refactor entire APIs37</principle>3839<principle name="story_ordering">40Stories must execute sequentially without forward dependencies:41421. Schema/database changes432. Server actions and backend logic443. UI components454. Dashboard/summary views4647Never reference something that doesn't exist yet.48</principle>4950<principle name="acceptance_criteria">51Each criterion must be verifiable and specific. Avoid vague language.5253**Good criteria**:54- "Add status column with values: 'pending' | 'in_progress' | 'done'"55- "Filter dropdown includes: All, Active, Completed"56- "Clicking delete shows confirmation dialog"5758**Bad criteria** (too vague):59- "Works correctly"60- "Good UX"61- "Handles edge cases"62</principle>6364<principle name="mandatory_criteria">65Every story MUST include: `"Typecheck passes"`6667UI-focused stories MUST also include: `"Verify in browser using Playwright e2e test"`68</principle>6970<principle name="real_verification">71Every story MUST include `verificationCommands` with real runtime checks — not just static analysis.7273**By storyType:**7475| storyType | Required verification | Example |76|-----------|----------------------|---------|77| `database` | Run migration + query DB to confirm schema | `prisma migrate deploy`, SQL query for new column |78| `backend` | Run tests + curl endpoint with real data | `curl -s http://localhost:3000/api/...` |79| `api` | curl endpoint, check status code and response body | `curl -s -w '%{http_code}' ...` |80| `frontend` | Playwright e2e test that interacts with real UI | `npx playwright test tests/e2e/...` |81| `infra` | Health check, config validation, service startup | `curl -s http://localhost:3000/health` |82| `test` | Run the test suite | `npm test` / `pytest` |8384Static checks (typecheck) are always included as baseline. Runtime validation is **additionally required**.85</principle>86</essential_principles>8788<output_format>89```json90{91 "project": "[Project Name]",92 "branchName": "ralph/[feature-name-kebab-case]",93 "description": "[Feature description]",94 "testCommands": {95 "unit": "npm test",96 "integration": "npm run test:integration",97 "e2e": "npx playwright test",98 "typecheck": "npm run typecheck"99 },100 "userStories": [101 {102 "id": "US-001",103 "title": "[Story title]",104 "description": "As a [user], I want [feature] so that [benefit]",105 "storyType": "database",106 "acceptanceCriteria": [107 "Specific criterion 1",108 "Specific criterion 2",109 "Typecheck passes"110 ],111 "verificationCommands": [112 { "command": "npm run typecheck", "expect": "exit_code:0" },113 { "command": "curl -s http://localhost:3000/api/tasks | jq length", "expect": "not_empty" }114 ],115 "status": "pending",116 "priority": 1,117 "attempts": 0,118 "maxAttempts": 3,119 "notes": "",120 "blockedBy": [],121 "docsToUpdate": ["README.md"],122 "completedAt": null,123 "lastAttemptLog": ""124 }125 ]126}127```128129**Field requirements**:130- `id`: Sequential US-001, US-002, etc.131- `title`: Short, descriptive action132- `description`: User story format (As a... I want... so that...)133- `storyType`: One of `"backend"` | `"frontend"` | `"database"` | `"api"` | `"infra"` | `"test"`134- `acceptanceCriteria`: Array of specific, verifiable criteria135- `verificationCommands`: Array of `{command, expect}` with real runtime checks136- `status`: Always `"pending"` initially137- `priority`: Execution order (1 = first)138- `attempts`: Always `0` initially139- `maxAttempts`: Default `3` (increase for complex stories)140- `notes`: Empty string initially141- `blockedBy`: Array of story IDs that must be `"done"` first142- `docsToUpdate`: Array of file paths to documentation that must be updated when story is done (e.g., `"README.md"`, `"docs/api.md"`, `"CHANGELOG.md"`)143- `completedAt`: Always `null` initially144- `lastAttemptLog`: Empty string initially145146**Expect matchers for verificationCommands:**147- `exit_code:0` — command exits with code 0148- `exit_code:N` — command exits with specific code N149- `contains:STRING` — stdout contains STRING150- `not_empty` — stdout is non-empty151- `matches:REGEX` — stdout matches regex pattern152</output_format>153154<workflow>1551. **Understand the PRD**: Read the full requirements document or feature request1562. **Read SPEC.md**: If available, extract verification environment info (dev server URL, DB type, test runners, commands). Use this to populate the root-level `testCommands` object1573. **Identify components**: List all database changes, backend logic, UI elements1584. **Decompose into stories**: Break each component into atomic, one-iteration tasks1595. **Classify storyType**: Assign `database`, `backend`, `api`, `frontend`, `infra`, or `test` to each story1606. **Order by dependency**: Schema first, then backend, then UI, then dashboards1617. **Set blockedBy**: Each story should list IDs of stories it depends on1628. **Write acceptance criteria**: Make each criterion specific and verifiable1639. **Generate verificationCommands**: Add real runtime checks per storyType (curl, Playwright, DB queries)16410. **Add mandatory criteria**: Ensure every story has "Typecheck passes"16511. **Generate tasks/prd.json**: Output the complete JSON structure to `tasks/prd.json`16612. **Run pre-save checklist**: Verify all requirements before finalizing167</workflow>168169<pre_save_checklist>170Before outputting the final prd.json, verify:171172- [ ] Previous runs archived (if applicable)173- [ ] Each story completable in one iteration174- [ ] Each story has a `storyType` assigned175- [ ] Stories ordered by dependency (no forward references)176- [ ] `blockedBy` dependencies are set correctly177- [ ] All stories include "Typecheck passes" in acceptanceCriteria178- [ ] UI stories include Playwright verification179- [ ] Every story has `verificationCommands` with at least one runtime check180- [ ] Acceptance criteria are verifiable, not vague181- [ ] No story depends on later stories182- [ ] `docsToUpdate` lists relevant docs for each story183- [ ] `status` is `"pending"`, `attempts` is `0`, `maxAttempts` is set184</pre_save_checklist>185186<examples>187<example name="database_story">188```json189{190 "id": "US-001",191 "title": "Add task status column to database",192 "description": "As a developer, I want a status column on tasks so that we can track task progress",193 "storyType": "database",194 "acceptanceCriteria": [195 "Add status column to tasks table with type enum('pending', 'in_progress', 'done')",196 "Default value is 'pending'",197 "Migration runs without errors",198 "Typecheck passes"199 ],200 "verificationCommands": [201 { "command": "npx prisma migrate deploy", "expect": "exit_code:0" },202 { "command": "npx prisma db execute --stdin <<< \"SELECT column_name FROM information_schema.columns WHERE table_name='tasks' AND column_name='status'\"", "expect": "contains:status" },203 { "command": "npm run typecheck", "expect": "exit_code:0" }204 ],205 "status": "pending",206 "priority": 1,207 "attempts": 0,208 "maxAttempts": 3,209 "notes": "",210 "blockedBy": [],211 "docsToUpdate": ["README.md"],212 "completedAt": null,213 "lastAttemptLog": ""214}215```216</example>217218<example name="api_story">219```json220{221 "id": "US-002",222 "title": "Create task CRUD API endpoints",223 "description": "As a developer, I want REST endpoints for tasks so that the frontend can manage tasks",224 "storyType": "api",225 "acceptanceCriteria": [226 "GET /api/tasks returns array of tasks",227 "POST /api/tasks creates a new task and returns 201",228 "PATCH /api/tasks/:id updates task and returns 200",229 "DELETE /api/tasks/:id removes task and returns 204",230 "Typecheck passes"231 ],232 "verificationCommands": [233 { "command": "npm run typecheck", "expect": "exit_code:0" },234 { "command": "npm test -- --grep 'tasks API'", "expect": "exit_code:0" },235 { "command": "curl -s -o /dev/null -w '%{http_code}' http://localhost:3000/api/tasks", "expect": "contains:200" },236 { "command": "curl -s -X POST http://localhost:3000/api/tasks -H 'Content-Type: application/json' -d '{\"title\":\"test task\"}' -o /dev/null -w '%{http_code}'", "expect": "contains:201" }237 ],238 "status": "pending",239 "priority": 2,240 "attempts": 0,241 "maxAttempts": 3,242 "notes": "",243 "blockedBy": ["US-001"],244 "docsToUpdate": ["README.md", "docs/api.md"],245 "completedAt": null,246 "lastAttemptLog": ""247}248```249</example>250251<example name="ui_story">252```json253{254 "id": "US-003",255 "title": "Add status filter dropdown to task list",256 "description": "As a user, I want to filter tasks by status so that I can focus on relevant tasks",257 "storyType": "frontend",258 "acceptanceCriteria": [259 "Filter dropdown appears above task list",260 "Options: All, Pending, In Progress, Done",261 "Selecting option filters displayed tasks",262 "Filter persists on page refresh",263 "Typecheck passes",264 "Verify in browser using Playwright e2e test"265 ],266 "verificationCommands": [267 { "command": "npm run typecheck", "expect": "exit_code:0" },268 { "command": "npx playwright test tests/e2e/task-filter.spec.ts", "expect": "exit_code:0" }269 ],270 "status": "pending",271 "priority": 3,272 "attempts": 0,273 "maxAttempts": 3,274 "notes": "",275 "blockedBy": ["US-002"],276 "docsToUpdate": ["README.md"],277 "completedAt": null,278 "lastAttemptLog": ""279}280```281</example>282</examples>283284<success_criteria>285Conversion is complete when:286287- [ ] All features from PRD are captured as user stories288- [ ] Each story is atomic (one context window)289- [ ] Each story has a `storyType` assigned290- [ ] Stories are properly ordered by dependency with `blockedBy` set291- [ ] All acceptance criteria are specific and verifiable292- [ ] Mandatory criteria ("Typecheck passes") present on all stories293- [ ] Every story has `verificationCommands` with real runtime checks294- [ ] UI stories include Playwright verification295- [ ] Valid JSON structure with all required fields296- [ ] Pre-save checklist passes297</success_criteria>298299---300> Converted and distributed by [TomeVault](https://tomevault.io/claim/cfircoo) — claim your Tome and manage your conversions.301<!-- tomevault:4.0:skill_md:2026-04-11 -->