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,548 +1,259 @@
1
1
  ---
2
2
  name: 5:implement-feature
3
- description: Orchestrates feature implementation by delegating tasks to specialized agents. Takes a planned feature and executes each step through forked agents to minimize main context usage.
4
- allowed-tools: Task, Read, Write, Glob, Grep, mcp__jetbrains__*
3
+ description: Executes an implementation plan by delegating to agents. Phase 3 of the 5-phase workflow.
4
+ allowed-tools: Task, Read, Write, Glob, Grep
5
5
  context: fork
6
6
  user-invocable: true
7
7
  ---
8
8
 
9
- # Implement Feature (Orchestrator - Phase 3)
9
+ # Implement Feature (Phase 3)
10
10
 
11
- ## Overview
11
+ Execute an implementation plan by delegating work to agents.
12
12
 
13
- This skill is the **third phase** of the 5-phase workflow:
14
- 1. **Feature Planning** - Understand requirements, create feature spec (completed)
15
- 2. **Implementation Planning** - Map to technical components and skills (completed)
16
- 3. **Orchestrated Implementation** (this skill) - Execute with state tracking
17
- 4. **Verify Implementation** - Check completeness and correctness (next)
18
- 5. **Code Review** - Apply automated quality improvements (final)
13
+ ## Scope
19
14
 
20
- This command is a **thin orchestrator** that:
21
- - Reads the implementation plan (pre-built Phase 2)
22
- - Initializes state tracking
23
- - Delegates to haiku agents via the Task tool (forked contexts)
24
- - Processes agent results
25
- - Tracks progress and handles failures
26
- - Reports completion
15
+ **This command orchestrates implementation. It delegates to agents.**
27
16
 
28
- **Architecture:** `Commands -> Agents (haiku) -> Skills`
29
- - This command stays in the main context (thin, minimal)
30
- - Agents run in forked contexts with **haiku model** for token efficiency
31
- - The plan contains self-contained prompts - agents execute without codebase exploration
32
- - Skills are called by agents when specified in the plan
17
+ You are a thin orchestrator:
18
+ - Read the plan
19
+ - Initialize state tracking
20
+ - Spawn agents for each step
21
+ - Track progress
22
+ - Report completion
33
23
 
34
- ## Prerequisites
24
+ Do NOT write code directly. Spawn agents to do the work.
35
25
 
36
- Before using this skill, ensure:
37
- 1. Feature spec exists at `.5/{TICKET-ID}-{description}/feature.md`
38
- 2. Implementation plan exists at `.5/{TICKET-ID}-{description}/plan/` directory with:
39
- - plan/meta.md (metadata)
40
- - plan/step-N.md files (one per step)
41
- - plan/verification.md (verification config)
42
- 3. Implementation plan has been reviewed and approved by developer
43
- 4. You have the feature name (e.g., "PROJ-1234-add-emergency-schedule") ready
26
+ ## Process
44
27
 
45
- ## Orchestration Process
28
+ ### Step 1: Load Plan
46
29
 
47
- ### Step 1: Load Implementation Plan
30
+ Read `.5/{feature-name}/plan.md` (where `{feature-name}` is the argument provided).
48
31
 
49
- Read the implementation plan metadata from `.5/{feature-name}/plan/meta.md` where `{feature-name}` is the argument provided by the user.
32
+ Parse:
33
+ - YAML frontmatter for ticket and feature name
34
+ - Components table for the list of work
35
+ - Implementation notes for context
36
+ - Verification commands
50
37
 
51
- **Error Handling:** If the plan directory or meta.md file is missing:
52
- - Report error immediately: "Error: Implementation plan not found at `.5/{feature-name}/plan/`. Please run /5:plan-implementation first."
53
- - Do not proceed to Step 2
38
+ If the plan doesn't exist, tell the user to run `/5:plan-implementation` first.
54
39
 
55
- Parse the YAML frontmatter from meta.md to extract:
56
- - `feature`: feature name
57
- - `ticket`: ticket ID
58
- - `total_steps`: number of steps in the plan
59
- - `total_components`: total component count
60
- - `new_files`: count of new files
61
- - `modified_files`: count of modified files
40
+ ### Step 2: Initialize State
62
41
 
