@@ -9,84 +9,83 @@ user-invocable: false
99
1010## Goal
1111
12- Transform user requirements into a comprehensive PRD (Product Requirements Document) that preserves all context from prior conversations.
12+ Transform user requirements into a comprehensive PRD that preserves all context from prior conversations.
1313
1414## Core Principle
1515
16- ** Context preservation is the primary goal.** If the user discussed UI layouts, data models, or design decisions before invoking ` /ralph-dev ` , that information MUST be captured in the PRD - not lost.
16+ ** Context preservation is the primary goal.** If the user discussed UI layouts, data models, or design decisions before invoking ` /ralph-dev ` , that information MUST be captured in the PRD.
17+
18+ ---
1719
1820## Workflow
1921
20- ### 1. Extract Context First (CRITICAL)
22+ ### Step 1: Extract Context (CRITICAL - Do This First )
2123
2224Before asking ANY questions, scan the conversation history for:
2325
2426- ** UI/UX** : layouts, wireframes, pages, components, design decisions
2527- ** Data** : entities, models, schemas, fields, relationships
2628- ** API** : endpoints, requests, responses, authentication
2729- ** Flows** : user journeys, processes, interactions
28- - ** Decisions** : choices made, alternatives considered, trade-offs accepted
30+ - ** Decisions** : choices made, alternatives considered, trade-offs
2931
30- Convert discussions into structured formats:
31- - Layout descriptions → ASCII wireframes
32- - Data discussions → TypeScript interfaces
33- - API discussions → Endpoint specifications
34- - Decisions → Decision log with rationale
32+ Convert to structured formats as appropriate (ASCII wireframes, TypeScript interfaces, endpoint specs, decision logs).
3533
36- ### 2. Identify Gaps
34+ ### Step 2: Identify Gaps
3735
38- After extraction, determine what's MISSING:
36+ Determine what's MISSING after extraction :
3937- Tech stack? Scale? Authentication? Deployment?
40- - Only ask about information NOT already discussed
38+ - Only proceed to ask about information NOT already discussed
4139
42- ### 3. Confirm & Ask
40+ ### Step 3: Confirm & Ask Questions
4341
44- If context was extracted:
45- 1 . Show summary of what was extracted
46- 2 . Ask user to confirm accuracy
47- 3 . Only ask questions for gaps
42+ ** If context was extracted:**
43+ 1 . Display summary of extracted context to user
44+ 2 . Use ` AskUserQuestion ` to confirm accuracy
45+ 3 . Only ask additional questions for gaps
4846
49- If no prior context:
47+ ** If no prior context:**
5048- Ask standard clarification questions (app type, tech stack, scale, auth)
5149
52- ** Tool ** : Use ` AskUserQuestion ` with max 4 questions per call, each with ` header ` (≤12 chars), ` multiSelect ` , and 2-4 ` options ` .
50+ ### Step 4: Generate PRD
5351
54- ### 4. Generate PRD
55-
56- Create a comprehensive PRD that includes:
52+ Create PRD with these sections (include only if relevant):
5753
58541 . ** Project Overview** - Goals, scope, constraints
59552 . ** Technical Stack** - Language, frameworks, database, deployment
60- 3 . ** UI/UX Design** - Wireframes, components, design tokens (if discussed)
61- 4 . ** Data Model** - Entities, relationships, schemas (if discussed)
62- 5 . ** API Contracts** - Endpoints, auth, errors (if discussed)
63- 6 . ** User Flows** - Key journeys, edge cases (if discussed)
64- 7 . ** User Stories** - Epics and stories with acceptance criteria
65- 8 . ** Design Decisions** - Choices made with rationale (if discussed)
56+ 3 . ** UI/UX Design** - Wireframes, components, design tokens * (if discussed)*
57+ 4 . ** Data Model** - Entities, relationships, schemas * (if discussed)*
58+ 5 . ** API Contracts** - Endpoints, auth, errors * (if discussed)*
59+ 6 . ** User Flows** - Key journeys, edge cases * (if discussed)*
60+ 7 . ** User Stories** - Epics with acceptance criteria
61+ 8 . ** Design Decisions** - Choices with rationale * (if discussed)*
66629 . ** Non-Functional Requirements** - Performance, security, testing
676310 . ** Appendix: Context Summary** - Key points from conversation
6864
69- ** Note** : Sections 3-6 and 8 are only needed if relevant context was discussed. Don't pad with generic content.
70-
71- ### 5. Save & Transition
65+ ### Step 5: Save PRD
7266
7367``` bash
74- # Backup existing PRD if present
75- # Save to .ralph-dev/prd.md
76- # Update state: ralph-dev state update --phase breakdown
77- ```
68+ mkdir -p .ralph-dev
7869
79- ## Constraints
70+ # REQUIRED: Backup existing PRD before overwriting
71+ if [ -f " .ralph-dev/prd.md" ]; then
72+ BACKUP_TIMESTAMP=$( date +%Y%m%d-%H%M%S)
73+ cp .ralph-dev/prd.md " .ralph-dev/prd.${BACKUP_TIMESTAMP} .bak"
74+ # Keep only last 5 backups
75+ ls -t .ralph-dev/prd.* .bak 2> /dev/null | tail -n +6 | xargs -r rm -f
76+ fi
8077
81- - ** NEVER** lose context from prior discussions
82- - ** NEVER** ask questions about information already provided
83- - ** NEVER** generate generic filler content - only include what's relevant
84- - ** ALWAYS** use ` AskUserQuestion ` tool, not plain text questions
85- - ** ALWAYS** confirm extracted context before proceeding
78+ # Save PRD using Write tool to .ralph-dev/prd.md
79+ ```
80+
81+ ### Step 6: Update State & Return Result
8682
87- ## Output
83+ ``` bash
84+ # REQUIRED: Transition to next phase
85+ ralph-dev state update --phase breakdown
86+ ```
8887
89- Return structured result :
88+ ** REQUIRED Output Format ** (orchestrator parses this) :
9089``` yaml
9190---PHASE RESULT---
9291phase : clarify
@@ -97,10 +96,41 @@ next_phase: breakdown
9796---END PHASE RESULT---
9897```
9998
99+ ---
100+
101+ ## Tool Constraints
102+
103+ ### AskUserQuestion
104+
105+ - ** Max 4 questions** per tool call
106+ - Each question requires:
107+ - ` question ` : The question text
108+ - ` header ` : Short label (≤12 chars), e.g., "App Type", "Tech Stack"
109+ - ` multiSelect ` : true/false
110+ - ` options ` : 2-4 choices, each with ` label ` and ` description `
111+ - Add "(Recommended)" suffix to suggested default option
112+ - "Other" option is auto-provided by Claude Code
113+ - ** 60-second timeout** - keep questions simple
114+
115+ ---
116+
117+ ## Constraints
118+
119+ - ** NEVER** lose context from prior discussions
120+ - ** NEVER** ask questions about information already provided
121+ - ** NEVER** generate generic filler content - only include relevant sections
122+ - ** NEVER** ask questions in plain text - always use ` AskUserQuestion ` tool
123+ - ** ALWAYS** backup existing PRD before overwriting
124+ - ** ALWAYS** update state via CLI after completion
125+ - ** ALWAYS** return structured PHASE RESULT block
126+
127+ ---
128+
100129## Error Handling
101130
102131| Error | Action |
103132| -------| --------|
104- | User cancels | Save partial state, return status: cancelled |
105- | Context extraction unclear | Ask user to clarify specific points |
106- | PRD generation fails | Use minimal viable PRD with available info |
133+ | User cancels | Save partial state, return ` status: cancelled ` |
134+ | Context unclear | Ask user to clarify specific points |
135+ | PRD generation fails | Use minimal PRD with available info |
136+ | State update fails | Log error, retry once, then report to orchestrator |
0 commit comments