ccsetup 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -24
- package/bin/create-project.js +373 -773
- package/lib/templates/README.md +2 -2
- package/lib/templates/metadata/agents.json +1 -1
- package/package.json +3 -2
- package/template/.claude/settings.json +18 -1
- package/template/.claude/skills/codex-review/SKILL.md +139 -0
- package/template/.claude/skills/secops/SKILL.md +259 -0
- package/template/.codex/skills/codex-review/SKILL.md +139 -0
- package/template/.codex/skills/prd/SKILL.md +343 -0
- package/template/.codex/skills/ralph/SKILL.md +339 -0
- package/template/AGENTS.md +43 -0
- package/template/CLAUDE.md +106 -4
- package/template/docs/codex-setup.md +32 -0
- package/template/hooks/codex-review/index.js +105 -0
- package/template/scripts/codex-review/codex-review.sh +266 -0
- package/template/scripts/ralph/CODEX.md +76 -0
- package/template/scripts/ralph/ralph.sh +32 -9
- package/bin/lib/contextGenerator.js +0 -287
- package/bin/lib/scanner/index.js +0 -28
- package/bin/scan.js +0 -367
- package/lib/aiMergeHelper.js +0 -112
- package/lib/contextGenerator.js +0 -574
- package/lib/contextMerger.js +0 -812
- package/lib/progressReporter.js +0 -88
- package/lib/scanConfig.js +0 -200
- package/lib/scanner/fileAnalyzer.js +0 -605
- package/lib/scanner/index.js +0 -164
- package/lib/scanner/patterns.js +0 -277
- package/lib/scanner/projectDetector.js +0 -147
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prd
|
|
3
|
+
description: "Generate a Product Requirements Document (PRD) for a new feature. Use when planning a feature, starting a new project, or when asked to create a PRD. Triggers on: create a prd, write prd for, plan this feature, requirements for, spec out."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PRD Generator
|
|
7
|
+
|
|
8
|
+
Create detailed Product Requirements Documents that are clear, actionable, and grounded in the actual codebase.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## The Job
|
|
13
|
+
|
|
14
|
+
1. **Scan the codebase** to understand tech stack, architecture, and existing patterns
|
|
15
|
+
2. Receive a feature description from the user
|
|
16
|
+
3. Ask 3-5 **codebase-informed** clarifying questions (with lettered options)
|
|
17
|
+
4. Generate a structured PRD that references real files, components, and patterns
|
|
18
|
+
5. Save to `tasks/prd-[feature-name].md`
|
|
19
|
+
|
|
20
|
+
**Important:** Do NOT start implementing. Just create the PRD.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Step 1: Codebase Reconnaissance
|
|
25
|
+
|
|
26
|
+
Before asking the user anything, silently scan the project using Codex tools:
|
|
27
|
+
|
|
28
|
+
### Detect Tech Stack
|
|
29
|
+
Use Glob and Read to find and inspect:
|
|
30
|
+
- `package.json`, `tsconfig.json`, `next.config.*` (Node/TypeScript/Next.js)
|
|
31
|
+
- `requirements.txt`, `pyproject.toml`, `setup.py` (Python)
|
|
32
|
+
- `go.mod` (Go)
|
|
33
|
+
- `Cargo.toml` (Rust)
|
|
34
|
+
- `Gemfile` (Ruby)
|
|
35
|
+
- `composer.json` (PHP)
|
|
36
|
+
|
|
37
|
+
Record: language, framework, package manager, key dependencies.
|
|
38
|
+
|
|
39
|
+
### Detect Quality Checks
|
|
40
|
+
From the config files found above, identify:
|
|
41
|
+
- **Typecheck**: `tsconfig.json` exists → "Typecheck passes"
|
|
42
|
+
- **Linter**: `eslint`, `biome`, `ruff`, `golangci-lint` in deps or config → "Lint passes"
|
|
43
|
+
- **Test framework**: `jest`, `vitest`, `pytest`, `go test` → "Tests pass"
|
|
44
|
+
- **Build**: check `scripts` in package.json for `build`, `check`, etc.
|
|
45
|
+
|
|
46
|
+
These become the **default quality criteria** appended to every user story.
|
|
47
|
+
|
|
48
|
+
### Scan Architecture
|
|
49
|
+
Use Glob to map the project structure:
|
|
50
|
+
- `src/**/*.{ts,tsx,js,jsx,py,go,rs}` — source file layout
|
|
51
|
+
- `**/schema.prisma`, `**/migrations/**`, `**/models/**` — database layer
|
|
52
|
+
- `**/api/**`, `**/routes/**`, `**/app/**/route.*` — API endpoints
|
|
53
|
+
- `**/components/**` — UI components
|
|
54
|
+
- `**/hooks/**`, `**/utils/**`, `**/lib/**` — shared utilities
|
|
55
|
+
|
|
56
|
+
### Read Project Context
|
|
57
|
+
- Read `AGENTS.md` (root and any nested) for project instructions and conventions
|
|
58
|
+
- Read existing PRDs in `tasks/prd-*.md` for format consistency
|
|
59
|
+
- Read `docs/ROADMAP.md` if it exists for current priorities
|
|
60
|
+
|
|
61
|
+
### Build Context Summary
|
|
62
|
+
Compile findings into an internal context block (do not show to user):
|
|
63
|
+
```
|
|
64
|
+
Tech: [framework] + [language] + [key deps]
|
|
65
|
+
Quality: [typecheck] [lint] [test] [build commands]
|
|
66
|
+
DB: [ORM/schema location]
|
|
67
|
+
API: [routing pattern, e.g., "Next.js App Router at app/api/"]
|
|
68
|
+
UI: [component library, e.g., "shadcn/ui in src/components/ui/"]
|
|
69
|
+
Existing patterns: [key files and conventions discovered]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Step 2: Clarifying Questions
|
|
75
|
+
|
|
76
|
+
Ask only critical questions where the initial prompt is ambiguous. **Tailor questions to what you found in the codebase** — don't ask about tech stack if you already know it.
|
|
77
|
+
|
|
78
|
+
Focus on:
|
|
79
|
+
|
|
80
|
+
- **Problem/Goal:** What problem does this solve?
|
|
81
|
+
- **Core Functionality:** What are the key actions?
|
|
82
|
+
- **Scope/Boundaries:** What should it NOT do?
|
|
83
|
+
- **Success Criteria:** How do we know it's done?
|
|
84
|
+
|
|
85
|
+
### Format Questions Like This:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
1. What is the primary goal of this feature?
|
|
89
|
+
A. Improve user onboarding experience
|
|
90
|
+
B. Increase user retention
|
|
91
|
+
C. Reduce support burden
|
|
92
|
+
D. Other: [please specify]
|
|
93
|
+
|
|
94
|
+
2. Who is the target user?
|
|
95
|
+
A. New users only
|
|
96
|
+
B. Existing users only
|
|
97
|
+
C. All users
|
|
98
|
+
D. Admin users only
|
|
99
|
+
|
|
100
|
+
3. What is the scope?
|
|
101
|
+
A. Minimal viable version
|
|
102
|
+
B. Full-featured implementation
|
|
103
|
+
C. Just the backend/API
|
|
104
|
+
D. Just the UI
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This lets users respond with "1A, 2C, 3B" for quick iteration.
|
|
108
|
+
|
|
109
|
+
### Codebase-Informed Questions
|
|
110
|
+
|
|
111
|
+
If your scan revealed relevant context, weave it into the questions:
|
|
112
|
+
|
|
113
|
+
- Found a database schema → "I see you have a `users` table with [fields]. Should this feature extend that table or create a new one?"
|
|
114
|
+
- Found existing components → "You already have a `DataTable` component in `src/components/ui/`. Should this feature reuse it?"
|
|
115
|
+
- Found API patterns → "Your API routes follow [pattern]. Should this feature add new routes under the same structure?"
|
|
116
|
+
|
|
117
|
+
Skip questions the codebase already answers. If the tech stack is clear, don't ask "What framework are you using?"
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Step 3: PRD Structure
|
|
122
|
+
|
|
123
|
+
Generate the PRD with these sections:
|
|
124
|
+
|
|
125
|
+
### 1. Introduction/Overview
|
|
126
|
+
Brief description of the feature and the problem it solves.
|
|
127
|
+
|
|
128
|
+
### 2. Tech Context
|
|
129
|
+
Auto-generated from your codebase scan. Include:
|
|
130
|
+
- **Stack:** Language, framework, key dependencies
|
|
131
|
+
- **Quality gates:** Which checks apply (typecheck, lint, test, build)
|
|
132
|
+
- **Relevant existing code:** File paths and patterns the feature should build on
|
|
133
|
+
|
|
134
|
+
This section helps implementers (human or AI) understand the codebase without re-scanning.
|
|
135
|
+
|
|
136
|
+
### 3. Goals
|
|
137
|
+
Specific, measurable objectives (bullet list).
|
|
138
|
+
|
|
139
|
+
### 4. User Stories
|
|
140
|
+
Each story needs:
|
|
141
|
+
- **Title:** Short descriptive name
|
|
142
|
+
- **Description:** "As a [user], I want [feature] so that [benefit]"
|
|
143
|
+
- **Acceptance Criteria:** Verifiable checklist of what "done" means
|
|
144
|
+
|
|
145
|
+
Each story should be small enough to implement in one focused session.
|
|
146
|
+
|
|
147
|
+
**Format:**
|
|
148
|
+
```markdown
|
|
149
|
+
### US-001: [Title]
|
|
150
|
+
**Description:** As a [user], I want [feature] so that [benefit].
|
|
151
|
+
|
|
152
|
+
**Acceptance Criteria:**
|
|
153
|
+
- [ ] Specific verifiable criterion
|
|
154
|
+
- [ ] Another criterion
|
|
155
|
+
- [ ] {auto-detected quality checks from Step 1}
|
|
156
|
+
- [ ] **[UI stories only]** Verify in browser using dev-browser skill
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Important:**
|
|
160
|
+
- Acceptance criteria must be verifiable, not vague. "Works correctly" is bad. "Button shows confirmation dialog before deleting" is good.
|
|
161
|
+
- **For any story with UI changes:** Always include "Verify in browser using dev-browser skill" as acceptance criteria.
|
|
162
|
+
- **Quality criteria are auto-appended** based on Step 1 detection. Do not hardcode "Typecheck passes" — use whatever the project actually has.
|
|
163
|
+
- **Reference real file paths** when a story modifies or extends existing code (e.g., "Add column to schema in `prisma/schema.prisma`").
|
|
164
|
+
|
|
165
|
+
### 5. Functional Requirements
|
|
166
|
+
Numbered list of specific functionalities:
|
|
167
|
+
- "FR-1: The system must allow users to..."
|
|
168
|
+
- "FR-2: When a user clicks X, the system must..."
|
|
169
|
+
|
|
170
|
+
Be explicit and unambiguous.
|
|
171
|
+
|
|
172
|
+
### 6. Non-Goals (Out of Scope)
|
|
173
|
+
What this feature will NOT include. Critical for managing scope.
|
|
174
|
+
|
|
175
|
+
### 7. Design Considerations (Optional)
|
|
176
|
+
- UI/UX requirements
|
|
177
|
+
- Link to mockups if available
|
|
178
|
+
- **Existing components to reuse** (reference actual paths found in scan, e.g., "`src/components/ui/DataTable.tsx`")
|
|
179
|
+
|
|
180
|
+
### 8. Technical Considerations
|
|
181
|
+
- Known constraints or dependencies
|
|
182
|
+
- Integration points with existing systems (reference actual files/modules)
|
|
183
|
+
- Performance requirements
|
|
184
|
+
- **Dependency order:** Which stories must be completed before others (schema → backend → UI)
|
|
185
|
+
|
|
186
|
+
### 9. Success Metrics
|
|
187
|
+
How will success be measured?
|
|
188
|
+
- "Reduce time to complete X by 50%"
|
|
189
|
+
- "Increase conversion rate by 10%"
|
|
190
|
+
|
|
191
|
+
### 10. Open Questions
|
|
192
|
+
Remaining questions or areas needing clarification.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Writing for AI Agents and Junior Developers
|
|
197
|
+
|
|
198
|
+
The PRD reader may be a junior developer or an autonomous AI agent (like Ralph). Therefore:
|
|
199
|
+
|
|
200
|
+
- Be explicit and unambiguous
|
|
201
|
+
- Reference actual file paths, not abstract descriptions
|
|
202
|
+
- Provide enough detail to understand purpose and core logic
|
|
203
|
+
- Number requirements for easy reference
|
|
204
|
+
- Use concrete examples where helpful
|
|
205
|
+
- Include the quality gates the project actually uses, not generic ones
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Output
|
|
210
|
+
|
|
211
|
+
- **Format:** Markdown (`.md`)
|
|
212
|
+
- **Location:** `tasks/`
|
|
213
|
+
- **Filename:** `prd-[feature-name].md` (kebab-case)
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Example PRD
|
|
218
|
+
|
|
219
|
+
```markdown
|
|
220
|
+
# PRD: Task Priority System
|
|
221
|
+
|
|
222
|
+
## Introduction
|
|
223
|
+
|
|
224
|
+
Add priority levels to tasks so users can focus on what matters most. Tasks can be marked as high, medium, or low priority, with visual indicators and filtering to help users manage their workload effectively.
|
|
225
|
+
|
|
226
|
+
## Tech Context
|
|
227
|
+
|
|
228
|
+
- **Stack:** Next.js 14 (App Router) + TypeScript + Tailwind CSS
|
|
229
|
+
- **DB:** Prisma with PostgreSQL (`prisma/schema.prisma`)
|
|
230
|
+
- **UI:** shadcn/ui components in `src/components/ui/`
|
|
231
|
+
- **Quality gates:** Typecheck (`tsc --noEmit`), Lint (`eslint`), Tests (`vitest`)
|
|
232
|
+
- **Relevant code:**
|
|
233
|
+
- Task model: `prisma/schema.prisma` (Task table)
|
|
234
|
+
- Task list component: `src/components/TaskList.tsx`
|
|
235
|
+
- Task card component: `src/components/TaskCard.tsx`
|
|
236
|
+
- Existing badge component: `src/components/ui/Badge.tsx`
|
|
237
|
+
- API routes: `src/app/api/tasks/`
|
|
238
|
+
|
|
239
|
+
## Goals
|
|
240
|
+
|
|
241
|
+
- Allow assigning priority (high/medium/low) to any task
|
|
242
|
+
- Provide clear visual differentiation between priority levels
|
|
243
|
+
- Enable filtering and sorting by priority
|
|
244
|
+
- Default new tasks to medium priority
|
|
245
|
+
|
|
246
|
+
## User Stories
|
|
247
|
+
|
|
248
|
+
### US-001: Add priority field to database
|
|
249
|
+
**Description:** As a developer, I need to store task priority so it persists across sessions.
|
|
250
|
+
|
|
251
|
+
**Acceptance Criteria:**
|
|
252
|
+
- [ ] Add `priority` enum ('high' | 'medium' | 'low', default 'medium') to Task model in `prisma/schema.prisma`
|
|
253
|
+
- [ ] Generate and run migration successfully
|
|
254
|
+
- [ ] Typecheck passes
|
|
255
|
+
- [ ] Lint passes
|
|
256
|
+
|
|
257
|
+
### US-002: Display priority indicator on task cards
|
|
258
|
+
**Description:** As a user, I want to see task priority at a glance so I know what needs attention first.
|
|
259
|
+
|
|
260
|
+
**Acceptance Criteria:**
|
|
261
|
+
- [ ] Extend `src/components/TaskCard.tsx` to show priority using existing `Badge` component from `src/components/ui/Badge.tsx`
|
|
262
|
+
- [ ] Badge colors: red=high, yellow=medium, gray=low
|
|
263
|
+
- [ ] Priority visible without hovering or clicking
|
|
264
|
+
- [ ] Typecheck passes
|
|
265
|
+
- [ ] Lint passes
|
|
266
|
+
- [ ] Verify in browser using dev-browser skill
|
|
267
|
+
|
|
268
|
+
### US-003: Add priority selector to task edit
|
|
269
|
+
**Description:** As a user, I want to change a task's priority when editing it.
|
|
270
|
+
|
|
271
|
+
**Acceptance Criteria:**
|
|
272
|
+
- [ ] Priority dropdown in task edit modal using shadcn `Select` component
|
|
273
|
+
- [ ] Shows current priority as selected
|
|
274
|
+
- [ ] Saves via existing PATCH `/api/tasks/[id]` route
|
|
275
|
+
- [ ] Typecheck passes
|
|
276
|
+
- [ ] Lint passes
|
|
277
|
+
- [ ] Verify in browser using dev-browser skill
|
|
278
|
+
|
|
279
|
+
### US-004: Filter tasks by priority
|
|
280
|
+
**Description:** As a user, I want to filter the task list to see only high-priority items when I'm focused.
|
|
281
|
+
|
|
282
|
+
**Acceptance Criteria:**
|
|
283
|
+
- [ ] Add filter dropdown to `src/components/TaskList.tsx` with options: All | High | Medium | Low
|
|
284
|
+
- [ ] Filter persists in URL search params
|
|
285
|
+
- [ ] Empty state message when no tasks match filter
|
|
286
|
+
- [ ] Typecheck passes
|
|
287
|
+
- [ ] Lint passes
|
|
288
|
+
- [ ] Tests pass
|
|
289
|
+
- [ ] Verify in browser using dev-browser skill
|
|
290
|
+
|
|
291
|
+
## Functional Requirements
|
|
292
|
+
|
|
293
|
+
- FR-1: Add `priority` field to Task model in `prisma/schema.prisma` ('high' | 'medium' | 'low', default 'medium')
|
|
294
|
+
- FR-2: Display colored priority badge on each task card via `Badge` component
|
|
295
|
+
- FR-3: Include priority selector in task edit modal using shadcn `Select`
|
|
296
|
+
- FR-4: Add priority filter dropdown to `TaskList` header
|
|
297
|
+
- FR-5: Sort by priority within each status column (high → medium → low)
|
|
298
|
+
|
|
299
|
+
## Non-Goals
|
|
300
|
+
|
|
301
|
+
- No priority-based notifications or reminders
|
|
302
|
+
- No automatic priority assignment based on due date
|
|
303
|
+
- No priority inheritance for subtasks
|
|
304
|
+
|
|
305
|
+
## Design Considerations
|
|
306
|
+
|
|
307
|
+
- Reuse existing `src/components/ui/Badge.tsx` with color variants
|
|
308
|
+
- Use shadcn `Select` for the filter and edit dropdowns (already in project deps)
|
|
309
|
+
|
|
310
|
+
## Technical Considerations
|
|
311
|
+
|
|
312
|
+
- Filter state managed via URL search params (Next.js `useSearchParams`)
|
|
313
|
+
- Priority stored in database, not computed
|
|
314
|
+
- **Dependency order:** US-001 (schema) → US-002 (display) → US-003 (edit) → US-004 (filter)
|
|
315
|
+
|
|
316
|
+
## Success Metrics
|
|
317
|
+
|
|
318
|
+
- Users can change priority in under 2 clicks
|
|
319
|
+
- High-priority tasks immediately visible at top of lists
|
|
320
|
+
- No regression in task list performance
|
|
321
|
+
|
|
322
|
+
## Open Questions
|
|
323
|
+
|
|
324
|
+
- Should priority affect task ordering within a column?
|
|
325
|
+
- Should we add keyboard shortcuts for priority changes?
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Checklist
|
|
331
|
+
|
|
332
|
+
Before saving the PRD:
|
|
333
|
+
|
|
334
|
+
- [ ] Ran codebase reconnaissance (Step 1)
|
|
335
|
+
- [ ] Tech Context section reflects actual project stack and quality gates
|
|
336
|
+
- [ ] Asked codebase-informed clarifying questions with lettered options
|
|
337
|
+
- [ ] Incorporated user's answers
|
|
338
|
+
- [ ] User stories reference real file paths where applicable
|
|
339
|
+
- [ ] User stories are small and specific (one focused session each)
|
|
340
|
+
- [ ] Quality criteria match what the project actually uses (not hardcoded)
|
|
341
|
+
- [ ] Functional requirements are numbered and unambiguous
|
|
342
|
+
- [ ] Non-goals section defines clear boundaries
|
|
343
|
+
- [ ] Saved to `tasks/prd-[feature-name].md`
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ralph
|
|
3
|
+
description: "Convert PRDs to prd.json format for the Ralph autonomous agent system. Use when you have an existing PRD and need to convert it to Ralph's JSON format. Triggers on: convert this prd, turn this into ralph format, create prd.json from this, ralph json."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ralph PRD Converter
|
|
7
|
+
|
|
8
|
+
Converts existing PRDs to the prd.json format that Ralph uses for autonomous execution. Scans the codebase to populate quality checks, file hints, and story notes automatically.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## The Job
|
|
13
|
+
|
|
14
|
+
1. **Scan the codebase** to detect quality commands and relevant file paths
|
|
15
|
+
2. Read the PRD (markdown file or text) — check for a Tech Context section first
|
|
16
|
+
3. Convert to `scripts/ralph/prd.json` with codebase-informed stories
|
|
17
|
+
4. Initialize `scripts/ralph/progress.txt` if it doesn't exist
|
|
18
|
+
|
|
19
|
+
**Important:** Do NOT start implementing. Just create the prd.json.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Step 1: Codebase Reconnaissance
|
|
24
|
+
|
|
25
|
+
Before converting, silently scan the project using Codex tools.
|
|
26
|
+
|
|
27
|
+
### If PRD has a Tech Context section
|
|
28
|
+
The improved `/prd` skill generates a Tech Context section with stack, quality gates, and relevant file paths. If present, use it directly — no need to re-scan.
|
|
29
|
+
|
|
30
|
+
### If PRD has no Tech Context section
|
|
31
|
+
Scan manually:
|
|
32
|
+
|
|
33
|
+
**Detect quality commands** — Read `package.json` scripts, config files, Makefiles:
|
|
34
|
+
- Look for: `typecheck`, `tsc`, `check-types` → record the exact script (e.g., `npm run typecheck`)
|
|
35
|
+
- Look for: `lint`, `eslint`, `biome check` → record exact script (e.g., `npm run lint`)
|
|
36
|
+
- Look for: `test`, `vitest`, `jest`, `pytest` → record exact script (e.g., `npm test`)
|
|
37
|
+
- Look for: `build` → record exact script (e.g., `npm run build`)
|
|
38
|
+
|
|
39
|
+
**Scan relevant files** — Use Glob to find files related to each user story:
|
|
40
|
+
- Database: `**/schema.prisma`, `**/models/**`, `**/migrations/**`
|
|
41
|
+
- API: `**/api/**`, `**/routes/**`, `**/app/**/route.*`
|
|
42
|
+
- Components: `**/components/**`
|
|
43
|
+
- Utilities: `**/hooks/**`, `**/utils/**`, `**/lib/**`
|
|
44
|
+
|
|
45
|
+
These become `notes` on each story — giving Ralph file-level hints for where to work.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Step 2: Output Format
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"project": "[Project Name]",
|
|
54
|
+
"branchName": "ralph/[feature-name-kebab-case]",
|
|
55
|
+
"description": "[Feature description from PRD title/intro]",
|
|
56
|
+
"qualityChecks": {
|
|
57
|
+
"typecheck": "npm run typecheck",
|
|
58
|
+
"lint": "npm run lint",
|
|
59
|
+
"test": "npm test",
|
|
60
|
+
"build": "npm run build"
|
|
61
|
+
},
|
|
62
|
+
"userStories": [
|
|
63
|
+
{
|
|
64
|
+
"id": "US-001",
|
|
65
|
+
"title": "[Story title]",
|
|
66
|
+
"description": "As a [user], I want [feature] so that [benefit]",
|
|
67
|
+
"acceptanceCriteria": [
|
|
68
|
+
"Criterion 1",
|
|
69
|
+
"Criterion 2",
|
|
70
|
+
"Typecheck passes",
|
|
71
|
+
"Lint passes"
|
|
72
|
+
],
|
|
73
|
+
"priority": 1,
|
|
74
|
+
"passes": false,
|
|
75
|
+
"notes": "Relevant files: prisma/schema.prisma, src/app/api/tasks/route.ts"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### The `qualityChecks` field
|
|
82
|
+
|
|
83
|
+
This is **new and critical**. It tells Ralph the exact commands to run, so each iteration doesn't have to guess. Only include checks that actually exist in the project:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
"qualityChecks": {
|
|
87
|
+
"typecheck": "npm run typecheck",
|
|
88
|
+
"lint": "npm run lint"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If a project has no typecheck, don't include it. If it uses `make check`, use that. Be exact.
|
|
93
|
+
|
|
94
|
+
### The `notes` field
|
|
95
|
+
|
|
96
|
+
Pre-populate with **file hints** from your codebase scan — relevant files the story will likely touch or extend:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
"notes": "Relevant files: prisma/schema.prisma (Task model), src/components/TaskCard.tsx (extend with badge)"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This gives each Ralph iteration a head start instead of scanning the codebase from scratch.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Story Size: The Number One Rule
|
|
107
|
+
|
|
108
|
+
**Each story must be completable in ONE Ralph iteration (one context window).**
|
|
109
|
+
|
|
110
|
+
Ralph spawns a fresh instance per iteration with no memory of previous work. If a story is too big, the LLM runs out of context before finishing and produces broken code.
|
|
111
|
+
|
|
112
|
+
### Right-sized stories:
|
|
113
|
+
- Add a database column and migration
|
|
114
|
+
- Add a UI component to an existing page
|
|
115
|
+
- Update a server action with new logic
|
|
116
|
+
- Add a filter dropdown to a list
|
|
117
|
+
|
|
118
|
+
### Too big (split these):
|
|
119
|
+
- "Build the entire dashboard" — Split into: schema, queries, UI components, filters
|
|
120
|
+
- "Add authentication" — Split into: schema, middleware, login UI, session handling
|
|
121
|
+
- "Refactor the API" — Split into one story per endpoint or pattern
|
|
122
|
+
|
|
123
|
+
**Rule of thumb:** If you cannot describe the change in 2-3 sentences, it is too big.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Story Ordering: Dependencies First
|
|
128
|
+
|
|
129
|
+
Stories execute in priority order. Earlier stories must not depend on later ones.
|
|
130
|
+
|
|
131
|
+
**Correct order:**
|
|
132
|
+
1. Schema/database changes (migrations)
|
|
133
|
+
2. Server actions / backend logic
|
|
134
|
+
3. UI components that use the backend
|
|
135
|
+
4. Dashboard/summary views that aggregate data
|
|
136
|
+
|
|
137
|
+
**Wrong order:**
|
|
138
|
+
1. UI component (depends on schema that does not exist yet)
|
|
139
|
+
2. Schema change
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Acceptance Criteria: Must Be Verifiable
|
|
144
|
+
|
|
145
|
+
Each criterion must be something Ralph can CHECK, not something vague.
|
|
146
|
+
|
|
147
|
+
### Good criteria (verifiable):
|
|
148
|
+
- "Add `status` column to tasks table with default 'pending'"
|
|
149
|
+
- "Filter dropdown has options: All, Active, Completed"
|
|
150
|
+
- "Clicking delete shows confirmation dialog"
|
|
151
|
+
|
|
152
|
+
### Bad criteria (vague):
|
|
153
|
+
- "Works correctly"
|
|
154
|
+
- "User can do X easily"
|
|
155
|
+
- "Good UX"
|
|
156
|
+
- "Handles edge cases"
|
|
157
|
+
|
|
158
|
+
### Quality criteria — use what the project actually has
|
|
159
|
+
|
|
160
|
+
Append the quality checks detected in Step 1. Examples:
|
|
161
|
+
|
|
162
|
+
- Project has typecheck + lint → append `"Typecheck passes"`, `"Lint passes"`
|
|
163
|
+
- Project has only tests → append `"Tests pass"`
|
|
164
|
+
- Project has a build step → append `"Build passes"`
|
|
165
|
+
|
|
166
|
+
Do **not** hardcode "Typecheck passes" if the project has no typecheck.
|
|
167
|
+
|
|
168
|
+
### For stories that change UI, also include:
|
|
169
|
+
```
|
|
170
|
+
"Verify in browser using dev-browser skill"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Conversion Rules
|
|
176
|
+
|
|
177
|
+
1. **Each user story becomes one JSON entry**
|
|
178
|
+
2. **IDs**: Sequential (US-001, US-002, etc.)
|
|
179
|
+
3. **Priority**: Based on dependency order, then document order
|
|
180
|
+
4. **All stories**: `passes: false`
|
|
181
|
+
5. **notes**: Pre-populate with relevant file paths from codebase scan
|
|
182
|
+
6. **branchName**: Derive from feature name, kebab-case, prefixed with `ralph/`
|
|
183
|
+
7. **qualityChecks**: Populated from detected project commands (Step 1)
|
|
184
|
+
8. **Quality criteria on stories**: Match what `qualityChecks` contains
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Splitting Large PRDs
|
|
189
|
+
|
|
190
|
+
If a PRD has big features, split them:
|
|
191
|
+
|
|
192
|
+
**Original:**
|
|
193
|
+
> "Add user notification system"
|
|
194
|
+
|
|
195
|
+
**Split into:**
|
|
196
|
+
1. US-001: Add notifications table to database
|
|
197
|
+
2. US-002: Create notification service for sending notifications
|
|
198
|
+
3. US-003: Add notification bell icon to header
|
|
199
|
+
4. US-004: Create notification dropdown panel
|
|
200
|
+
5. US-005: Add mark-as-read functionality
|
|
201
|
+
6. US-006: Add notification preferences page
|
|
202
|
+
|
|
203
|
+
Each is one focused change that can be completed and verified independently.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Example
|
|
208
|
+
|
|
209
|
+
**Input PRD with Tech Context:**
|
|
210
|
+
```markdown
|
|
211
|
+
# PRD: Task Status Feature
|
|
212
|
+
|
|
213
|
+
## Tech Context
|
|
214
|
+
- **Stack:** Next.js 14 (App Router) + TypeScript + Tailwind CSS
|
|
215
|
+
- **DB:** Prisma with PostgreSQL (`prisma/schema.prisma`)
|
|
216
|
+
- **UI:** shadcn/ui in `src/components/ui/`
|
|
217
|
+
- **Quality gates:** Typecheck (`tsc --noEmit`), Lint (`eslint`), Tests (`vitest`)
|
|
218
|
+
- **Relevant code:**
|
|
219
|
+
- Task model: `prisma/schema.prisma`
|
|
220
|
+
- Task list: `src/components/TaskList.tsx`
|
|
221
|
+
- Task card: `src/components/TaskCard.tsx`
|
|
222
|
+
- Badge: `src/components/ui/Badge.tsx`
|
|
223
|
+
- API: `src/app/api/tasks/`
|
|
224
|
+
|
|
225
|
+
## User Stories
|
|
226
|
+
### US-001: Add status field to database ...
|
|
227
|
+
### US-002: Display status badge on task cards ...
|
|
228
|
+
### US-003: Add status toggle ...
|
|
229
|
+
### US-004: Filter tasks by status ...
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Output prd.json:**
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"project": "TaskApp",
|
|
236
|
+
"branchName": "ralph/task-status",
|
|
237
|
+
"description": "Task Status Feature - Track task progress with status indicators",
|
|
238
|
+
"qualityChecks": {
|
|
239
|
+
"typecheck": "npx tsc --noEmit",
|
|
240
|
+
"lint": "npm run lint",
|
|
241
|
+
"test": "npx vitest run"
|
|
242
|
+
},
|
|
243
|
+
"userStories": [
|
|
244
|
+
{
|
|
245
|
+
"id": "US-001",
|
|
246
|
+
"title": "Add status field to tasks table",
|
|
247
|
+
"description": "As a developer, I need to store task status in the database.",
|
|
248
|
+
"acceptanceCriteria": [
|
|
249
|
+
"Add status column: 'pending' | 'in_progress' | 'done' (default 'pending')",
|
|
250
|
+
"Generate and run migration successfully",
|
|
251
|
+
"Typecheck passes",
|
|
252
|
+
"Lint passes"
|
|
253
|
+
],
|
|
254
|
+
"priority": 1,
|
|
255
|
+
"passes": false,
|
|
256
|
+
"notes": "Relevant files: prisma/schema.prisma (Task model)"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"id": "US-002",
|
|
260
|
+
"title": "Display status badge on task cards",
|
|
261
|
+
"description": "As a user, I want to see task status at a glance.",
|
|
262
|
+
"acceptanceCriteria": [
|
|
263
|
+
"Each task card shows colored status badge",
|
|
264
|
+
"Badge colors: gray=pending, blue=in_progress, green=done",
|
|
265
|
+
"Typecheck passes",
|
|
266
|
+
"Lint passes",
|
|
267
|
+
"Verify in browser using dev-browser skill"
|
|
268
|
+
],
|
|
269
|
+
"priority": 2,
|
|
270
|
+
"passes": false,
|
|
271
|
+
"notes": "Relevant files: src/components/TaskCard.tsx (extend), src/components/ui/Badge.tsx (reuse with color variants)"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"id": "US-003",
|
|
275
|
+
"title": "Add status toggle to task list rows",
|
|
276
|
+
"description": "As a user, I want to change task status directly from the list.",
|
|
277
|
+
"acceptanceCriteria": [
|
|
278
|
+
"Each row has status dropdown or toggle",
|
|
279
|
+
"Changing status saves immediately via PATCH /api/tasks/[id]",
|
|
280
|
+
"UI updates without page refresh",
|
|
281
|
+
"Typecheck passes",
|
|
282
|
+
"Lint passes",
|
|
283
|
+
"Verify in browser using dev-browser skill"
|
|
284
|
+
],
|
|
285
|
+
"priority": 3,
|
|
286
|
+
"passes": false,
|
|
287
|
+
"notes": "Relevant files: src/components/TaskList.tsx, src/app/api/tasks/[id]/route.ts"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"id": "US-004",
|
|
291
|
+
"title": "Filter tasks by status",
|
|
292
|
+
"description": "As a user, I want to filter the list to see only certain statuses.",
|
|
293
|
+
"acceptanceCriteria": [
|
|
294
|
+
"Filter dropdown: All | Pending | In Progress | Done",
|
|
295
|
+
"Filter persists in URL params",
|
|
296
|
+
"Typecheck passes",
|
|
297
|
+
"Lint passes",
|
|
298
|
+
"Tests pass",
|
|
299
|
+
"Verify in browser using dev-browser skill"
|
|
300
|
+
],
|
|
301
|
+
"priority": 4,
|
|
302
|
+
"passes": false,
|
|
303
|
+
"notes": "Relevant files: src/components/TaskList.tsx (add filter dropdown)"
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Archiving Previous Runs
|
|
312
|
+
|
|
313
|
+
**Before writing a new prd.json, check if there is an existing one from a different feature:**
|
|
314
|
+
|
|
315
|
+
1. Read the current `prd.json` if it exists
|
|
316
|
+
2. Check if `branchName` differs from the new feature's branch name
|
|
317
|
+
3. If different AND `progress.txt` has content beyond the header:
|
|
318
|
+
- Create archive folder: `archive/YYYY-MM-DD-feature-name/`
|
|
319
|
+
- Copy current `prd.json` and `progress.txt` to archive
|
|
320
|
+
- Reset `progress.txt` with fresh header
|
|
321
|
+
|
|
322
|
+
**The ralph.sh script handles this automatically** when you run it, but if you are manually updating prd.json between runs, archive first.
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Checklist Before Saving
|
|
327
|
+
|
|
328
|
+
Before writing prd.json, verify:
|
|
329
|
+
|
|
330
|
+
- [ ] Ran codebase reconnaissance or read PRD's Tech Context (Step 1)
|
|
331
|
+
- [ ] `qualityChecks` populated with exact commands from the project
|
|
332
|
+
- [ ] **Previous run archived** (if prd.json exists with different branchName, archive it first)
|
|
333
|
+
- [ ] Each story is completable in one iteration (small enough)
|
|
334
|
+
- [ ] Stories are ordered by dependency (schema → backend → UI)
|
|
335
|
+
- [ ] Story quality criteria match what `qualityChecks` contains (not hardcoded)
|
|
336
|
+
- [ ] UI stories have "Verify in browser using dev-browser skill" as criterion
|
|
337
|
+
- [ ] Acceptance criteria are verifiable (not vague)
|
|
338
|
+
- [ ] Story `notes` pre-populated with relevant file paths
|
|
339
|
+
- [ ] No story depends on a later story
|