63
- Store this metadata for state file initialization.
64
-
65
- **Note:** Individual step files (plan/step-N.md) will be loaded on-demand during Step 4 when executing each step.
66
-
67
- ### Step 2: Initialize State Tracking (MANDATORY)
68
-
69
- **CRITICAL**: You MUST create the state file before starting any step execution. This file is the source of truth for implementation progress.
70
-
71
- Create state file at `.5/{feature-name}/state.json` using Write tool:
42
+ Create `.5/{feature-name}/state.json`:
72
43
 
73
44
  ```json
74
45
  {
75
- "ticketId": "PROJ-1234",
76
- "featureName": "{feature-name}",
77
- "phase": "implementation",
46
+ "ticket": "{ticket-id}",
47
+ "feature": "{feature-name}",
78
48
  "status": "in-progress",
79
49
  "currentStep": 1,
80
- "totalSteps": "{from plan}",
81
- "completedComponents": [],
82
- "pendingComponents": [
83
- /* All components from plan */
84
- ],
85
- "failedAttempts": [],
86
- "verificationResults": {},
87
- "contextUsage": "0%",
88
- "startedAt": "{ISO timestamp}",
89
- "lastUpdated": "{ISO timestamp}"
50
+ "completed": [],
51
+ "failed": [],
52
+ "startedAt": "{ISO-timestamp}"
90
53
  }
91
54
  ```
92
55
 
93
- **After creating the file:**
94
- 1. Use Read tool to verify the file was written correctly
95
- 2. Report to user: "State tracking initialized at `.5/{feature-name}/state.json`"
96
- 3. If file creation fails, stop execution and report error to user
97
-
98
- ### Step 3: Initialize Task List
99
-
100
- Create TaskCreate entries for all steps defined in the implementation plan. Steps are defined dynamically in each feature's plan based on component dependencies - read them directly from `.5/{feature-name}/plan.md`.
56
+ ### Step 3: Execute Steps
101
57
 
102
- ### Step 4: Execute Steps via Agents
58
+ Group components by step number from the plan. For each step:
103
59
 
104
- For each step (1 to total_steps from meta.md), follow this pattern:
60
+ **3a. Analyze step for parallel execution**
105
61
 
106
- #### 4a. Load and Parse Step File
62
+ Components within the same step are independent by design. For steps with multiple components:
63
+ - **2+ simple components** → spawn parallel agents (one per component)
64
+ - **1 complex component** → single agent
65
+ - **Mixed complexity** → group by complexity, parallel within groups
107
66
 
108
- For the current step number N:
67
+ **3b. Determine model per component**
109
68
 
110
- 1. **Read step file:** `.5/{feature-name}/plan/step-{N}.md`
69
+ Based on Complexity column:
70
+ - `simple` → `haiku` (fast, cheap)
71
+ - `moderate` → `haiku` (default) or `sonnet` (if business logic heavy)
72
+ - `complex` → `sonnet` (better reasoning)
111
73
 
112
- **Error Handling:** If the step file is missing:
113
- - Report error: "Error: Step {N} plan file not found at `.5/{feature-name}/plan/step-{N}.md`. Plan may be incomplete."
114
- - Stop execution and escalate to user
74
+ **3c. Spawn agents (parallel when possible)**
115
75
 
116
- 2. **Parse YAML frontmatter** (between `---` markers):
117
- - Extract: `step`, `name`, `mode`, `components` (count)
76
+ For steps with multiple independent components, spawn agents in parallel using multiple Task calls in a single message:
118
77
 
