5-phase-workflow 1.0.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.
Files changed (33) hide show
  1. package/README.md +332 -0
  2. package/bin/install.js +408 -0
  3. package/docs/workflow-guide.md +1024 -0
  4. package/package.json +34 -0
  5. package/src/agents/integration-agent.md +219 -0
  6. package/src/agents/review-processor.md +160 -0
  7. package/src/agents/step-executor.md +108 -0
  8. package/src/agents/step-fixer.md +132 -0
  9. package/src/agents/step-verifier.md +125 -0
  10. package/src/agents/verification-agent.md +411 -0
  11. package/src/commands/5/configure.md +309 -0
  12. package/src/commands/5/discuss-feature.md +393 -0
  13. package/src/commands/5/implement-feature.md +502 -0
  14. package/src/commands/5/plan-feature.md +285 -0
  15. package/src/commands/5/plan-implementation.md +376 -0
  16. package/src/commands/5/quick-implement.md +263 -0
  17. package/src/commands/5/review-code.md +583 -0
  18. package/src/commands/5/verify-implementation.md +277 -0
  19. package/src/hooks/statusline.js +53 -0
  20. package/src/settings.json +6 -0
  21. package/src/skills/build-project/SKILL.md +277 -0
  22. package/src/skills/configure-project/SKILL.md +355 -0
  23. package/src/skills/generate-readme/EXAMPLES.md +168 -0
  24. package/src/skills/generate-readme/SKILL.md +123 -0
  25. package/src/skills/generate-readme/TEMPLATE.md +141 -0
  26. package/src/skills/run-tests/SKILL.md +365 -0
  27. package/src/templates/ARCHITECTURE.md +64 -0
  28. package/src/templates/CONCERNS.md +75 -0
  29. package/src/templates/CONVENTIONS.md +75 -0
  30. package/src/templates/INTEGRATIONS.md +65 -0
  31. package/src/templates/STACK.md +60 -0
  32. package/src/templates/STRUCTURE.md +60 -0
  33. package/src/templates/TESTING.md +107 -0
