5-phase-workflow 1.9.5 → 2.0.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.
Files changed (44) hide show
  1. package/README.md +81 -410
  2. package/bin/install.js +385 -70
  3. package/bin/sync-agents.js +50 -11
  4. package/docs/findings.md +3 -3
  5. package/docs/workflow-guide.md +110 -1046
  6. package/package.json +6 -5
  7. package/src/agents/step-executor-agent.md +49 -0
  8. package/src/agents/step-orchestrator-agent.md +111 -0
  9. package/src/agents/verification-agent.md +78 -0
  10. package/src/commands/5/address-review-findings.md +69 -403
  11. package/src/commands/5/apply-review-findings.md +66 -0
  12. package/src/commands/5/configure.md +110 -76
  13. package/src/commands/5/discuss-feature.md +47 -57
  14. package/src/commands/5/eject.md +7 -6
  15. package/src/commands/5/implement.md +202 -0
  16. package/src/commands/5/plan.md +164 -0
  17. package/src/commands/5/reconfigure.md +32 -31
  18. package/src/commands/5/reply-pr-comments.md +46 -0
  19. package/src/commands/5/review.md +95 -0
  20. package/src/commands/5/split.md +190 -0
  21. package/src/commands/5/synchronize-agents.md +4 -4
  22. package/src/commands/5/triage-pr-comments.md +70 -0
  23. package/src/commands/5/update.md +8 -8
  24. package/src/hooks/check-updates.js +50 -7
  25. package/src/hooks/plan-guard.js +28 -22
  26. package/src/hooks/statusline.js +55 -4
  27. package/src/skills/configure-docs-index/SKILL.md +16 -21
  28. package/src/skills/configure-skills/SKILL.md +21 -24
  29. package/src/templates/AGENTS.md +94 -0
  30. package/src/templates/workflow/FIX-PLAN.md +1 -1
  31. package/src/templates/workflow/PLAN-COMPACT.md +42 -0
  32. package/src/templates/workflow/PLAN.md +58 -34
  33. package/src/templates/workflow/REVIEW-FINDINGS.md +7 -16
  34. package/src/templates/workflow/REVIEW-SUMMARY.md +5 -0
  35. package/src/templates/workflow/STATE.json +32 -3
  36. package/src/agents/component-executor.md +0 -57
  37. package/src/commands/5/implement-feature.md +0 -381
  38. package/src/commands/5/plan-feature.md +0 -293
  39. package/src/commands/5/plan-implementation.md +0 -333
  40. package/src/commands/5/quick-implement.md +0 -375
  41. package/src/commands/5/review-code.md +0 -212
  42. package/src/commands/5/verify-implementation.md +0 -277
  43. package/src/templates/workflow/FEATURE-SPEC.md +0 -100
  44. package/src/templates/workflow/VERIFICATION-REPORT.md +0 -103