119
- 3. **Extract YAML components block:**
120
- - Find the `## Components` section
121
- - Extract the YAML block (between ` ```yaml` and ` ``` `)
122
- - Parse the YAML to get the `components` array
123
-
124
- **Error Handling:** If YAML parsing fails:
125
- - Report error: "Error: Malformed step plan file at `.5/{feature-name}/plan/step-{N}.md`. Check YAML syntax in components block."
126
- - Stop execution and escalate to user
78
+ ```
79
+ # Example: Step 1 has 3 simple components - spawn all 3 in parallel
127
80
 
128
- 4. **Build step block object:**
129
- ```yaml
130
- step: {from frontmatter}
131
- name: "{from frontmatter}"
132
- mode: {from frontmatter}
133
- components: {from YAML block}
134
- ```
81
+ Task tool call #1:
82
+ subagent_type: general-purpose
83
+ model: haiku
84
+ description: "Create {component-1} for {feature-name}"
85
+ prompt: |
86
+ Create a single component for a feature.
135
87
 
136
- This step block is now ready to pass to the step-executor agent (same format as before).
88
+ ## Component
89
+ - Name: {component-name}
90
+ - Action: create
91
+ - File: {file-path}
92
+ - Description: {what it does}
137
93
 
138
- #### 4b. Spawn step-executor Agent (haiku)
94
+ ## Pattern Reference
95
+ {relevant implementation note for this component}
139
96
 
140
- Read `.claude/agents/step-executor.md` for agent instructions, then spawn via Task tool with **model: haiku**:
97
+ ## Instructions
98
+ 1. Find a similar existing file using Glob (e.g., *Service.ts for services)
99
+ 2. Read that file to understand the pattern
100
+ 3. Create the new file following that pattern
101
+ 4. Verify the file exists
141
102
 
142
- ```
143
- Task tool call:
103
+ Task tool call #2:
144
104
  subagent_type: general-purpose
145
105
  model: haiku
146
- description: "Execute Step {N} for {feature-name}"
106
+ description: "Create {component-2} for {feature-name}"
147
107
  prompt: |
148
- {Contents of step-executor.md}
149
-
150
- ---
151
-
152
- ## Your Task
108
+ [same structure, different component]
153
109
 
154
- {Step block extracted from plan - passed verbatim}
110
+ Task tool call #3:
111
+ subagent_type: general-purpose
112
+ model: haiku
113
+ description: "Create {component-3} for {feature-name}"
114
+ prompt: |
115
+ [same structure, different component]
155
116
  ```
156
117
 
157
- The step-executor receives the pre-built prompts and executes them directly. No codebase exploration needed.
158
-
159
- #### 4c. Process step-executor Results
160
-
161
- Receive results from the agent. For each component:
162
- - If success: Move from `pendingComponents` to `completedComponents` in state file
163
- - If failed: Record in `failedAttempts`
164
-
165
- #### 4d. Spawn step-verifier Agent
166
-
167
- Read `.claude/agents/step-verifier.md` for agent instructions, then spawn via Task tool:
118
+ For steps with a single component or complex interdependencies, use a single agent:
168
119
 
169
120
  ```
170
121
  Task tool call:
171
122
  subagent_type: general-purpose
172
- description: "Verify Step {N} for {feature-name}"
123
+ model: {based on complexity}
124
+ description: "Execute Step {N} for {feature-name}"
173
125
  prompt: |
174
- {Contents of step-verifier.md}
126
+ You are implementing components for a feature.
175
127
 
176
- ---
177
-
178
- ## Your Task
179
-
180
- Step Number: {N}
181
- Affected Modules: {modules from plan}
182
- New Files: {files reported by step-executor}
183
- Compilation Targets: {based on step number and modules}
184
- ```
128
+ ## Feature Context
129
+ {feature-name}: {one-line summary from plan}
185
130
 
186
- #### 4e. Process step-verifier Results
131
+ ## Components to Create/Modify
132
+ {components for this step from the plan table}
187
133
 
188
- - If **passed**: Update state, mark step task complete, proceed to next step
189
- - If **passed-with-warnings**: Update state with warnings, proceed to next step
190
- - If **failed**: Handle failure (see Step 5)
134
+ ## Implementation Notes
135
+ {implementation notes section from plan}
191
136
 
192
- #### 4f. Update State File (MANDATORY)
137
+ ## Instructions
138
+ 1. For each component:
139
+ - If creating a file: find a similar existing file, understand the pattern, create the new file following that pattern
140
+ - If modifying a file: read the file, make the described change
141
+ 2. After creating/modifying each file, verify it exists
142
+ 3. Report what you created/modified
193
143
 
194
- **CRITICAL**: You MUST update the state file after each step completes. This is required for:
195
- - Progress tracking if implementation is interrupted
196
- - Debugging failures
197
- - Resuming work in a new session
198
- - User visibility into progress
144
+ Use Glob to find similar files. Use Read to understand patterns. Use Write/Edit to create/modify files.
145
+ ```
199
146
 
