5-phase-workflow 1.1.1 → 1.2.0

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: 5:plan-implementation
3
- description: Creates a precise, AI-executable implementation plan. Performs all codebase analysis upfront and produces self-contained component prompts that can be executed by haiku without exploration. Phase 2 of the 5-phase workflow.
3
+ description: Creates an implementation plan from a feature spec. Phase 2 of the 5-phase workflow.
4
4
  allowed-tools: Read, Glob, Grep, Task, AskUserQuestion, Write
5
5
  context: fork
6
6
  user-invocable: true
@@ -8,432 +8,207 @@ user-invocable: true
8
8
 
9
9
  # Plan Implementation (Phase 2)
10
10
 
11
- ## Overview
11
+ Create an implementation plan that maps a feature spec to concrete components.
12
12
 
13
- This skill is the **second phase** of the 5-phase workflow:
14
- 1. **Feature Planning** - Understand requirements, create feature spec (completed)
15
- 2. **Implementation Planning** (this skill) - Analyze codebase, produce AI-executable plan
16
- 3. **Orchestrated Implementation** - Execute plan with haiku agents
17
- 4. **Verify Implementation** - Check completeness and correctness
18
- 5. **Code Review** - Apply automated quality improvements
13
+ ## Scope
19
14
 
20
- **Critical design constraint:** The plan must be executable by haiku-model agents without any codebase exploration. This means YOU must do all analysis upfront and embed everything into the plan: exact file paths, exact code patterns, reference snippets, imports, and complete instructions.
15
+ **This command creates the plan. It does NOT implement.**
21
16
 
22
- ## Prerequisites
17
+ After creating the plan, tell the user to run `/5:implement-feature`.
23
18
 
24
- Before invoking this skill, ensure:
25
- 1. Feature spec exists at `.5/{TICKET-ID}-{description}/feature.md`
26
- 2. Feature spec has been reviewed and approved by developer
27
- 3. You have the feature name/ticket ID ready
19
+ ## Process
28
20
 
29
- ## Planning Process
21
+ ### Step 1: Load Feature Spec
30
22
 
31
- ### Step 1: Read Feature Specification
32
-
33
- Read the feature spec from `.5/{feature-name}/feature.md`.
23
+ Read `.5/{feature-name}/feature.md` (where `{feature-name}` is the argument provided).
34
24
 
35
25
  Extract:
36
26
  - Ticket ID
37
- - Summary
38
27
  - Requirements (functional and non-functional)
39
- - Affected domains
40
- - Entity definitions
41
- - Business rules
42
28
  - Acceptance criteria
29
+ - Affected components mentioned
43
30
 
44
- ### Step 2: Deep Codebase Analysis
45
-
46
- **This is the most important step.** You must gather all context that the executor agents will need, because they cannot explore the codebase themselves.
47
-
48
- **2a. Project structure:**
49
- - Use Glob to map the directory structure
50
- - Identify source directories, test directories, config locations
51
- - Understand module/package organization
52
-
53
- **2b. Existing patterns (read actual files):**
54
- - Find 1-2 existing examples of each component type needed (e.g., an existing service, model, controller)
55
- - Read them fully to extract:
56
- - Import statements and patterns
57
- - Class/function structure
58
- - Naming conventions (file names, variable names, export style)
59
- - Error handling patterns
60
- - Test patterns
61
-
62
- **2c. Dependencies and integration points:**
63
- - Read registration files, route files, module declarations
64
- - Understand how new components get wired in
65
- - Identify exact locations where modifications are needed (file path + line context)
66
-
67
- **2d. Build/test configuration:**
68
- - Read `.claude/.5/config.json` for build commands
69
- - Read available skills from `.claude/skills/`
31
+ If the file doesn't exist, tell the user to run `/5:plan-feature` first.
70
32
 
71
- ### Step 3: Technical Collaboration (3-5 Questions)
33
+ ### Step 2: Quick Codebase Scan
72
34
 