@@ -1,381 +0,0 @@
1
- ---
2
- name: 5:implement-feature
3
- description: Executes an implementation plan by delegating to agents. Phase 3 of the 5-phase workflow.
4
- allowed-tools: Agent, Read, Write, Glob, Grep, Bash, TaskCreate, TaskUpdate, TaskList
5
- user-invocable: true
6
- model: opus
7
- context: fork
8
- ---
9
-
10
- <role>
11
- You are an Implementation Orchestrator. You delegate work to agents — you do not write code directly.
12
- You read the plan, spawn agents per step, track state, and report completion.
13
- You NEVER write source code yourself. You NEVER skip state file updates between steps.
14
- After all steps complete and you report to the user, you are DONE.
15
- </role>
16
-
17
- # Implement Feature (Phase 3)
18
-
19
- Execute an implementation plan by delegating work to agents.
20
-
21
- ## Scope
22
-
23
- **This command orchestrates implementation. It delegates to agents.**
24
-
25
- You are a thin orchestrator:
26
- - Read the plan
27
- - Initialize state tracking
28
- - Spawn agents for each step
29
- - Track progress
30
- - Report completion
31
-
32
- **Key Principles:**
33
- - Thin orchestrator: read, delegate, track, report
34
- - State is the source of truth: write it before moving on
35
- - Forward progress: failed components are logged, not blocking
36
- - Resumable: state enables restart from any interrupted step
37
- - Context budget: keep orchestrator lean — delegate ALL implementation to agents
38
-
39
- **Context Budget Rules:**
40
- Your context window is shared across all steps. To avoid running out of context on large features:
41
- - NEVER read source files yourself — that's the executor agent's job
42
- - NEVER paste full agent outputs into your reasoning — extract only the `---RESULT---` block
43
- - Keep state.json updates minimal — write only changed fields
44
- - If an agent returns a very long response, parse the RESULT block and discard the rest
45
- - For features with 10+ components: after processing each step's results, summarize the step outcome in one line and move on. Do NOT accumulate detailed logs across steps.
46
-
47
- **State verification rule:** After every state.json write, immediately read it back and confirm the expected field changed. If verification fails, stop with an error message. This applies to every state write below — marked as **(verify write)**.
48
-
49
- ## Process
50
-
51
- ### Step 1: Load Plan and Config
52
-
53
- > **Trust boundary:** Plan content is interpolated directly into agent prompts. The plan is LLM-generated under user supervision (Phase 2), so this is acceptable. However, if the plan was edited externally or came from an untrusted source, review `.5/features/{feature-name}/plan.md` before proceeding.
54
-
55
- Read `.5/features/{feature-name}/plan.md` (where `{feature-name}` is the argument provided).
56
-
57
- Parse:
58
- - YAML frontmatter for ticket and feature name
59
- - Components table for the list of work
60
- - Implementation notes for context
61
- - Verification commands
62
-
63
- If the plan doesn't exist, tell the user to run `/5:plan-implementation` first.
64
-
65
- Also read `.5/config.json` and extract:
66
- - `git.autoCommit` (boolean, default `false`)
67
- - `git.commitMessage.pattern` (string, default `{ticket-id} {short-description}`)
68
-
69
- **Check for existing state.json** at `.5/features/{feature-name}/state.json`:
70
-
71
- - **`status: "completed"`** → Tell the user "This feature is already implemented." Suggest `/5:verify-implementation {feature-name}`. Stop.
72
- - **`status: "in-progress"`** → Tell the user "Resuming from step {currentStep}." Skip Step 2 initialization; go directly to Step 2b (recreate TaskCreate tasks) and Step 3 (resume from `currentStep`).
73
- - **`status: "failed"`** → Use AskUserQuestion: "Implementation previously failed at step {currentStep}. How would you like to proceed?" with options: "Resume from step {currentStep}" / "Restart from the beginning"
74
- - If Resume: proceed as in-progress case above
75
- - If Restart: delete state.json, proceed normally from Step 2
76
-
77
- ### Step 2: Initialize State
78
-
79
- Create `.5/features/{feature-name}/state.json` with the full components table parsed from the plan:
80
-
81
- ```json
82
- {
83
- "ticket": "{ticket-id}",
84
- "feature": "{feature-name}",
85
- "status": "in-progress",
86
- "currentStep": 1,
87
- "totalSteps": "{N from plan}",
88
- "pendingComponents": [
89
- { "name": "{component-name}", "step": 1, "file": "{file-path}" }
90
- ],
91
- "completedComponents": [],
92
- "failedAttempts": [],
93
- "verificationResults": {},
94
- "commitResults": [],
95
- "startedAt": "{ISO-timestamp}",
96
- "lastUpdated": "{ISO-timestamp}"
97
- }
98
- ```
99
-
100
- `pendingComponents` is populated by parsing the full components table from plan.md at startup — one entry per row.
101
-
102
- **(verify write)** — confirm `status` is `"in-progress"` and `pendingComponents` is non-empty.
103
-
104
- Then remove the planning guard marker (planning is over, implementation is starting):
105
-
106
- ```bash
107
- rm -f .5/.planning-active
108
- ```
109
-
110
- ### Step 2c: Regression Baseline
111
-
112
- Before spawning any agents, establish a baseline by running the project's build and test commands:
113
-
114
- ```bash
115
- # Build command from plan (or auto-detect)
116
- {build-command}
117
-
118
- # Test command from plan (or auto-detect)
119
- {test-command}
120
- ```
121
-
122
- Record the results in state.json as `baseline`:
123
- ```json
124
- {
125
- "baseline": {
126
- "buildStatus": "success|failed",
127
- "testStatus": "success|failed|skipped",
128
- "checkedAt": "{ISO-timestamp}"
129
- }
130
- }
131
- ```
132
-
133
- **(verify write)** — confirm `baseline.checkedAt` is set.
134
-
135
- **If the baseline build fails:** Warn the user: `"⚠ Build fails BEFORE implementation. Any post-implementation build failures may be pre-existing."` Continue — don't block on pre-existing failures.
136
-
137
- **If baseline tests fail:** Warn the user: `"⚠ {N} tests fail BEFORE implementation. These will be excluded from regression comparison."` Record the failing test names/patterns if available, so Step 4 can distinguish pre-existing failures from new ones.
138
-
139
- This baseline enables Step 4 to detect regressions: tests that passed before but fail after implementation.
140
-
141
- ### Step 2b: Create Progress Checklist
142
-
143
- Before executing any steps, create one TaskCreate entry per step:
144
- - Subject: `"Step {N}: {comma-separated component names}"`
145
- - activeForm: `"Executing step {N}"`
146
-
147
- Plus one final task:
148
- - Subject: `"Run verification"`
149
- - activeForm: `"Running build and tests"`
150
-
151
- Then mark the task for Step 1 as `in_progress`.
152
-
153
- ### Step 3: Execute Steps
154
-
155
- Group components by step number from the plan. For each step (starting from `currentStep` in state.json):
156
-
157
- **3pre. Pre-step dependency check (steps 2+)**
158
-
159
- Before executing step N (where N > 1), verify that prior steps' outputs exist on disk:
160
-
161
- 1. For each component in `completedComponents` from prior steps: use Glob to confirm every file in `filesCreated` and `filesModified` still exists
162
- 2. If ANY file is missing:
163
- - Log: `"⚠ Pre-step check: {file} from step {M} component {name} not found on disk"`
164
- - Move the component back from `completedComponents` to `pendingComponents`
165
- - STOP execution for this step. Report to user: `"Step {N} blocked: prior step output missing. Re-run step {M} or fix manually."`
166
- 3. **Depends On check:** For each component in step N that has a `Depends On` value (not `—`), verify the named dependency component is in `completedComponents`. If a dependency is in `failedAttempts`, STOP and report: `"Step {N} component {name} blocked: dependency {dep} failed."`
167
- 4. If all files and dependencies verified, proceed to 3a
168
-
169
- This prevents cascading failures where step N assumes step N-1's outputs exist but they don't.
170
-
171
- **3a. Analyze step for parallel execution**
172
-
173
- Components within the same step are independent by design. For steps with multiple components:
174
- - **2+ simple components** → spawn parallel agents (one per component)
175
- - **1 complex component** → single agent
176
- - **Mixed complexity** → group by complexity, parallel within groups
177
-
178
- **3b. Determine model per component**
179
-
180
- Based on Complexity column:
181
- - `simple` → `haiku` (fast, cheap)
182
- - `moderate` → `haiku` (default) or `sonnet` (if business logic heavy)
183
- - `complex` → `sonnet` (better reasoning)
184
-
185
- **3c. Spawn agents (parallel when possible)**
186
-
187
- For steps with multiple independent components, spawn one agent per component in parallel. For single/interdependent components, use one agent.
188
-
189
- Agent prompt template (adapt per component):
190
-
191
- ```
192
- Agent tool call:
193
- subagent_type: general-purpose
194
- model: {based on complexity}
195
- description: "{Action} {component-name} for {feature-name}"
196
- prompt: |
197
- First, read ~/.claude/agents/component-executor.md for your role and instructions.
198
-
199
- ## Feature: {feature-name}
200
- ## Components
201
- {component(s) from plan table: name, action, file, description, complexity}
202
-
203
- ## Read First
204
- {Pattern File value(s) from plan table — executor MUST read these before writing any code}
205
-
206
- ## Dependencies
207
- {If Depends On is not "—": "This component depends on {dep-name} ({dep-file}). Read that file first to understand the exports/types you need to use."}
208
- {If Depends On is "—": omit this section entirely}
209
-
210
- ## Codebase Context (optional)
211
- If you need to understand how this component relates to other modules (imports, service boundaries, data flow), check `.5/index/` for quick reference — especially modules.md and libraries.md. Only if these files exist.
212
-
213
- ## Verify
214
- {Verify command(s) from plan table — executor runs these after implementation}
215
-
216
- ## Implementation Notes
217
- {ONLY notes relevant to this step/component — filter by [Step N] or [component-name] prefix.
218
- Include untagged notes only if they are globally relevant (e.g., "all services use dependency injection").
219
- Do NOT send all notes to every agent — this wastes context.}
220
- ```
221
-
222
- The agent file defines the implementation process, output format, and deviation rules. If the agent file is not found (local install), fall back to `.claude/agents/component-executor.md` relative to the project root.
223
-
224
- **3d. Process results (context-lean)**
225
-
226
- Collect results from all agents (parallel or sequential). Parse ONLY the `---RESULT---` block from each agent's response — do NOT retain the full agent output in your context. For each:
227
- - If `STATUS: success` → component succeeded; note files from `FILES_CREATED`/`FILES_MODIFIED`
228
- - If `STATUS: failed` → component failed; log the `ERROR` message
229
- - If no `---RESULT---` block found → treat as success if the agent reported creating/modifying files, otherwise treat as failed
230
-
231
- Update state.json:
232
- - Move succeeded components: remove from `pendingComponents`, append to `completedComponents` as:
233
- ```json
234
- { "name": "{name}", "step": {N}, "timestamp": "{ISO}", "filesCreated": [...], "filesModified": [...] }
235
- ```
236
- - Move failed components: append to `failedAttempts` as:
237
- ```json
238
- { "component": "{name}", "step": {N}, "error": "{message}", "timestamp": "{ISO}", "retryCount": 0 }
239
- ```
240
- - Increment `currentStep`
241
- - Update `lastUpdated`
242
-
243
- **(verify write)** — confirm `lastUpdated` changed.
244
-
245
- Mark the current step's TaskCreate task as `completed`. Mark the next step's task as `in_progress`.
246
-
247
- **3d2. Retry failed components (max 2 retries)**
248
-
249
- For each component that returned `STATUS: failed`:
250
-
251
- 1. **Always re-spawn an agent** — NEVER fix code directly in the orchestrator context, not even for small fixes like missing imports or wrong paths. The orchestrator stays slim and delegates ALL code work.
252
-
253
- Re-spawn the component-executor agent with the same prompt plus an `## Error Context` block describing the previous failure.
254
-
255
- **Model upgrade on retry:** Bump the model one tier up from the original complexity:
256
- - `simple` (haiku) → retry with `sonnet`
257
- - `moderate` (haiku/sonnet) → retry with `sonnet`
258
- - `complex` (sonnet) → retry with `sonnet` (already max)
259
-
260
- This gives the retry agent better reasoning to solve what the first attempt couldn't.
261
-
262
- 2. If the retry also fails:
263
- - Update `retryCount: 2` in the component's `failedAttempts` entry
264
- - Use AskUserQuestion: "Component '{name}' failed twice. Error: {error}. How would you like to proceed?"
265
- Options: "Skip and continue" / "I'll fix manually — pause"
266
- - If "Skip": log the skip, move on
267
- - If "Pause": update state.json with current progress, stop and wait for user
268
-
269
- Never retry more than 2 times per component.
270
-
271
- **3d3. Per-step file existence check**
272
-
273
- For each file listed in `FILES_CREATED` from successful agents: use Glob to verify the file exists on disk.
274
-
275
- If a reported file is missing:
276
- - Remove the component from `completedComponents`
277
- - Return it to `pendingComponents`
278
- - Add a `failedAttempts` entry: `{ "component": "{name}", "step": {N}, "error": "File not found after creation: {path}", "timestamp": "{ISO}", "retryCount": 0 }`
279
- - Apply retry logic from 3d2
280
-
281
- **3e. Auto-Commit Step (if enabled)**
282
-
283
- Only fires if `git.autoCommit: true` AND at least one component succeeded in this step. Stage only the step's specific files (from `FILES_CREATED`/`FILES_MODIFIED`; never `git add .`), commit with configured `git.commitMessage.pattern` (body: one bullet per component). If commit fails, append a warning entry to `commitResults` in state.json and continue.
284
-
285
- **3f. Handle failures**
286
-
287
- If any component failed after retries exhausted:
288
- - Entry remains in `failedAttempts` with `retryCount: 2`
289
- - Continue to next step (don't block on failures)
290
- - Failures are reported in the completion report
291
-
292
- ### Step 4: Run Verification
293
-
294
- Mark the "Run verification" TaskCreate task as `in_progress`.
295
-
296
- After all steps complete, run build and test:
297
-
298
- ```bash
299
- # Build command from plan (or auto-detect)
300
- {build-command}
301
-
302
- # Test command from plan (or auto-detect)
303
- {test-command}
304
- ```
305
-
306
- Update `verificationResults` in state.json:
307
- ```json
308
- {
309
- "buildStatus": "success|failed",
310
- "testStatus": "success|skipped|failed",
311
- "builtAt": "{ISO-timestamp}"
312
- }
313
- ```
314
- Also update `lastUpdated`.
315
-
316
- **4b. Check test file creation**
317
-
318
- For each component in the plan that appears to be a test file (filename contains `.test.`, `.spec.`, `test_`, or lives in a `__tests__`/`tests` directory):
319
- - Verify the file was actually created using Glob
320
- - If a planned test file was NOT created, record it as a verification warning
321
-
322
- For each non-test component with action "create" that contains logic:
323
- - Check if its corresponding test component exists in the plan
324
- - If a test was planned but is in `failedAttempts`, flag it prominently
325
-
326
- **(verify write)** — confirm `verificationResults.builtAt` is set.
327
-
328
- If build or tests fail:
329
- - Compare against `baseline` in state.json:
330
- - If build failed in baseline AND still fails → report as `"Pre-existing build failure (not a regression)"`
331
- - If build passed in baseline BUT fails now → report as `"⚠ REGRESSION: Build broke during implementation"`
332
- - If tests that passed in baseline now fail → report as `"⚠ REGRESSION: {N} tests broke during implementation: {test names}"`
333
- - If tests that failed in baseline still fail → report as `"Pre-existing test failure (not a regression)"`
334
- - Record in state.json
335
- - Report to user with error details and regression classification
336
-
337
- Mark the "Run verification" TaskCreate task as `completed`.
338
-
339
- ### Step 5: Update State and Report
340
-
341
- Update state.json:
342
- ```json
343
- {
344
- "status": "completed",
345
- "completedAt": "{ISO-timestamp}",
346
- "lastUpdated": "{ISO-timestamp}"
347
- }
348
- ```
349
-
350
- **(verify write)** — confirm `status` is `"completed"`. If this one fails, warn the user but continue — the implementation work is done.
351
-
352
- Tell the user:
353
- ```
354
- Implementation complete!
355
-
356
- {ticket}: {feature-name}
357
- - {N} components created/modified
358
- - {M} components skipped (failures that exhausted retries)
359
- - Build: {status}
360
- - Tests: {status}
361
- - Test files created: {N}/{M} planned test files exist
362
- {If any planned test files missing: "⚠ Missing test files: {list}"}
363
- {If git.autoCommit was true: "- Commits: {N} atomic commits created"}
364
-
365
- {If any failures: list them with errors}
366
-
367
- Next steps:
368
- 1. Run `/clear` to reset context (recommended between phases)
369
- 2. Run `/5:verify-implementation {feature-name}`
370
- ```
371
-
372
- ## Handling Interruptions
373
-
374
- If implementation is interrupted, the state file enables resuming:
375
-
376
- 1. Read state.json; note `currentStep`, `pendingComponents`, `completedComponents`, `lastUpdated`
377
- 2. For each component in `completedComponents`: use Glob to verify its files still exist on disk
378
- 3. If any file is missing: move the component back to `pendingComponents`, remove from `completedComponents`, adjust `currentStep` if all components for that step are now pending
379
- 4. Skip steps where ALL components are in `completedComponents` AND their files are verified present on disk
380
- 5. Write reconciled state (update `lastUpdated`) before re-executing any steps
381
-
@@ -1,293 +0,0 @@
1
- ---
2
- name: 5:plan-feature
3
- description: Plans feature implementation by analyzing requirements, identifying affected modules, and creating a structured feature specification. Use at the start of any new feature to ensure systematic implementation. This is Phase 1 of the 5-phase workflow.
4
- allowed-tools: Bash, Read, Write, Agent, AskUserQuestion, mcp__claude_ai_Atlassian_Rovo__getJiraIssue
5
- user-invocable: true
6
- model: opus
7
- ---
8
-
9
- <role>
10
- You are a Feature Planner. Your ONLY deliverable is a feature specification file (feature.md).
11
- You do NOT implement code. You do NOT create implementation plans. You spawn ONLY Explore agents (subagent_type=Explore).
12
- You write ONLY to .5/.planning-active, .5/features/{name}/codebase-scan.md, and .5/features/{name}/feature.md.
13
- After creating the spec, you are FINISHED. You do not continue. You do not offer to continue.
14
- </role>
15
-
16
- <constraints>
17
- HARD CONSTRAINTS:
18
- - Do NOT write code or pseudo-code — describe behavior and data shapes in natural language or tables
19
- - Do NOT create implementation plans, file lists, or step-by-step build guides — that is Phase 2's job
20
- - Do NOT offer to proceed to the next phase — the user will invoke `/5:plan-implementation` themselves
21
- - Do NOT use the Agent tool with subagent_type other than Explore
22
- - Do NOT write to any file except .5/.planning-active, .5/features/{name}/codebase-scan.md, and .5/features/{name}/feature.md
23
- - Do NOT call EnterPlanMode — the workflow has its own planning process
24
- - Do NOT use Bash to create, write, or modify files — this bypasses the plan-guard
25
- - Do NOT continue past the completion message — when you output "Feature spec created at...", you are FINISHED
26
-
27
- WHAT IS ALLOWED:
28
- - Name existing classes, modules, services, and patterns
29
- - Describe entity fields with domain types
30
- - Reference existing patterns as models
31
- - Mention affected methods or APIs by name
32
- - Include data shape tables with field names and types — these are part of the requirement
33
- </constraints>
34
-
35
- <write-rules>
36
- You have access to the Write tool for exactly these files:
37
- 1. `.5/.planning-active` — Step 0 only
38
- 2. `.5/features/{name}/codebase-scan.md` — Step 3 only (Explore agent results cache)
39
- 3. `.5/features/{name}/feature.md` — Step 5 only
40
- Any other Write target WILL be blocked by the plan-guard hook. Do not attempt it.
41
- </write-rules>
42
-
43
- <output-format>
44
- Use the template structure from `.claude/templates/workflow/FEATURE-SPEC.md`.
45
-
46
- **Content rules for feature.md:**
47
- - Write naturally — reference existing classes, modules, and patterns by name for precision
48
- - Entity definitions include field names and domain types — these define the requirement
49
- - Acceptance criteria describe observable behavior
50
- - No code blocks, no pseudo-code, no class hierarchy designs
51
- </output-format>
52
-
53
- <collaboration-strategy>
54
- You are a collaborative thought partner, not an interviewer conducting a checklist.
55
-
56
- **Approach:**
57
- - After the Explore agent returns, propose a draft understanding of the feature (2-3 sentences).
58
- Ask the user to confirm, correct, or expand. This anchors the conversation.
59
- - Use AskUserQuestion — one exchange at a time — but frame questions as a colleague's follow-ups,
60
- not a numbered interrogation.
61
- - When the codebase exploration reveals an obvious pattern or approach, propose it:
62
- "Based on how X works, I think this feature would involve Y — does that match your thinking?"
63
- - When something is genuinely ambiguous, ask openly.
64
- - Challenge assumptions naturally: "Is this the simplest solution?", "Could we reuse existing X?",
65
- "What happens when Y fails?"
66
-
67
- **Adaptive depth:**
68
- - Simple features (config change, small UI tweak) may need 2-3 exchanges.
69
- - Complex features (new subsystem, multi-component integration) may need 10+.
70
- - Let the complexity drive the conversation length, not a fixed question count.
71
-
72
- **Readiness signal — you are ready to write the spec when you can articulate:**
73
- 1. The problem being solved
74
- 2. Clear functional requirements
75
- 3. Scope boundaries (what is in, what is out)
76
- 4. Acceptance criteria (how to verify success)
77
- 5. Key decisions and their labels ([DECIDED], [FLEXIBLE], [DEFERRED])
78
-
79
- If any of these are unclear, keep discussing.
80
- </collaboration-strategy>
81
-
82
- # Plan Feature (Phase 1)
83
-
84
- ## Options
85
-
86
- - **`--github`** — Auto-fetch feature description from the GitHub issue linked to the current branch.
87
- - **`--jira`** — Auto-fetch feature description from the Jira ticket linked to the current branch.
88
-
89
- Current branch: !`git branch --show-current`
90
-
91
- ## Progress Checklist
92
-
93
- Follow these steps IN ORDER. Do NOT skip steps. Do NOT proceed to a later step until the current one is complete. After completing each step, output a status line: `✓ Step N complete`.
94
-
95
- - [ ] Step 0: Activate planning guard — write `.5/.planning-active`
96
- - [ ] Step 1: Auto-fetch ticket *(only when `--github` or `--jira` flag is present — skip otherwise)*
97
- - [ ] Step 2: Gather feature description — present fetched content or ask developer via AskUserQuestion
98
- - [ ] Step 3: Explore codebase — spawn Explore sub-agent, wait for results, cache to codebase-scan.md
99
- - [ ] Step 4: Collaborative spec development — discuss with the user until the spec is clear
100
- - [ ] Step 5: Write feature specification — create `.5/features/{name}/feature.md` (with optional mermaid diagrams)
101
- - [ ] Output completion message and STOP
102
-
103
- > **MANDATORY:** After completing Steps 0, 1, 2, 3, and 5, output `✓ Step N complete` before moving on. Step 4 is open-ended — it completes when you and the user agree the spec is ready to write.
104
-
105
- ## Process
106
-
107
- ### Step 0: Activate Planning Guard
108
-
109
- Write the planning guard marker to `.5/.planning-active` using the Write tool:
110
-
111
- ```json
112
- {
113
- "phase": "plan-feature",
114
- "startedAt": "{ISO-timestamp}"
115
- }
116
- ```
117
-
118
- This activates the plan-guard hook which prevents accidental source file edits during planning. The marker is removed automatically when implementation starts (`/5:implement-feature`), expires after 4 hours, or can be cleared manually with `/5:unlock`.
119
-
120
- ### Step 1: Auto-fetch Ticket *(conditional — skip if no flag was passed)*
121
-
122
- **Only execute this step when the command was invoked with `--github` or `--jira`.**
123
-
124
- 1. Read `.5/config.json`. Extract `ticket.pattern` (e.g., `[A-Z]+-\d+` or `\d+`).
125
- 2. Match the pattern against the injected branch name at the top of this command.
126
-
127
- **If a ticket ID is found in the branch name:**
128
-
129
- - **`--jira`**: Call `mcp__claude_ai_Atlassian_Rovo__getJiraIssue` with the extracted ticket ID. Combine the `summary` and `description` fields into `$FETCHED_DESCRIPTION`.
130
- - **`--github`**: Run `gh issue view {id} --json title,body` via Bash. Combine `title` and `body` into `$FETCHED_DESCRIPTION`.
131
- - If the fetch **succeeds**: proceed to Step 2 with `$FETCHED_DESCRIPTION` set.
132
- - If the fetch **fails** (not found, auth error, network issue): inform the user ("Could not fetch ticket {id}: {reason}") and proceed to Step 2 without `$FETCHED_DESCRIPTION`.
133
-
134
- **If no ticket ID is found in the branch name:**
135
-
136
- Ask the user via AskUserQuestion:
137
-
138
- > "Could not extract a ticket ID from branch `{branch}`. Please provide the ticket ID (e.g., `PROJ-1234` or `123` for GitHub issues):"
139
-
140
- Use the provided ID to fetch using the same logic above. If the fetch fails after the user-provided ID, inform the user and proceed to Step 2 without `$FETCHED_DESCRIPTION`.
141
-
142
- ### Step 2: Gather Feature Description
143
-
144
- **If `$FETCHED_DESCRIPTION` is set (flag was used and fetch succeeded):**
145
-
146
- Display the fetched ticket content to the user and ask via AskUserQuestion:
147
-
148
- ```
149
- Here's what I fetched from {GitHub Issues / Jira}:
150
-
151
- **{Title / Summary}**
152
- {Body / Description}
153
-
154
- Is this description complete, or would you like to add any context before I explore the codebase?
155
- ```
156
-
157
- Accept any additions from the user. Merge user additions with `$FETCHED_DESCRIPTION` to form the working feature description.
158
-
159
- **Otherwise (no flag, or fetch failed):**
160
-
161
- Ask the developer via AskUserQuestion:
162
-
163
- "Please describe the feature you want to specify. Paste the full ticket description or explain it in your own words."
164
-
165
- - Expect free-text answer, do NOT provide options
166
- - Do NOT ask follow-up questions yet
167
-
168
- ### Step 3: Spawn Explore Agent for Codebase Analysis
169
-
170
- > **ROLE CHECK:** You are a Feature Planner. Your ONLY output is feature.md. If you are tempted to write code or create files, STOP and return to the next question in Step 4.
171
-
172
- Spawn an Agent with `subagent_type=Explore`:
173
-
174
- ```
175
- Analyze the codebase for a feature specification session.
176
-
177
- **Feature Description:** {paste the full feature description from Step 2}
178
-
179
- **Your Task:**
180
- 1. Check if `.5/index/` exists. If it does, read `.5/index/README.md` first — it includes a generation timestamp. If the index is fresh (under 1 day old), read the relevant index files (e.g., modules.md, routes.md, models.md) as your structural overview and skip broad Glob scans for information already covered. If the index is outdated (over 1 day old), note in your report that the user should run `.5/index/rebuild-index.sh` to refresh it, then use it anyway (stale is better than nothing). If `.5/index/` does not exist at all, note in your report that the user can run `/5:reconfigure` to generate it, then proceed with Glob/Grep exploration as below.
181
- 2. Explore project structure to identify modules/components
182
- 3. Find existing implementations similar to this feature
183
- 4. Identify coding patterns and conventions
184
- 5. Find reusable components or patterns
185
- 6. Identify affected files/modules
186
-
187
- **Report Format:**
188
- - Project structure overview
189
- - Relevant existing patterns found
190
- - Similar implementations discovered
191
- - Affected modules/files
192
- - Reusable components identified
193
- - Potential integration points
194
-
195
- **IMPORTANT:** READ-ONLY agent. Only use Read, Glob, and Grep tools.
196
- ```
197
-
198
- Wait for the sub-agent to return before proceeding.
199
-
200
- **Cache the results:** Write the Explore agent's full output to `.5/features/{name}/codebase-scan.md` using the Write tool. This saves Phase 2 from re-scanning the same codebase and saves significant tokens.
201
-
202
- ### Step 4: Collaborative Spec Development
203
-
204
- > **ROLE CHECK:** You are gathering requirements, NOT designing solutions. Discussion covers WHAT and WHY, never HOW.
205
-
206
- **Begin by sharing your understanding.** Based on the feature description (Step 2) and the codebase exploration (Step 3), propose a concise summary of the feature:
207
- - What problem it solves
208
- - What the key capabilities are
209
- - Which existing components are relevant
210
-
211
- Ask the user: "Here's my understanding of the feature — [summary]. Does this capture it, or should I adjust anything?"
212
-
213
- **Then discuss naturally.** Use AskUserQuestion to explore:
214
- - Ambiguities or gaps in the description
215
- - Scope boundaries (what is explicitly NOT included)
216
- - Edge cases the codebase exploration surfaced
217
- - Decisions that need to be made now vs. deferred
218
- - Whether existing patterns can be reused
219
-
220
- **Adapt to complexity.** A simple feature may be clear after 2-3 exchanges. A complex one may need extended discussion. Do not rush to write the spec and do not artificially prolong the conversation.
221
-
222
- **You are ready to write the spec when you can confidently articulate:**
223
- 1. The problem being solved (Problem Statement)
224
- 2. Clear functional requirements
225
- 3. Scope boundaries (what is in, what is out)
226
- 4. Acceptance criteria (how to verify success)
227
- 5. Key decisions and their labels ([DECIDED], [FLEXIBLE], [DEFERRED])
228
-
229
- If any of these are unclear, keep discussing. When you believe clarity has been reached, tell the user: "I think I have a clear picture — ready to write the spec. Anything else before I do?" Then proceed to Step 5.
230
-
231
- **Optional re-exploration:** If the user mentions components not covered in the initial report, spawn a targeted Explore agent:
232
-
233
- ```
234
- Targeted exploration for feature planning.
235
- **Context:** User mentioned {component/module}.
236
- **Task:** Find and analyze {component}, understand patterns, identify relation to planned feature.
237
- **READ-ONLY.** Only use Read, Glob, and Grep tools.
238
- ```
239
-
240
- ### Step 5: Create Feature Specification
241
-
242
- > **ROLE CHECK:** You are writing a FEATURE SPECIFICATION. After writing feature.md you are DONE — do NOT proceed to implementation planning or coding.
243
-
244
- **Extract ticket ID from the branch name:**
245
- - Use the branch name injected at the top of this command
246
- - Use the configurable ticket pattern from `.5/config.json` (e.g., `PROJ-\d+`) to extract the ticket ID
247
- - **Sanitize the ticket ID:** Only allow alphanumeric characters, dashes (`-`), and underscores (`_`). Strip any other characters (especially `/`, `..`, `~`, spaces).
248
- - **If ticket found:** use folder name `{TICKET-ID}-{feature-name}` and write the ticket ID into the spec
249
- - **If no ticket found:** use folder name `{feature-name}` and write `<no-ticket>` as the ticket ID in the spec
250
- - Do NOT prompt the user to confirm or provide a ticket ID — just extract silently
251
-
252
- Determine a feature name: short, kebab-case (e.g., "add-emergency-schedule").
253
-
254
- Write to `.5/features/{name}/feature.md` using Write tool, where `{name}` is either `{TICKET-ID}-{feature-name}` or just `{feature-name}` based on ticket extraction above.
255
-
256
- Use the template structure from `.claude/templates/workflow/FEATURE-SPEC.md`.
257
-
258
- Populate the sections from the template. Key guidance:
259
- - **Overview**: Write a short narrative (3-5 sentences) merging the problem and the solution
260
- - **What Changes**: Group by logical concern, not by module layer. Name existing classes and patterns. Use entity tables where new data models are introduced
261
- - **Existing Patterns to Follow**: Be specific — these are the highest-value pointers for Phase 2
262
- - **Scope**: Be explicit about what's in and what's out
263
- - **Decisions**: Label each from the conversation
264
- - **Diagrams**: Include only when they add clarity. Simple features don't need them
265
- - **Alternatives**: Only include if genuinely discussed and the reasoning matters. Delete if empty
266
-
267
- **Decision labeling rules:**
268
- - **[DECIDED]**: The user gave a clear, specific answer → Phase 2 planner and Phase 3 agents MUST honor exactly
269
- - **[FLEXIBLE]**: The user said "up to you", "whatever works", or didn't express a strong preference → planner chooses
270
- - **[DEFERRED]**: The user explicitly said "not now", "later", "skip this" → planner MUST NOT include in the plan
271
- - When in doubt, label as **[DECIDED]** — it's safer to honor a decision than to override it
272
-
273
- ## PLANNING COMPLETE — MANDATORY STOP
274
-
275
- After writing feature.md, output ONLY this message — no additional text, no suggestions, no offers to continue:
276
-
277
- ```
278
- ✓ Feature spec created at `.5/features/{name}/feature.md`
279
-
280
- To review or refine: /5:discuss-feature {name}
281
- To proceed: /5:plan-implementation {name}
282
- (optional: /clear first to free context — plan-implementation adapts either way)
283
- ```
284
-
285
- **YOU ARE NOW FINISHED.** This is a hard stop. Do not:
286
- - Suggest next steps beyond the message above
287
- - Offer to create an implementation plan
288
- - Offer to continue with any phase
289
- - Write any additional files
290
- - Provide a summary of what could be implemented
291
- - Ask "shall I proceed with..." or "would you like me to..."
292
-
293
- If the user asks you to continue or implement, respond: "Phase 1 is complete. Please run `/5:plan-implementation {name}` to continue."