200
- After each step:
201
- 1. **Read current state file** using Read tool: `.5/{feature-name}/state.json`
202
- 2. **Update fields**:
203
- - `currentStep`: Increment to next step number
204
- - `completedComponents`: Append all successfully completed components from this step
205
- - `verificationResults`: Add verification outcome for this step
206
- - `lastUpdated`: Current ISO timestamp
207
- 3. **Write back** using Write tool with the updated JSON
208
- 4. **Verify write** by reading the file again to confirm update succeeded
147
+ **3d. Process results**
209
148
 
210
- **Example state update after Step 1:**
149
+ Collect results from all agents (parallel or sequential). For each:
150
+ - Components completed successfully
151
+ - Components that failed
211
152
 
212
- Before:
153
+ Update state.json:
213
154
  ```json
214
155
  {
215
- "currentStep": 1,
216
- "completedComponents": [],
217
- "verificationResults": {}
156
+ "currentStep": {N+1},
157
+ "completed": [...previous, ...newlyCompleted],
158
+ "failed": [...previous, ...newlyFailed]
218
159
  }
219
160
  ```
220
161
 
221
- After:
222
- ```json
223
- {
224
- "currentStep": 2,
225
- "completedComponents": [
226
- {
227
- "type": "Component",
228
- "name": "Product",
229
- "skill": "{project-specific-skill}",
230
- "step": 1,
231
- "timestamp": "2026-01-28T10:30:00Z",
232
- "filePath": "src/models/Product.js"
233
- }
234
- ],
235
- "verificationResults": {
236
- "step1": "passed"
237
- },
238
- "lastUpdated": "2026-01-28T10:30:00Z"
239
- }
240
- ```
241
-
242
- **If you skip this step, the implementation will not be resumable and progress will be lost.**
243
-
244
- ### Step 5: Handle Failures
245
-
246
- If a step-executor or step-verifier reports failure:
247
-
248
- 1. **Record failure in state file** (MANDATORY):
249
- - Read current state file
250
- - Append to `failedAttempts` array:
251
- ```json
252
- {
253
- "component": "ComponentName",
254
- "skill": "skill-name",
255
- "step": 1,
256
- "error": "Error description",
257
- "attempt": 1,
258
- "timestamp": "{ISO timestamp}"
259
- }
260
- ```
261
- - Update `lastUpdated` timestamp
262
- - Write back to state file
263
- - This ensures failures are tracked even if work is interrupted
264
-
265
- 2. **Check retry limit** — count attempts for this component in `failedAttempts`. If >= 2, skip to escalation (step 6).
266
-
267
- 3. **Spawn step-fixer agent** (sonnet) — read `.claude/agents/step-fixer.md` for agent instructions, then spawn via Task tool:
268
-
269
- To retrieve the original component prompt:
270
- - Read `.5/{feature-name}/plan/step-{N}.md`
271
- - Parse the YAML components block
272
- - Find the component by ID
273
- - Extract the `prompt` field
274
-
275
- ```
276
- Task tool call:
277
- subagent_type: general-purpose
278
- model: sonnet
279
- description: "Fix Step {N} component {ComponentName} (attempt {M})"
280
- prompt: |
281
- {Contents of step-fixer.md}
282
-
283
- ---
162
+ **3e. Handle failures**
284
163
 
285
- ## Your Task
164
+ If any component failed:
165
+ - Log the failure in state.json
166
+ - Continue to next step (don't block on failures)
167
+ - Report failures at the end
286
168
 
287
- Step Number: {N}
288
- Component: {ComponentName}
289
- Attempt: {M}
169
+ ### Step 4: Run Verification
290
170
 
291
- Original Prompt:
292
- {The component prompt extracted from plan/step-{N}.md}
171
+ After all steps complete, run build and test:
293
172
 
294
- Step Verifier Output:
295
- {Complete output from step-verifier}
173
+ ```bash
174
+ # Build command from plan (or auto-detect)
175
+ {build-command}
296
176
 