73
- Ask targeted technical questions using AskUserQuestion:
74
- - Data layer decisions (persistence, query patterns)
75
- - Validation requirements
76
- - API design choices
77
- - Whether to create new vs extend existing components
78
- - Challenge the approach: suggest simpler alternatives
35
+ Understand the project structure:
36
+ - Use Glob to find source directories
37
+ - Identify where similar components live (models, services, controllers, tests)
38
+ - Note naming conventions from existing files
79
39
 
80
- ### Step 4: Map Components to Skills
40
+ This is a quick scan, not deep analysis. The executor agent will do detailed pattern matching.
81
41
 
82
- For each component, determine:
83
- - Which skill creates it (from `.claude/skills/`)
84
- - Or `null` if no matching skill exists (component will be created directly via Write/Edit)
42
+ ### Step 3: Ask 2-3 Technical Questions
85
43
 
86
- ### Step 5: Determine Dependency Steps
44
+ Use AskUserQuestion to clarify:
45
+ - Data layer decisions (if applicable)
46
+ - Key implementation choices
47
+ - Anything unclear from the feature spec
48
+ - Software Architecture
49
+ - Testing behaviour
87
50
 
88
- Group components by dependencies:
89
- 1. Components with no dependencies → first step (parallel)
90
- 2. Components depending on step 1 → second step
91
- 3. Continue until all assigned
92
- 4. Name steps based on content
51
+ Keep it brief. Don't over-question. Don't ask feature questions already answered in the plan-feature phase.
93
52
 
94
- ### Step 6: Build Component Prompts
53
+ ### Step 4: Design Components
95
54
 
96
- **For each component, create a complete, self-contained execution prompt.** This prompt must contain everything a haiku agent needs to create the file without exploring anything.
55
+ Based on the feature spec and codebase scan, identify:
56
+ - What files need to be created
57
+ - What files need to be modified
58
+ - The order of implementation (dependencies)
97
59
 
98
- **For `action: create` components, the prompt must include:**
99
- - The complete file content to write, OR
100
- - A reference snippet from an existing file + clear instructions on what to change
101
- - All import statements
102
- - All type definitions needed
103
- - Exact file path
60
+ Group into steps:
61
+ - **Step 1**: Foundation (models, types, interfaces)
62
+ - **Step 2**: Logic (services, business rules)
63
+ - **Step 3**: Integration (controllers, routes, wiring)
64
+ - **Step 4**: Tests (if not created alongside components)
104
65
 
105
- **For `action: modify` components, the prompt must include:**
106
- - The exact file path
107
- - The exact `old_string` to find (copied from the actual file)
108
- - The exact `new_string` to replace it with
109
- - Context about what's above/below to ensure uniqueness
66
+ Not every feature needs all steps. Use what makes sense.
110
67
 
111
- **Prompt quality checklist:**
112
- - Could a developer who has never seen this codebase execute this prompt? If no, add more context.
113
- - Are all imports specified? If the component imports from other new components in this plan, are those paths correct?
114
- - Is the file path correct relative to the project root?
115
- - For modifications: is the old_string unique in the file?
116
-
117
- ### Step 7: Write Implementation Plan
118
-
119
- Create the plan directory `.5/{feature-name}/plan/` and write atomic plan files:
120
-
121
- #### 7a. Create plan directory
122
-
123
- Use Bash to create the directory:
124
- ```bash
125
- mkdir -p .5/{feature-name}/plan
126
- ```
68
+ ### Step 5: Write the Plan
127
69
 
128
- #### 7b. Write plan/meta.md
129
-
130
- Write metadata file using this format:
70
+ Create a single file at `.5/{feature-name}/plan.md`:
131
71
 