@@ -0,0 +1,502 @@
1
+ ---
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__*
5
+ context: fork
6
+ user-invocable: true
7
+ ---
8
+
9
+ # Implement Feature (Orchestrator - Phase 3)
10
+
11
+ ## Overview
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)
19
+
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
27
+
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
33
+
34
+ ## Prerequisites
35
+
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.md`
39
+ 3. Implementation plan has been reviewed and approved by developer
40
+ 4. You have the feature name (e.g., "PROJ-1234-add-emergency-schedule") ready
41
+
42
+ ## Orchestration Process
43
+
44
+ ### Step 1: Load Implementation Plan
45
+
46
+ Read the implementation plan from `.5/{feature-name}/plan.md` where `{feature-name}` is the argument provided by the user.
47
+
48
+ The plan uses a structured format. Extract:
49
+ - From `## Meta`: feature name, ticket ID, total_steps, total_components
50
+ - From `## Steps`: each step block with its components, modes, and pre-built prompts
51
+ - From `## Verification`: build_command, test_command, expected file lists
52
+
53
+ Each step block contains complete, self-contained component prompts ready to pass directly to haiku agents.
54
+
55
+ ### Step 2: Initialize State Tracking (MANDATORY)
56
+
57
+ **CRITICAL**: You MUST create the state file before starting any step execution. This file is the source of truth for implementation progress.
58
+
59
+ Create state file at `.5/{feature-name}/state.json` using Write tool:
60
+
61
+ ```json
62
+ {
63
+ "ticketId": "PROJ-1234",
64
+ "featureName": "{feature-name}",
65
+ "phase": "implementation",
66
+ "status": "in-progress",
67
+ "currentStep": 1,
68
+ "totalSteps": "{from plan}",
69
+ "completedComponents": [],
70
+ "pendingComponents": [
71
+ /* All components from plan */
72
+ ],
73
+ "failedAttempts": [],
74
+ "verificationResults": {},
75
+ "contextUsage": "0%",
76
+ "startedAt": "{ISO timestamp}",
77
+ "lastUpdated": "{ISO timestamp}"
78
+ }
79
+ ```
80
+
81
+ **After creating the file:**
82
+ 1. Use Read tool to verify the file was written correctly
83
+ 2. Report to user: "State tracking initialized at `.5/{feature-name}/state.json`"
84
+ 3. If file creation fails, stop execution and report error to user
85
+
86
+ ### Step 3: Initialize Task List
87
+
88
+ 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`.
89
+
90
+ ### Step 4: Execute Steps via Agents
91
+
92
+ For each step defined in the plan, follow this pattern:
93
+
94
+ #### 4a. Extract Step Block
95
+
96
+ From the plan, extract the step block verbatim. The plan already contains the structured format that step-executor expects:
97
+ - Step number, name, mode
98
+ - Components with action, file, skill, depends_on, and complete prompt
99
+
100
+ No transformation needed - the plan format matches the step-executor input contract.
101
+
102
+ #### 4b. Spawn step-executor Agent (haiku)
103
+
104
+ Read `.claude/agents/step-executor.md` for agent instructions, then spawn via Task tool with **model: haiku**:
105
+
106
+ ```
107
+ Task tool call:
108
+ subagent_type: general-purpose
109
+ model: haiku
110
+ description: "Execute Step {N} for {feature-name}"
111
+ prompt: |
112
+ {Contents of step-executor.md}
113
+
114
+ ---
115
+
116
+ ## Your Task
117
+
118
+ {Step block extracted from plan - passed verbatim}
119
+ ```
120
+
121
+ The step-executor receives the pre-built prompts and executes them directly. No codebase exploration needed.
122
+
123
+ #### 4c. Process step-executor Results
124
+
125
+ Receive results from the agent. For each component:
126
+ - If success: Move from `pendingComponents` to `completedComponents` in state file
127
+ - If failed: Record in `failedAttempts`
128
+
129
+ #### 4d. Spawn step-verifier Agent
130
+
131
+ Read `.claude/agents/step-verifier.md` for agent instructions, then spawn via Task tool:
132
+
133
+ ```
134
+ Task tool call:
135
+ subagent_type: general-purpose
136
+ description: "Verify Step {N} for {feature-name}"
137
+ prompt: |
138
+ {Contents of step-verifier.md}
139
+
140
+ ---
141
+
142
+ ## Your Task
143
+
144
+ Step Number: {N}
145
+ Affected Modules: {modules from plan}
146
+ New Files: {files reported by step-executor}
147
+ Compilation Targets: {based on step number and modules}
148
+ ```
149
+
150
+ #### 4e. Process step-verifier Results
151
+
152
+ - If **passed**: Update state, mark step task complete, proceed to next step
153
+ - If **passed-with-warnings**: Update state with warnings, proceed to next step
154
+ - If **failed**: Handle failure (see Step 5)
155
+
156
+ #### 4f. Update State File (MANDATORY)
157
+
158
+ **CRITICAL**: You MUST update the state file after each step completes. This is required for:
159
+ - Progress tracking if implementation is interrupted
160
+ - Debugging failures
161
+ - Resuming work in a new session
162
+ - User visibility into progress
163
+
164
+ After each step:
165
+ 1. **Read current state file** using Read tool: `.5/{feature-name}/state.json`
166
+ 2. **Update fields**:
167
+ - `currentStep`: Increment to next step number
168
+ - `completedComponents`: Append all successfully completed components from this step
169
+ - `verificationResults`: Add verification outcome for this step
170
+ - `lastUpdated`: Current ISO timestamp
171
+ 3. **Write back** using Write tool with the updated JSON
172
+ 4. **Verify write** by reading the file again to confirm update succeeded
173
+
174
+ **Example state update after Step 1:**
175
+
176
+ Before:
177
+ ```json
178
+ {
179
+ "currentStep": 1,
180
+ "completedComponents": [],
181
+ "verificationResults": {}
182
+ }
183
+ ```
184
+
185
+ After:
186
+ ```json
187
+ {
188
+ "currentStep": 2,
189
+ "completedComponents": [
190
+ {
191
+ "type": "Component",
192
+ "name": "Product",
193
+ "skill": "{project-specific-skill}",
194
+ "step": 1,
195
+ "timestamp": "2026-01-28T10:30:00Z",
196
+ "filePath": "src/models/Product.js"
197
+ }
198
+ ],
199
+ "verificationResults": {
200
+ "step1": "passed"
201
+ },
202
+ "lastUpdated": "2026-01-28T10:30:00Z"
203
+ }
204
+ ```
205
+
206
+ **If you skip this step, the implementation will not be resumable and progress will be lost.**
207
+
208
+ ### Step 5: Handle Failures
209
+
210
+ If a step-executor or step-verifier reports failure:
211
+
212
+ 1. **Record failure in state file** (MANDATORY):
213
+ - Read current state file
214
+ - Append to `failedAttempts` array:
215
+ ```json
216
+ {
217
+ "component": "ComponentName",
218
+ "skill": "skill-name",
219
+ "step": 1,
220
+ "error": "Error description",
221
+ "attempt": 1,
222
+ "timestamp": "{ISO timestamp}"
223
+ }
224
+ ```
225
+ - Update `lastUpdated` timestamp
226
+ - Write back to state file
227
+ - This ensures failures are tracked even if work is interrupted
228
+
229
+ 2. **Check retry limit** — count attempts for this component in `failedAttempts`. If >= 2, skip to escalation (step 6).
230
+
231
+ 3. **Spawn step-fixer agent** (sonnet) — read `.claude/agents/step-fixer.md` for agent instructions, then spawn via Task tool:
232
+
233
+ ```
234
+ Task tool call:
235
+ subagent_type: general-purpose
236
+ model: sonnet
237
+ description: "Fix Step {N} component {ComponentName} (attempt {M})"
238
+ prompt: |
239
+ {Contents of step-fixer.md}
240
+
241
+ ---
242
+
243
+ ## Your Task
244
+
245
+ Step Number: {N}
246
+ Component: {ComponentName}
247
+ Attempt: {M}
248
+
249
+ Original Prompt:
250
+ {The component prompt from the plan that step-executor used}
251
+
252
+ Step Verifier Output:
253
+ {Complete output from step-verifier}
254
+
255
+ Previous Attempts:
256
+ {Previous fix attempts from failedAttempts in state file, if any}
257
+ ```
258
+
259
+ 4. **Process step-fixer results**:
260
+ - If **fixed**: Proceed to re-verification (step 5)
261
+ - If **failed**: Record in state, increment attempt count, loop back to step 2
262
+ - If **escalate**: Skip to escalation (step 6)
263
+
264
+ 5. **Re-verify** by spawning step-verifier again (same as Step 4d)
265
+
266
+ 6. **Escalate to user** if:
267
+ - 2 retry attempts exhausted
268
+ - step-fixer reports `escalate` status
269
+ - Fix requires design decision
270
+
271
+ ### Step 6: Execute Final Integration Step (if configured)
272
+
273
+ If the plan includes a final integration step, read `.claude/agents/integration-agent.md` for agent instructions, then spawn via Task tool:
274
+
275
+ ```
276
+ Task tool call:
277
+ subagent_type: general-purpose
278
+ description: "Integration for {feature-name}"
279
+ prompt: |
280
+ {Contents of integration-agent.md}
281
+
282
+ ---
283
+
284
+ ## Your Task
285
+
286
+ Feature Name: {feature-name}
287
+ Components to Wire: {from plan}
288
+ Integration Points: {from plan}
289
+ Affected Modules: {all affected modules}
290
+ ```
291
+
292
+ Process integration-agent results:
293
+ - If success: Update state, mark final step complete
294
+ - If failed: Attempt fix or escalate
295
+
296
+ ### Step 7: Monitor Context Usage
297
+
298
+ After each step, estimate context usage:
299
+ - Warn developer at 50% usage
300
+ - Stop at 80% usage and recommend continuing in new session
301
+
302
+ Update state file:
303
+ ```json
304
+ {
305
+ "contextUsage": "45%",
306
+ "contextWarningIssued": false
307
+ }
308
+ ```
309
+
310
+ ### Step 8: Report Completion (MANDATORY)
311
+
312
+ **CRITICAL**: You MUST update the state file to mark completion. This is the final checkpoint.
313
+
314
+ 1. **Read current state file** using Read tool
315
+ 2. **Update to completed status**:
316
+ ```json
317
+ {
318
+ "status": "completed",
319
+ "phase": "completed",
320
+ "completedAt": "{ISO timestamp}",
321
+ "lastUpdated": "{ISO timestamp}"
322
+ }
323
+ ```
324
+ 3. **Write back** using Write tool
325
+ 4. **Verify** the update by reading the file again
326
+
327
+ Tell the developer:
328
+ 1. "Feature implementation complete!"
329
+ 2. "All {N} components created successfully"
330
+ 3. "Compilation: Successful"
331
+ 4. "Tests: All passing ({N} tests)"
332
+ 5. **"State file: `.5/{feature-name}/state.json`"** (this is critical for resume capability)
333
+ 6. "Next step: Run `/verify-implementation` to validate completeness"
334
+
335
+ **Note:** The verification step will automatically prompt the developer to commit changes, which is recommended before running CodeRabbit review.
336
+
337
+ ## State File Schema
338
+
339
+ ```typescript
340
+ {
341
+ ticketId: string,
342
+ featureName: string,
343
+ phase: "implementation" | "completed" | "failed",
344
+ status: "in-progress" | "completed" | "failed",
345
+ currentStep: number,
346
+ totalSteps: number,
347
+ completedComponents: Array<{
348
+ type: string,
349
+ name: string,
350
+ skill: string,
351
+ step: number,
352
+ timestamp: string,
353
+ filePath: string
354
+ }>,
355
+ pendingComponents: Array<{
356
+ type: string,
357
+ name: string,
358
+ skill: string,
359
+ step: number
360
+ }>,
361
+ failedAttempts: Array<{
362
+ component: string,
363
+ skill: string,
364
+ step: number,
365
+ error: string,
366
+ timestamp: string
367
+ }>,
368
+ verificationResults: Record<string, string>,
369
+ contextUsage: string,
370
+ contextWarningIssued?: boolean,
371
+ startedAt: string,
372
+ lastUpdated: string,
373
+ completedAt?: string
374
+ }
375
+ ```
376
+
377
+ ## Step Execution Modes
378
+
379
+ Steps are defined in the implementation plan with pre-built component prompts. Each step specifies:
380
+ - `mode: parallel | sequential` - how components within the step execute
381
+ - Components with self-contained prompts ready for haiku execution
382
+
383
+ Step-executor agents run with **haiku model** for token efficiency. The plan contains all context they need - no codebase exploration.
384
+
385
+ After each step: step-verifier agent runs.
386
+
387
+ ## Example Orchestration Flow
388
+
389
+ ```
390
+ User: /implement-feature PROJ-1234-add-emergency-schedule
391
+
392
+ [Main] Load plan, init state, create tasks
393
+
394
+ [FORK] step-executor: Step 1 (Foundation) - parallel
395
+ -> Returns: Product data structure created
396
+ [FORK] step-verifier: Step 1
397
+ -> Returns: passed
398
+
399
+ [Main] Update state: Step 1 complete
400
+
401
+ [FORK] step-executor: Step 2 (Logic) - parallel
402
+ -> Returns: Validation logic, business rules created
403
+ [FORK] step-verifier: Step 2
404
+ -> Returns: passed-with-warnings (1 unused import)
405
+
406
+ [Main] Update state: Step 2 complete
407
+
408
+ [FORK] step-executor: Step 3 (Integration) - sequential
409
+ -> Returns: API endpoint, tests created
410
+ [FORK] step-verifier: Step 3
411
+ -> Returns: failed (missing import in endpoint)
412
+
413
+ [FORK] step-fixer: Step 3 (attempt 1)
414
+ -> Returns: fixed (added missing import)
415
+ [FORK] step-verifier: Step 3 (retry)
416
+ -> Returns: passed
417
+
418
+ [Main] Update state: Step 3 complete
419
+
420
+ [Main] Update state: completed
421
+ [Main] Report: "Feature implementation complete! All 5 components created."
422
+ ```
423
+
424
+ ## Instructions Summary
425
+
426
+ 1. **Load implementation plan** from `.5/{feature-name}/plan.md`
427
+ 2. **Initialize state file** (MANDATORY) in `.5/{feature-name}/state.json` - verify creation
428
+ 3. **Create tasks** for all steps defined in the plan
429
+ 4. **For each step:**
430
+ - Spawn step-executor
431
+ - Process results
432
+ - Spawn step-verifier
433
+ - Process results
434
+ - **Update state file** (MANDATORY - Step 4f) - verify update
435
+ 5. **For final integration step (if configured):** Spawn integration-agent, process results, **update state file** (MANDATORY)
436
+ 6. **Handle failures** - record in state file (MANDATORY), spawn step-fixer to diagnose and fix, re-verify after fix, escalate if stuck
437
+ 7. **Monitor context** - warn at 50%, stop at 80%
438
+ 8. **Update state file to completed** (MANDATORY - Step 8) - verify final update
439
+ 9. **Report completion** with summary including state file location
440
+
441
+ **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.
442
+
443
+ ## Key Principles
444
+
445
+ 1. **Thin orchestrator** - Main context only reads plans, spawns agents, processes results, updates state
446
+ 2. **Haiku execution** - Step-executor agents use haiku model with pre-built prompts from the plan
447
+ 3. **No exploration** - Agents execute self-contained prompts; all codebase analysis was done in Phase 2
448
+ 4. **State tracking** - Persistent, resumable, debuggable
449
+ 5. **Verify early, verify often** - step-verifier after each step-executor
450
+ 6. **Graceful degradation** - Retry, fix, escalate
451
+ 7. **Context awareness** - Monitor and warn
452
+
453
+ ## Resuming Interrupted Implementations
454
+
455
+ If an implementation is interrupted (context limit, error, timeout):
456
+
457
+ 1. **Check state file** at `.5/{feature-name}/state.json`
458
+ 2. **Read current progress**:
459
+ - `currentStep`: Which step to resume at
460
+ - `completedComponents`: What's already done
461
+ - `failedAttempts`: What needs attention
462
+ 3. **Resume execution** starting from `currentStep`
463
+ 4. **Continue normal flow** with step-executor → step-verifier → state update cycle
464
+
465
+ **Example resume scenario:**
466
+ ```
467
+ User: "Continue implementation of PROJ-1234-add-emergency-schedule"
468
+
469
+ [You read state file]
470
+ {
471
+ "currentStep": 2,
472
+ "completedComponents": [/* Step 1 components */],
473
+ "failedAttempts": []
474
+ }
475
+
476
+ [You resume at Step 2]
477
+ "Resuming implementation from Step 2 (Logic)..."
478
+ [Execute Step 2 → remaining steps]
479
+ ```
480
+
481
+ ## DO NOT
482
+
483
+ - DO NOT execute skills directly from this command (agents call skills)
484
+ - DO NOT do heavy file reading/writing in main context (agents do this)
485
+ - **DO NOT skip state file updates** (this breaks resumability)
486
+ - **DO NOT skip state file initialization** (Step 2 is mandatory)
487
+ - **DO NOT skip state file completion update** (Step 8 is mandatory)
488
+ - DO NOT skip verification (step-verifier) after any step
489
+ - DO NOT continue after 2 failed retry attempts without escalation
490
+ - DO NOT ignore context usage warnings
491
+ - DO NOT analyze errors in main context (delegate to step-fixer)
492
+ - DO NOT fix code in main context (delegate to step-fixer)
493
+
494
+ ## Related Documentation
495
+
496
+ - [Agent: step-executor](../agents/step-executor.md)
497
+ - [Agent: step-verifier](../agents/step-verifier.md)
498
+ - [Agent: integration-agent](../agents/integration-agent.md)
499
+ - [Agent: step-fixer](../agents/step-fixer.md)
500
+ - [/plan-feature command](plan-feature.md)
501
+ - [/plan-implementation command](plan-implementation.md)
502
+ - [/verify-implementation command](verify-implementation.md)