297
- Previous Attempts:
298
- {Previous fix attempts from failedAttempts in state file, if any}
299
- ```
300
-
301
- 4. **Process step-fixer results**:
302
- - If **fixed**: Proceed to re-verification (step 5)
303
- - If **failed**: Record in state, increment attempt count, loop back to step 2
304
- - If **escalate**: Skip to escalation (step 6)
305
-
306
- 5. **Re-verify** by spawning step-verifier again (same as Step 4d)
307
-
308
- 6. **Escalate to user** if:
309
- - 2 retry attempts exhausted
310
- - step-fixer reports `escalate` status
311
- - Fix requires design decision
312
-
313
- ### Step 6: Execute Final Integration Step (if configured)
314
-
315
- If the plan includes a final integration step, read `.claude/agents/integration-agent.md` for agent instructions, then spawn via Task tool:
316
-
317
- ```
318
- Task tool call:
319
- subagent_type: general-purpose
320
- description: "Integration for {feature-name}"
321
- prompt: |
322
- {Contents of integration-agent.md}
323
-
324
- ---
325
-
326
- ## Your Task
327
-
328
- Feature Name: {feature-name}
329
- Components to Wire: {from plan}
330
- Integration Points: {from plan}
331
- Affected Modules: {all affected modules}
332
- ```
333
-
334
- Process integration-agent results:
335
- - If success: Update state, mark final step complete
336
- - If failed: Attempt fix or escalate
337
-
338
- ### Step 7: Monitor Context Usage
339
-
340
- After each step, estimate context usage:
341
- - Warn developer at 50% usage
342
- - Stop at 80% usage and recommend continuing in new session
343
-
344
- Update state file:
345
- ```json
346
- {
347
- "contextUsage": "45%",
348
- "contextWarningIssued": false
349
- }
177
+ # Test command from plan (or auto-detect)
178
+ {test-command}
350
179
  ```
351
180
 
352
- ### Step 8: Report Completion (MANDATORY)
181
+ If build or tests fail:
182
+ - Record in state.json
183
+ - Report to user with error details
353
184
 
354
- **CRITICAL**: You MUST update the state file to mark completion. This is the final checkpoint.
185
+ ### Step 5: Update State and Report
355
186
 
356
- 1. **Read current state file** using Read tool
357
- 2. **Update to completed status**:
187
+ Update state.json:
358
188
  ```json
359
189
  {
360
190
  "status": "completed",
361
- "phase": "completed",
362
- "completedAt": "{ISO timestamp}",
363
- "lastUpdated": "{ISO timestamp}"
191
+ "completedAt": "{ISO-timestamp}",
192
+ "buildStatus": "success|failed",
193
+ "testStatus": "success|failed"
364
194
  }
365
195
  ```
366
- 3. **Write back** using Write tool
367
- 4. **Verify** the update by reading the file again
368
196
 
369
- Tell the developer:
370
- 1. "Feature implementation complete!"
371
- 2. "All {N} components created successfully"
372
- 3. "Compilation: Successful"
373
- 4. "Tests: All passing ({N} tests)"
374
- 5. **"State file: `.5/{feature-name}/state.json`"** (this is critical for resume capability)
375
- 6. "Next steps:"
376
- - "Run `/clear` to reset context"
377
- - "Then run `/5:verify-implementation {feature-name}` to validate completeness"
378
-
379
- **Note:** The verification step will automatically prompt the developer to commit changes, which is recommended before running CodeRabbit review.
380
-
381
- ## State File Schema
382
-
383
- ```typescript
384
- {
385
- ticketId: string,
386
- featureName: string,
387
- phase: "implementation" | "completed" | "failed",
388
- status: "in-progress" | "completed" | "failed",
389
- currentStep: number,
390
- totalSteps: number,
391
- completedComponents: Array<{
392
- type: string,
393
- name: string,
394
- skill: string,
395
- step: number,
396
- timestamp: string,
397
- filePath: string
398
- }>,
399
- pendingComponents: Array<{
400
- type: string,
401
- name: string,
402
- skill: string,
403
- step: number
404
- }>,
405
- failedAttempts: Array<{
406
- component: string,
407
- skill: string,
408
- step: number,
409
- error: string,
410
- timestamp: string
411
- }>,
412
- verificationResults: Record<string, string>,
413
- contextUsage: string,
414
- contextWarningIssued?: boolean,
415
- startedAt: string,
416
- lastUpdated: string,
417
- completedAt?: string
418
- }
197
+ Tell the user:
419
198
  ```
199
+ Implementation complete!
420
200
 
421
- ## Step Execution Modes
201
+ {ticket}: {feature-name}
202
+ - {N} components created/modified
203
+ - Build: {status}
204
+ - Tests: {status}
422
205
 
423
- Steps are defined in the implementation plan with pre-built component prompts. Each step specifies:
424
- - `mode: parallel | sequential` - how components within the step execute
425
- - Components with self-contained prompts ready for haiku execution
426
-
427
- Step-executor agents run with **haiku model** for token efficiency. The plan contains all context they need - no codebase exploration.
428
-
429
- After each step: step-verifier agent runs.
430
-
431
- ## Example Orchestration Flow
206
+ {If any failures: list them}
432
207
 
208
+ Next steps:
209
+ 1. Run `/clear` to reset context (recommended between phases)
210
+ 2. Run `/5:verify-implementation {feature-name}`
433
211
  ```