132
72
  ```markdown
133
73
  ---
74
+ ticket: {TICKET-ID}
134
75
  feature: {feature-name}
135
- ticket: {ticket-id}
136
- total_steps: {N}
137
- total_components: {N}
138
- new_files: {N}
139
- modified_files: {N}
140
- created_at: {ISO timestamp}
141
- format_version: "2.0"
76
+ created: {ISO-timestamp}
142
77
  ---
143
78
 
144
- # Plan Metadata: {TICKET-ID} - {Title}
79
+ # Implementation Plan: {TICKET-ID}
145
80
 
146
- {1-2 sentence summary of what this plan builds}
81
+ {One sentence summary}
147
82
 
148
- ## Steps Overview
149
- - Step 1: {Name} ({N} components)
150
- - Step 2: {Name} ({N} components)
151
- - Step N: {Name} ({N} components)
83
+ ## Components
152
84
 
153
- ## Risks
154
- - {risk 1}: {mitigation}
155
- - {risk 2}: {mitigation}
156
- ```
85
+ | Step | Component | Action | File | Description | Complexity |
86
+ |------|-----------|--------|------|-------------|------------|
87
+ | 1 | {name} | create | {path} | {what it does} | simple |
88
+ | 1 | {name} | create | {path} | {what it does} | simple |
89
+ | 2 | {name} | create | {path} | {what it does} | moderate |
90
+ | 2 | {name} | modify | {path} | {what to change} | moderate |
91
+ | 3 | {name} | create | {path} | {what it does} | complex |
157
92
 
158
- #### 7c. Write plan/step-N.md files (one per step)
93
+ ## Implementation Notes
159
94
 
160
- For each step, create a separate file `plan/step-{N}.md` using this format:
95
+ {Any important context for the executor:}
96
+ - Follow the pattern from {existing-file} for {component-type}
97
+ - {Key business rule to remember}
98
+ - {Integration point to wire up}
161
99
 
162
- ```markdown
163
- ---
164
- step: {N}
165
- feature: {feature-name}
166
- name: "{Step Name}"
167
- mode: parallel | sequential
168
- components: {N}
169
- ---
100
+ ## Complexity Guide
170
101
 
171
- # Step {N}: {Step Name}
102
+ **simple** Use haiku (fast, cheap)
103
+ - Creating files that closely follow existing patterns
104
+ - Type definitions, interfaces, simple models
105
+ - Adding imports/exports
106
+ - Straightforward CRUD without custom logic
172
107
 
173
- {Brief description of what this step accomplishes}
108
+ **moderate** Use haiku with sonnet fallback
109
+ - Services with some business logic
110
+ - Files requiring understanding of multiple patterns
111
+ - Modifications to existing files
174
112
 
175
- ## Components
113
+ **complex** → Use sonnet (better reasoning)
114
+ - Integration points wiring multiple systems
115
+ - Complex validation or business rules
116
+ - Components requiring architectural decisions
117
+ - Significant refactoring of existing code
176
118
 
177
- ```yaml
178
- components:
179
- - id: {component-id}
180
- action: create | modify
181
- file: "{exact/path/to/file.ext}"
182
- skill: "{skill-name}" | null
183
- depends_on: []
184
- prompt: |
185
- {Complete, self-contained execution instructions.
186
-
187
- For create: include full file content or reference snippet.
188
- For modify: include exact old_string and new_string.
189
- Include all imports, types, and context.}
190
-
191
- - id: {component-id-2}
192
- action: create | modify
193
- file: "{exact/path/to/file.ext}"
194
- skill: "{skill-name}" | null
195
- depends_on: ["{component-id}"]
196
- prompt: |
197
- {Complete instructions}
198
- ```
119
+ ## Verification
199
120
 
200
- ## Expected Outputs
201
- **Files Created:**
202
- - {path1}
203
- - {path2}
121
+ - Build: {command or "auto"}
122
+ - Test: {command or "auto"}
123
+ ```
204
124
 
205
- **Files Modified:**
206
- - {path3}
125
+ **Key principle:** The plan describes WHAT to build, not HOW. The executor agent will figure out patterns by reading existing code.
207
126
 
208
- ## Verification Targets
209
- **Build Targets:**
210
- - {module1}
211
- - {module2}
127
+ ### Step 6: Done
212
128
 
213
- **Test Targets:**
214
- - {test-module-1}
129
+ Tell the user:
215
130
  ```
131
+ Plan created at `.5/{feature-name}/plan.md`
216
132
 
217
- **Important:** Use YAML block within Markdown for components. This provides easy parsing while maintaining readability.
133
+ {N} components across {M} steps.
218
134
 
219
- #### 7d. Write plan/verification.md
135
+ Review the plan, then:
136
+ 1. Run `/clear` to reset context (recommended between phases)
137
+ 2. Run `/5:implement-feature {feature-name}`
138
+ ```
220
139
 
221
- Write verification configuration file:
140
+ ## Example Plan
222
141
 
223
142
  ```markdown
224
- # Verification Configuration
225
-
226
- build_command: "{from config}"
227
- test_command: "{from config}"
228
-
229
- ## Expected New Files
230
- - {path1}
231
- - {path2}
232
-
233
- ## Expected Modified Files
234
- - {path3}
235
- - {path4}
143
+ ---
144
+ ticket: PROJ-1234
145
+ feature: PROJ-1234-add-emergency-schedule
146
+ created: 2026-01-28T10:00:00Z
147
+ ---
236
148
 
237
- ## Build Targets
238
- - {module1}
239
- - {module2}
149
+ # Implementation Plan: PROJ-1234
240
150
 
241
- ## Test Modules
242
- - {test-module-1}
243
- ```
151
+ Add emergency schedule tracking to products with date validation.
244
152
 
245
- ### Step 8: Inform Developer
153
+ ## Components
246
154
 
247
- After creating the implementation plan, tell the developer:
155
+ | Step | Component | Action | File | Description | Complexity |
156
+ |------|-----------|--------|------|-------------|------------|
157
+ | 1 | Schedule model | create | src/models/Schedule.ts | Schedule entity with name, startDate, endDate, isEmergency | simple |
158
+ | 1 | Schedule types | create | src/types/schedule.ts | TypeScript interfaces for schedule data | simple |
159
+ | 2 | Schedule service | create | src/services/ScheduleService.ts | CRUD operations with date validation (endDate > startDate) | moderate |
160
+ | 2 | Schedule repository | create | src/repositories/ScheduleRepository.ts | Database access for schedules | simple |
161
+ | 3 | Schedule controller | create | src/controllers/ScheduleController.ts | REST endpoints: GET/POST/DELETE /api/schedules | moderate |
162
+ | 3 | Register routes | modify | src/routes/index.ts | Add schedule routes to router | simple |
163
+ | 4 | Schedule service tests | create | src/services/__tests__/ScheduleService.test.ts | Test validation and CRUD | moderate |
248
164
 
249
- 1. "Implementation plan created at `.5/{feature-name}/plan/`"
250
- 2. "{N} components across {M} steps"
251
- 3. "Atomic plan structure: meta.md, step-1.md, step-2.md, ..., verification.md"
252
- 4. "Each component has a self-contained execution prompt for haiku agents"
253
- 5. "Please review the plan files"
254
- 6. "Then run `/clear` followed by `/5:implement-feature {feature-name}`"
165
+ ## Implementation Notes
255
166
 
256
- ## Component Prompt Examples
167
+ - Follow the pattern from src/services/UserService.ts for the service
168
+ - Follow the pattern from src/controllers/UserController.ts for the controller
169
+ - Date validation: endDate must be after startDate, throw ValidationError if not
170
+ - Emergency schedules have `isEmergency: true` flag
257
171
 
258
- ### Example: Create a new TypeScript service
172
+ ## Verification
259
173
 
174
+ - Build: npm run build
175
+ - Test: npm test
260
176
  ```
261
- #### component: schedule-service
262
- action: create
263
- file: "src/services/ScheduleService.ts"
264
- skill: null
265
- depends_on: ["schedule-model"]
266
- prompt: |
267
- Create file `src/services/ScheduleService.ts` with this content:
268
-
269
- ```typescript
270
- import { Schedule } from '../models/Schedule';
271
- import { ScheduleRepository } from '../repositories/ScheduleRepository';
272
- import { ValidationError } from '../errors/ValidationError';
273
-
274
- export class ScheduleService {
275
- constructor(private readonly repo: ScheduleRepository) {}
276
-
277
- async create(data: { name: string; startDate: Date; endDate: Date }): Promise<Schedule> {
278
- if (data.endDate <= data.startDate) {
279
- throw new ValidationError('endDate must be after startDate');
280
- }
281
- return this.repo.save(new Schedule(data));
282
- }
283
-
284
- async findById(id: string): Promise<Schedule | null> {
285
- return this.repo.findById(id);
286
- }
287
-
288
- async delete(id: string): Promise<void> {
289
- return this.repo.delete(id);
290
- }
291
- }
292
- ```
293
-
294
- This follows the pattern from `src/services/UserService.ts`.
295
- ```
296
-
297
- ### Example: Modify an existing router file
298
177
 