434
- User: /implement-feature PROJ-1234-add-emergency-schedule
435
-
436
- [Main] Load plan, init state, create tasks
437
212
 
438
- [FORK] step-executor: Step 1 (Foundation) - parallel
439
- -> Returns: Product data structure created
440
- [FORK] step-verifier: Step 1
441
- -> Returns: passed
213
+ ## Handling Interruptions
442
214
 
443
- [Main] Update state: Step 1 complete
215
+ If implementation is interrupted, the state file allows resuming:
216
+ - Read state.json
217
+ - Skip steps where all components are in `completed`
218
+ - Resume from `currentStep`
444
219
 
445
- [FORK] step-executor: Step 2 (Logic) - parallel
446
- -> Returns: Validation logic, business rules created
447
- [FORK] step-verifier: Step 2
448
- -> Returns: passed-with-warnings (1 unused import)
220
+ ## Example Flow
449
221
 
450
- [Main] Update state: Step 2 complete
451
-
452
- [FORK] step-executor: Step 3 (Integration) - sequential
453
- -> Returns: API endpoint, tests created
454
- [FORK] step-verifier: Step 3
455
- -> Returns: failed (missing import in endpoint)
456
-
457
- [FORK] step-fixer: Step 3 (attempt 1)
458
- -> Returns: fixed (added missing import)
459
- [FORK] step-verifier: Step 3 (retry)
460
- -> Returns: passed
461
-
462
- [Main] Update state: Step 3 complete
463
-
464
- [Main] Update state: completed
465
- [Main] Report: "Feature implementation complete! All 5 components created."
466
- ```
467
-
468
- ## Instructions Summary
469
-
470
- 1. **Load implementation plan metadata** from `.5/{feature-name}/plan/meta.md` - parse YAML frontmatter for total_steps, total_components
471
- 2. **Initialize state file** (MANDATORY) in `.5/{feature-name}/state.json` - verify creation
472
- 3. **Create tasks** for all steps defined in the plan
473
- 4. **For each step (1 to total_steps):**
474
- - Load and parse step file: `.5/{feature-name}/plan/step-{N}.md` (parse YAML frontmatter + components block)
475
- - Build step block object from parsed data
476
- - Spawn step-executor with step block
477
- - Process results
478
- - Spawn step-verifier
479
- - Process results
480
- - **Update state file** (MANDATORY - Step 4f) - verify update
481
- 5. **For final integration step (if configured):** Spawn integration-agent, process results, **update state file** (MANDATORY)
482
- 6. **Handle failures** - record in state file (MANDATORY), extract original prompt from plan/step-{N}.md, spawn step-fixer to diagnose and fix, re-verify after fix, escalate if stuck
483
- 7. **Monitor context** - warn at 50%, stop at 80%
484
- 8. **Update state file to completed** (MANDATORY - Step 8) - verify final update
485
- 9. **Report completion** with summary including state file location
486
-
487
- **CRITICAL**: State file updates at Steps 2, 4f (after each step), 5 (failures), and 8 (completion) are MANDATORY. These enable resumability if implementation is interrupted.
488
-
489
- ## Key Principles
490
-
491
- 1. **Thin orchestrator** - Main context only reads plans, spawns agents, processes results, updates state
492
- 2. **Haiku execution** - Step-executor agents use haiku model with pre-built prompts from the plan
493
- 3. **No exploration** - Agents execute self-contained prompts; all codebase analysis was done in Phase 2
494
- 4. **State tracking** - Persistent, resumable, debuggable
495
- 5. **Verify early, verify often** - step-verifier after each step-executor
496
- 6. **Graceful degradation** - Retry, fix, escalate
497
- 7. **Context awareness** - Monitor and warn
498
-
499
- ## Resuming Interrupted Implementations
500
-
501
- If an implementation is interrupted (context limit, error, timeout):
502
-
503
- 1. **Check state file** at `.5/{feature-name}/state.json`
504
- 2. **Read current progress**:
505
- - `currentStep`: Which step to resume at
506
- - `completedComponents`: What's already done
507
- - `failedAttempts`: What needs attention
508
- 3. **Resume execution** starting from `currentStep`
509
- 4. **Continue normal flow** with step-executor → step-verifier → state update cycle
510
-
511
- **Example resume scenario:**
512
222
  ```