299
- ```
300
- #### component: register-schedule-routes
301
- action: modify
302
- file: "src/routes/index.ts"
303
- skill: null
304
- depends_on: ["schedule-controller"]
305
- prompt: |
306
- Modify file `src/routes/index.ts`.
307
-
308
- Find this exact string:
309
- ```
310
- // Route registrations
311
- app.use('/api/users', userRoutes);
312
- ```
313
-
314
- Replace with:
315
- ```
316
- // Route registrations
317
- app.use('/api/users', userRoutes);
318
- app.use('/api/schedules', scheduleRoutes);
319
- ```
320
-
321
- Also add this import at the top of the file, after the existing imports:
322
- Find: `import { userRoutes } from './userRoutes';`
323
- Replace with:
324
- ```
325
- import { userRoutes } from './userRoutes';
326
- import { scheduleRoutes } from './scheduleRoutes';
327
- ```
328
- ```
178
+ ## Structuring Steps for Parallel Execution
329
179
 
330
- ### Example: Create a test file
180
+ Components in the same step run in parallel. Structure your plan accordingly:
331
181
 
182
+ **Good - parallel-friendly:**
332
183
  ```
333
- #### component: schedule-service-test
334
- action: create
335
- file: "src/services/__tests__/ScheduleService.test.ts"
336
- skill: null
337
- depends_on: ["schedule-service"]
338
- prompt: |
339
- Create file `src/services/__tests__/ScheduleService.test.ts` with this content:
340
-
341
- ```typescript
342
- import { ScheduleService } from '../ScheduleService';
343
- import { ScheduleRepository } from '../../repositories/ScheduleRepository';
344
- import { ValidationError } from '../../errors/ValidationError';
345
-
346
- describe('ScheduleService', () => {
347
- let service: ScheduleService;
348
- let mockRepo: jest.Mocked<ScheduleRepository>;
349
-
350
- beforeEach(() => {
351
- mockRepo = {
352
- save: jest.fn(),
353
- findById: jest.fn(),
354
- delete: jest.fn(),
355
- } as any;
356
- service = new ScheduleService(mockRepo);
357
- });
358
-
359
- describe('create', () => {
360
- it('creates a schedule with valid dates', async () => {
361
- const data = {
362
- name: 'Test',
363
- startDate: new Date('2026-01-01'),
364
- endDate: new Date('2026-01-31'),
365
- };
366
- mockRepo.save.mockResolvedValue({ id: '1', ...data } as any);
367
- const result = await service.create(data);
368
- expect(mockRepo.save).toHaveBeenCalled();
369
- expect(result).toBeDefined();
370
- });
371
-
372
- it('throws if endDate <= startDate', async () => {
373
- const data = {
374
- name: 'Test',
375
- startDate: new Date('2026-01-31'),
376
- endDate: new Date('2026-01-01'),
377
- };
378
- await expect(service.create(data)).rejects.toThrow(ValidationError);
379
- });
380
- });
381
- });
382
- ```
383
-
384
- This follows the test pattern from `src/services/__tests__/UserService.test.ts`.
184
+ | Step | Component | File |
185
+ | 1 | Model | src/models/Schedule.ts | ← parallel (no deps)
186
+ | 1 | Types | src/types/schedule.ts | ← parallel (no deps)
187
+ | 2 | Service | src/services/ScheduleService.ts | ← parallel
188
+ | 2 | Repository | src/repositories/ScheduleRepo.ts | ← parallel
189
+ | 3 | Controller | src/controllers/ScheduleCtrl.ts | ← needs service
190
+ | 3 | Routes | src/routes/index.ts | ← needs controller
385
191
  ```
386
192
 
387
- ## Instructions Summary
388
-
389
- 1. **Read feature spec** from `.5/{feature-name}/feature.md`
390
- 2. **Deep codebase analysis** - Read actual files, extract patterns, imports, conventions. This is the critical step.
391
- 3. **Ask 3-5 technical questions** - Clarify implementation details
392
- 4. **Map components to skills** - Check `.claude/skills/` for available skills
393
- 5. **Group into dependency steps** - Based on component dependencies
394
- 6. **Build self-contained prompts** - Each prompt must be executable by haiku without exploration
395
- 7. **Write plan** to `.5/{feature-name}/plan.md` in the structured format
396
- 8. **Inform developer** to review and run `/5:implement-feature`
397
-
398
- ## Key Principles
399
-
400
- 1. **Haiku-ready prompts** - Every component prompt is self-contained with all context baked in
401
- 2. **No exploration by executors** - All codebase analysis happens here in Phase 2
402
- 3. **Exact file paths** - No guessing, no pattern matching needed
403
- 4. **Reference code inline** - Include actual snippets, not "look at file X"
404
- 5. **Dependency-driven steps** - Step grouping from component dependencies
405
- 6. **Verify prompt quality** - Could someone with no codebase knowledge execute it?
406
-
407
- ## DO NOT
408
-
409
- - DO NOT start implementation (that's Phase 3's job)
410
- - DO NOT create state files (that's `/implement-feature`'s job)
411
- - DO NOT write vague prompts like "follow existing patterns" without including the pattern
412
- - DO NOT skip codebase analysis - reading actual files is mandatory
413
- - DO NOT leave file paths ambiguous
414
- - DO NOT write prompts that require the executor to read other files to understand what to do
415
- - DO NOT assume the executor can figure things out - be explicit
416
-
417
- ## Example Usage
418
-
193
+ **Bad - forces sequential:**
419
194
  ```
420
- User: /plan-implementation PROJ-1234-add-emergency-schedule
421
-
422
- Skill:
423
- 1. Reads .5/PROJ-1234-add-emergency-schedule/feature.md
424
- 2. Explores codebase: reads existing models, services, routes, tests
425
- 3. Extracts patterns: import style, naming, structure, test framework
426
- 4. Asks technical questions about validation, persistence, API
427
- 5. Maps components to skills (or null for direct execution)
428
- 6. Groups into steps by dependencies
429
- 7. Builds self-contained prompts with inline code and exact paths
430
- 8. Creates .5/PROJ-1234-add-emergency-schedule/plan/ directory
431
- 9. Writes plan/meta.md with metadata and risks
432
- 10. Writes plan/step-1.md, plan/step-2.md, plan/step-3.md with YAML components
433
- 11. Writes plan/verification.md with build/test config
434
- 12. Tells user: "Plan created with 7 components across 3 steps. Atomic plan structure at `.5/PROJ-1234-add-emergency-schedule/plan/`. Review the plan files, then run `/clear` followed by `/5:implement-feature PROJ-1234-add-emergency-schedule`"
195
+ | Step | Component | File |
196
+ | 1 | Model | ... |
197
+ | 2 | Types | ... | ← could be step 1
198
+ | 3 | Service | ... |
199
+ | 4 | Repository | ... | ← could be step 3
435
200
  ```
436
201
 
437
- ## Related Documentation
202
+ **Rules:**
203
+ - Group independent components in the same step
204
+ - Only separate into different steps when there's a real dependency
205
+ - More components per step = more parallelization = faster execution
206
+
207
+ ## What NOT To Do
438
208
 
439
- - [5-Phase Workflow Guide](../docs/workflow-guide.md)
209
+ - Don't write complete code in the plan
210
+ - Don't spend time on "haiku-ready prompts"
211
+ - Don't create multiple plan files (meta.md, step-N.md, etc.)
212
+ - Don't over-analyze the codebase - the executor will do detailed pattern matching
213
+ - Don't ask more than 3 questions
214
+ - Don't create unnecessary sequential steps - group independent work together