513
- User: "Continue implementation of PROJ-1234-add-emergency-schedule"
514
-
515
- [You read state file]
516
- {
517
- "currentStep": 2,
518
- "completedComponents": [/* Step 1 components */],
519
- "failedAttempts": []
520
- }
223
+ User: /implement-feature PROJ-1234-add-emergency-schedule
521
224
 
522
- [You resume at Step 2]
523
- "Resuming implementation from Step 2 (Logic)..."
524
- [Execute Step 2 → remaining steps]
225
+ [You read plan.md]
226
+ [You create state.json]
227
+
228
+ [Step 1: Foundation - 2 simple components → PARALLEL]
229
+ Spawn 2 agents in single message:
230
+ - Agent A creates: Schedule.ts (model)
231
+ - Agent B creates: schedule.ts (types)
232
+ Both complete → update state
233
+
234
+ [Step 2: Logic - 2 moderate components → PARALLEL]
235
+ Spawn 2 agents in single message:
236
+ - Agent A creates: ScheduleService.ts
237
+ - Agent B creates: ScheduleRepository.ts
238
+ Both complete → update state
239
+
240
+ [Step 3: Integration - mixed complexity → SEQUENTIAL or grouped]
241
+ Option A: Single sonnet agent handles both
242
+ Option B: Parallel if truly independent
243
+ - Agent creates: ScheduleController.ts
244
+ - Agent modifies: routes/index.ts
245
+ Complete → update state
246
+
247
+ [Step 4: Tests - 1 component → SINGLE agent]
248
+ Agent creates: ScheduleService.test.ts
249
+ Complete → update state
250
+
251
+ [Verification]
252
+ Run: npm run build → successful
253
+ Run: npm test → passing
254
+
255
+ [Update state: completed]
256
+ [Report to user]
525
257
  ```
526
258
 
527
- ## DO NOT
528
-
529
- - DO NOT execute skills directly from this command (agents call skills)
530
- - DO NOT do heavy file reading/writing in main context (agents do this)
531
- - **DO NOT skip state file updates** (this breaks resumability)
532
- - **DO NOT skip state file initialization** (Step 2 is mandatory)
533
- - **DO NOT skip state file completion update** (Step 8 is mandatory)
534
- - DO NOT skip verification (step-verifier) after any step
535
- - DO NOT continue after 2 failed retry attempts without escalation
536
- - DO NOT ignore context usage warnings
537
- - DO NOT analyze errors in main context (delegate to step-fixer)
538
- - DO NOT fix code in main context (delegate to step-fixer)
539
-
540
- ## Related Documentation
541
-
542
- - [Agent: step-executor](../agents/step-executor.md)
543
- - [Agent: step-verifier](../agents/step-verifier.md)
544
- - [Agent: integration-agent](../agents/integration-agent.md)
545
- - [Agent: step-fixer](../agents/step-fixer.md)
546
- - [/plan-feature command](plan-feature.md)
547
- - [/plan-implementation command](plan-implementation.md)
548
- - [/verify-implementation command](verify-implementation.md)
259
+ **Performance gain:** Steps 1 and 2 run in half the time by parallelizing components.