5-phase-workflow 1.5.3 → 1.6.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.
package/bin/install.js CHANGED
@@ -273,6 +273,7 @@ function getWorkflowManagedFiles() {
273
273
  hooks: [
274
274
  'statusline.js',
275
275
  'check-updates.js',
276
+ 'check-reconfig.js',
276
277
  'plan-guard.js',
277
278
  'config-guard.js'
278
279
  ],
@@ -491,6 +492,7 @@ function showCommandsHelp(isGlobal) {
491
492
  log.info(' /5:verify-implementation - Verify implementation (Phase 4)');
492
493
  log.info(' /5:review-code - Code review (Phase 5)');
493
494
  log.info(' /5:configure - Interactive project setup');
495
+ log.info(' /5:reconfigure - Refresh docs/skills (no Q&A)');
494
496
  log.info(' /5:unlock - Remove planning guard lock');
495
497
  log.info('');
496
498
  log.info(`Config file: ${path.join(getDataPath(isGlobal), 'config.json')}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5-phase-workflow",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
4
4
  "description": "A 5-phase feature development workflow for Claude Code",
5
5
  "bin": {
6
6
  "5-phase-workflow": "bin/install.js"
@@ -279,6 +279,12 @@ If no patterns/commands detected:
279
279
  - Inform user: "No common patterns detected. Would you like to specify patterns manually?"
280
280
  - Allow manual entry of pattern names/locations or command names
281
281
 
282
+ **2l. Git-ignore `.5/features/` folder:**
283
+ - "The `.5/features/` folder will contain feature specs, implementation plans, and state files. Would you like to add it to `.gitignore`?"
284
+ - Options:
285
+ 1. "Yes, add to .gitignore (recommended)" — workflow artifacts stay local, not tracked in version control
286
+ 2. "No, track in git" — useful if you want to share specs and plans with your team
287
+
282
288
  ### Step 2.5: Write config.json
283
289
 
284
290
  Using the values gathered from Steps 1 and 2, write `.5/config.json` directly.
@@ -330,12 +336,37 @@ mkdir -p .5
330
336
  "commitMessage": {
331
337
  "pattern": "{ticket-id} {short-description}"
332
338
  }
339
+ },
340
+ "dotFiveFolder": {
341
+ "gitignore": true
333
342
  }
334
343
  }
335
344
  ```
336
345
 
337
346
  Fill all values from user responses. Write with pretty-printed JSON. Read back to verify correctness.
338
347
 
348
+ **Update `.5/version.json` with configure timestamp:**
349
+
350
+ After writing config.json, update `.5/version.json` so the reconfigure reminder can track staleness:
351
+ 1. Read `.5/version.json` (if it exists)
352
+ 2. Set `configuredAt` to the current ISO timestamp (`new Date().toISOString()`)
353
+ 3. Set `configuredAtCommit` to the current short commit hash (run `git rev-parse --short HEAD`)
354
+ 4. Write back `.5/version.json` preserving all other fields
355
+
356
+ **Apply `.gitignore` if selected:**
357
+
358
+ If the user chose to gitignore the `.5/features/` folder:
359
+ 1. Check if `.gitignore` exists in the project root
360
+ 2. If it exists, check if `.5/features/` is already listed — if not, append `.5/features/` on a new line
361
+ 3. If `.gitignore` does not exist, create it with `.5/features/` as the first entry
362
+ 4. Inform the user: "Added `.5/features/` to `.gitignore`"
363
+
364
+ **Always gitignore `.5/.reconfig-reminder`:**
365
+
366
+ Ensure `.5/.reconfig-reminder` is gitignored (it's a transient runtime flag that should never be committed):
367
+ 1. Check if `.gitignore` exists in the project root — create it if not
368
+ 2. Check if `.5/.reconfig-reminder` is already listed — if not, append `.5/.reconfig-reminder` on a new line
369
+
339
370
  ### Step 3: Create Feature Spec
340
371
 
341
372
  Write `.5/features/CONFIGURE/feature.md` containing all gathered data:
@@ -421,8 +452,4 @@ Tell the user:
421
452
  4. "After that: Continue with `/5:implement-feature CONFIGURE` -> `/5:verify-implementation` -> `/5:review-code` (clearing context between each phase)"
422
453
 
423
454
  ## Related Documentation
424
-
425
- - [5-Phase Workflow Guide](../../docs/workflow-guide.md)
426
455
  - [configure-project skill](../../skills/configure-project/SKILL.md)
427
- - [/5:plan-feature command](./plan-feature.md)
428
- - [/5:plan-implementation command](./plan-implementation.md)
@@ -251,9 +251,3 @@ Skill: "Feature spec updated. Changes:
251
251
  - Added: Full CRUD operations
252
252
  Next: /clear then /5:plan-implementation PROJ-1234-add-feature"
253
253
  ```
254
-
255
- ## Related Documentation
256
-
257
- - [5-Phase Workflow Guide](../docs/workflow-guide.md)
258
- - [plan-feature command](./plan-feature.md)
259
- - [plan-implementation command](./plan-implementation.md)
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 5:implement-feature
3
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, Bash
4
+ allowed-tools: Task, Read, Write, Glob, Grep, Bash, TaskCreate, TaskUpdate, TaskList
5
5
  context: fork
6
6
  user-invocable: true
7
7
  ---
@@ -21,7 +21,18 @@ You are a thin orchestrator:
21
21
  - Track progress
22
22
  - Report completion
23
23
 
24
- Do NOT write code directly. Spawn agents to do the work.
24
+ **DO NOT:**
25
+ - Write code directly — spawn agents
26
+ - Skip state file updates between steps
27
+ - Mark a step complete before writing state
28
+ - Proceed to next step if state write fails
29
+ - Use `git add .` at any point
30
+
31
+ **Key Principles:**
32
+ - Thin orchestrator: read, delegate, track, report
33
+ - State is the source of truth: write it before moving on
34
+ - Forward progress: failed components are logged, not blocking
35
+ - Resumable: state enables restart from any interrupted step
25
36
 
26
37
  ## Process
27
38
 
@@ -43,9 +54,17 @@ Also read `.5/config.json` and extract:
43
54
  - `git.autoCommit` (boolean, default `false`)
44
55
  - `git.commitMessage.pattern` (string, default `{ticket-id} {short-description}`)
45
56
 
57
+ **Check for existing state.json** at `.5/features/{feature-name}/state.json`:
58
+
59
+ - **`status: "completed"`** → Tell the user "This feature is already implemented." Suggest `/5:verify-implementation {feature-name}`. Stop.
60
+ - **`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`).
61
+ - **`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"
62
+ - If Resume: proceed as in-progress case above
63
+ - If Restart: delete state.json, proceed normally from Step 2
64
+
46
65
  ### Step 2: Initialize State
47
66
 
48
- Create `.5/features/{feature-name}/state.json`:
67
+ Create `.5/features/{feature-name}/state.json` with the full components table parsed from the plan:
49
68
 
50
69
  ```json
51
70
  {
@@ -53,21 +72,45 @@ Create `.5/features/{feature-name}/state.json`:
53
72
  "feature": "{feature-name}",
54
73
  "status": "in-progress",
55
74
  "currentStep": 1,
56
- "completed": [],
57
- "failed": [],
58
- "startedAt": "{ISO-timestamp}"
75
+ "totalSteps": "{N from plan}",
76
+ "pendingComponents": [
77
+ { "name": "{component-name}", "step": 1, "file": "{file-path}" }
78
+ ],
79
+ "completedComponents": [],
80
+ "failedAttempts": [],
81
+ "verificationResults": {},
82
+ "commitResults": [],
83
+ "startedAt": "{ISO-timestamp}",
84
+ "lastUpdated": "{ISO-timestamp}"
59
85
  }
60
86
  ```
61
87
 
88
+ `pendingComponents` is populated by parsing the full components table from plan.md at startup — one entry per row.
89
+
90
+ **MANDATORY VERIFICATION:** Read state.json back immediately after writing. Confirm `status` is `"in-progress"` and `pendingComponents` is non-empty.
91
+ If the read fails or content is wrong, stop: "Failed to initialize state file. Cannot proceed safely."
92
+
62
93
  Then remove the planning guard marker (planning is over, implementation is starting):
63
94
 
64
95
  ```bash
65
96
  rm -f .5/.planning-active
66
97
  ```
67
98
 
99
+ ### Step 2b: Create Progress Checklist
100
+
101
+ Before executing any steps, create one TaskCreate entry per step:
102
+ - Subject: `"Step {N}: {comma-separated component names}"`
103
+ - activeForm: `"Executing step {N}"`
104
+
105
+ Plus one final task:
106
+ - Subject: `"Run verification"`
107
+ - activeForm: `"Running build and tests"`
108
+
109
+ Then mark the task for Step 1 as `in_progress`.
110
+
68
111
  ### Step 3: Execute Steps
69
112
 
70
- Group components by step number from the plan. For each step:
113
+ Group components by step number from the plan. For each step (starting from `currentStep` in state.json):
71
114
 
72
115
  **3a. Analyze step for parallel execution**
73
116
 
@@ -110,32 +153,69 @@ The agent file defines the implementation process, output format, and deviation
110
153
  **3d. Process results**
111
154
 
112
155
  Collect results from all agents (parallel or sequential). Parse the `---RESULT---` block from each agent's response. For each:
113
- - If `STATUS: success` → mark components as completed, note files from `FILES_CREATED`/`FILES_MODIFIED`
114
- - If `STATUS: failed` → mark components as failed, log the `ERROR` message
115
- - If no `---RESULT---` block found → treat the response as success if the agent reported creating/modifying files, otherwise treat as failed
156
+ - If `STATUS: success` → component succeeded; note files from `FILES_CREATED`/`FILES_MODIFIED`
157
+ - If `STATUS: failed` → component failed; log the `ERROR` message
158
+ - If no `---RESULT---` block found → treat as success if the agent reported creating/modifying files, otherwise treat as failed
116
159
 
117
160
  Update state.json:
118
- ```json
119
- {
120
- "currentStep": {N+1},
121
- "completed": [...previous, ...newlyCompleted],
122
- "failed": [...previous, ...newlyFailed]
123
- }
124
- ```
161
+ - Move succeeded components: remove from `pendingComponents`, append to `completedComponents` as:
162
+ ```json
163
+ { "name": "{name}", "step": {N}, "timestamp": "{ISO}", "filesCreated": [...], "filesModified": [...] }
164
+ ```
165
+ - Move failed components: append to `failedAttempts` as:
166
+ ```json
167
+ { "component": "{name}", "step": {N}, "error": "{message}", "timestamp": "{ISO}", "retryCount": 0 }
168
+ ```
169
+ - Increment `currentStep`
170
+ - Update `lastUpdated`
171
+
172
+ **MANDATORY VERIFICATION:** Read state.json back and confirm `lastUpdated` changed.
173
+ If verify fails, stop: "State write failed after step {N}. Cannot proceed safely."
174
+
175
+ Mark the current step's TaskCreate task as `completed`. Mark the next step's task as `in_progress`.
176
+
177
+ **3d2. Retry failed components (max 2 retries)**
178
+
179
+ For each component that returned `STATUS: failed`:
180
+
181
+ 1. **Assess the error:**
182
+ - **Small fix** (missing import, wrong path, syntax error): Fix with Edit tool directly in main context. Mark as completed. This counts as retry 1.
183
+ - **Large fix** (logic error, wrong pattern, missing context): Re-spawn the component-executor agent with the same prompt plus an `## Error Context` block describing the previous failure. This counts as retry 1.
184
+
185
+ 2. If the retry also fails:
186
+ - Update `retryCount: 2` in the component's `failedAttempts` entry
187
+ - Use AskUserQuestion: "Component '{name}' failed twice. Error: {error}. How would you like to proceed?"
188
+ Options: "Skip and continue" / "I'll fix manually — pause"
189
+ - If "Skip": log the skip, move on
190
+ - If "Pause": update state.json with current progress, stop and wait for user
191
+
192
+ Never retry more than 2 times per component.
193
+
194
+ **3d3. Per-step file existence check**
195
+
196
+ For each file listed in `FILES_CREATED` from successful agents: use Glob to verify the file exists on disk.
197
+
198
+ If a reported file is missing:
199
+ - Remove the component from `completedComponents`
200
+ - Return it to `pendingComponents`
201
+ - Add a `failedAttempts` entry: `{ "component": "{name}", "step": {N}, "error": "File not found after creation: {path}", "timestamp": "{ISO}", "retryCount": 0 }`
202
+ - Apply retry logic from 3d2
125
203
 
126
204
  **3e. Auto-Commit Step (if enabled)**
127
205
 
128
- Only fires if `git.autoCommit: true` AND at least one component succeeded. Stage only the step's specific files (never `git add .`), commit with configured `git.commitMessage.pattern` (body: one bullet per component). If commit fails, log warning in `state.json` `commitResults` and continue.
206
+ 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.
129
207
 
130
208
  **3f. Handle failures**
131
209
 
132
- If any component failed:
133
- - Log the failure in state.json
210
+ If any component failed after retries exhausted:
211
+ - Entry remains in `failedAttempts` with `retryCount: 2`
134
212
  - Continue to next step (don't block on failures)
135
- - Report failures at the end
213
+ - Failures are reported in the completion report
136
214
 
137
215
  ### Step 4: Run Verification
138
216
 
217
+ Mark the "Run verification" TaskCreate task as `in_progress`.
218
+
139
219
  After all steps complete, run build and test:
140
220
 
141
221
  ```bash
@@ -146,10 +226,24 @@ After all steps complete, run build and test:
146
226
  {test-command}
147
227
  ```
148
228
 
229
+ Update `verificationResults` in state.json:
230
+ ```json
231
+ {
232
+ "buildStatus": "success|failed",
233
+ "testStatus": "success|skipped|failed",
234
+ "builtAt": "{ISO-timestamp}"
235
+ }
236
+ ```
237
+ Also update `lastUpdated`.
238
+
239
+ **MANDATORY VERIFICATION:** Read state.json back and confirm `verificationResults.builtAt` is set.
240
+
149
241
  If build or tests fail:
150
242
  - Record in state.json
151
243
  - Report to user with error details
152
244
 
245
+ Mark the "Run verification" TaskCreate task as `completed`.
246
+
153
247
  ### Step 5: Update State and Report
154
248
 
155
249
  Update state.json:
@@ -157,22 +251,25 @@ Update state.json:
157
251
  {
158
252
  "status": "completed",
159
253
  "completedAt": "{ISO-timestamp}",
160
- "buildStatus": "success|failed",
161
- "testStatus": "success|failed"
254
+ "lastUpdated": "{ISO-timestamp}"
162
255
  }
163
256
  ```
164
257
 
258
+ **MANDATORY VERIFICATION:** Read state.json back and confirm `status` is `"completed"`.
259
+ If read fails, warn the user but do not re-attempt — the implementation work is done; only tracking failed.
260
+
165
261
  Tell the user:
166
262
  ```
167
263
  Implementation complete!
168
264
 
169
265
  {ticket}: {feature-name}
170
266
  - {N} components created/modified
267
+ - {M} components skipped (failures that exhausted retries)
171
268
  - Build: {status}
172
269
  - Tests: {status}
173
270
  {If git.autoCommit was true: "- Commits: {N} atomic commits created"}
174
271
 
175
- {If any failures: list them}
272
+ {If any failures: list them with errors}
176
273
 
177
274
  Next steps:
178
275
  1. Run `/clear` to reset context (recommended between phases)
@@ -181,18 +278,47 @@ Next steps:
181
278
 
182
279
  ## Handling Interruptions
183
280
 
184
- If implementation is interrupted, the state file allows resuming:
185
- - Read state.json
186
- - For each step marked as completed, verify the output files still exist on disk using Glob
187
- - If any completed files are missing, move those components back to pending and re-run them
188
- - Skip steps where all components are in `completed` AND their files verified to exist
189
- - Resume from `currentStep`
281
+ If implementation is interrupted, the state file enables resuming:
282
+
283
+ 1. Read state.json; note `currentStep`, `pendingComponents`, `completedComponents`, `lastUpdated`
284
+ 2. For each component in `completedComponents`: use Glob to verify its files still exist on disk
285
+ 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
286
+ 4. Skip steps where ALL components are in `completedComponents` AND their files are verified present on disk
287
+ 5. Write reconciled state (update `lastUpdated`) before re-executing any steps
190
288
 
191
289
  ## Example Flow
192
290
 
193
291
  ```
194
- Step 1: 2 simple components → 2 parallel haiku agents → update state
195
- Step 2: 2 moderate components → 2 parallel agents → update state
196
- Step 3: 1 complex component → 1 sonnet agent → update state
197
- Step 4: Verify (build + test) → update state → report
292
+ Step 1: 2 simple components → 2 parallel haiku agents → update state → verify write
293
+ Step 2: 2 moderate components → 2 parallel agents → update state → verify write
294
+ Step 3: 1 complex component → 1 sonnet agent → update state → verify write
295
+ Step 4: Verify (build + test) → update verificationResultsverify write → report
198
296
  ```
297
+
298
+ ## Instructions Summary
299
+
300
+ ### Before starting:
301
+ 1. Check for existing state.json → handle resume / restart / completed cases
302
+ 2. Read plan.md → parse components table, implementation notes, verification commands
303
+ 3. Read config.json → extract `git.autoCommit`, `git.commitMessage.pattern`
304
+ 4. Initialize state.json with richer schema → **MANDATORY: verify write**
305
+ 5. Create TaskCreate tasks for all steps + verification → mark step 1 `in_progress`
306
+
307
+ ### For each step:
308
+ 1. Determine parallelism (same-step components = parallel)
309
+ 2. Determine model per component (simple→haiku, complex→sonnet)
310
+ 3. Spawn agents (one per component, parallel when possible)
311
+ 4. Collect results, parse `---RESULT---` blocks
312
+ 5. Run per-step file existence check (Glob) on `FILES_CREATED`
313
+ 6. Run retry logic for failures (max 2 retries per component)
314
+ 7. Update state.json → **MANDATORY: verify write**
315
+ 8. Run auto-commit if enabled and step had successes (stage specific files only)
316
+ 9. Mark step task `completed`, mark next step task `in_progress`
317
+
318
+ ### After all steps:
319
+ 1. Run build command
320
+ 2. Run test command
321
+ 3. Update `verificationResults` in state.json → **verify write**
322
+ 4. Update `status: "completed"` in state.json → **MANDATORY: verify write**
323
+ 5. Mark verification task `completed`
324
+ 6. Report to user
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 5:quick-implement
3
3
  description: Execute small, focused implementations quickly with state tracking and atomic commits. Skips extensive planning phases and verification agents - use for tasks where you know exactly what to do.
4
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion, Skill, mcp__jetbrains__*
4
+ allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion, Skill, TaskCreate, TaskUpdate, TaskList, mcp__jetbrains__*
5
5
  context: fork
6
6
  user-invocable: true
7
7
  ---
@@ -30,6 +30,18 @@ Your job is NOT:
30
30
  ❌ Create feature spec files
31
31
  ❌ Commit without config (only if git.autoCommit is enabled)
32
32
 
33
+ **DO NOT:**
34
+ - Write code directly without using a Skill or spawning an agent
35
+ - Skip state file updates after each component
36
+ - Mark a component complete before writing state
37
+ - Proceed if a state write fails
38
+ - Use `git add .` at any point
39
+
40
+ **Key Principles:**
41
+ - Small scope: 1-5 files, treated as a single logical step
42
+ - State is the source of truth: write it after every component
43
+ - Resumable: state enables restart from the last completed component
44
+
33
45
  ## Process
34
46
 
35
47
  ### Step 1: Get Task Description
@@ -66,6 +78,15 @@ Generate a slug from `$DESCRIPTION` using string manipulation (do NOT use bash f
66
78
 
67
79
  Set `feature_name` to `${TICKET_ID}-${slug}`.
68
80
 
81
+ ### Step 3b: Check for Existing State
82
+
83
+ Check if `.5/features/${feature_name}/state.json` already exists:
84
+
85
+ - **`status: "completed"`** → Tell the user "This task is already implemented." Suggest `/clear` before starting a new task. Stop.
86
+ - **`status: "in-progress"`** → Use AskUserQuestion: "A previous run was interrupted at component '{last completed}'. How would you like to proceed?" Options: "Resume from where I left off" / "Restart from the beginning"
87
+ - If Resume: skip Steps 4–7 initialization; go directly to Step 7b (recreate TaskCreate tasks) and Step 8 (resume remaining `pendingComponents`)
88
+ - If Restart: delete state.json, proceed normally from Step 4
89
+
69
90
  ### Step 4: Analyze and Plan
70
91
 
71
92
  1. **Identify affected files** using Glob and Grep
@@ -124,9 +145,32 @@ Use AskUserQuestion:
124
145
 
125
146
  **CRITICAL**: You MUST create the state file before starting implementation. This enables resumability if work is interrupted.
126
147
 
127
- Create state file at `.5/features/${feature_name}/state.json` with fields: `ticket`, `feature`, `phase: "quick-implementation"`, `status: "in-progress"`, `currentStep: 1`, `totalSteps: 1`, `completed: []`, `pending: [from plan]`, `failed: []`, `verificationResults: {}`, `startedAt`, `lastUpdated`.
148
+ Create state file at `.5/features/${feature_name}/state.json`:
149
+
150
+ ```json
151
+ {
152
+ "ticket": "{ticket-id}",
153
+ "feature": "{feature_name}",
154
+ "phase": "quick-implementation",
155
+ "status": "in-progress",
156
+ "currentStep": 1,
157
+ "totalSteps": 1,
158
+ "pendingComponents": [
159
+ { "name": "{component-name}", "step": 1, "file": "{file-path}" }
160
+ ],
161
+ "completedComponents": [],
162
+ "failedAttempts": [],
163
+ "verificationResults": {},
164
+ "commitResults": [],
165
+ "startedAt": "{ISO-timestamp}",
166
+ "lastUpdated": "{ISO-timestamp}"
167
+ }
168
+ ```
169
+
170
+ `pendingComponents` is populated from the approved plan's components table — one entry per row.
128
171
 
129
- Verify the file was written correctly with Read tool. If creation fails, stop and report error.
172
+ **MANDATORY VERIFICATION:** Read state.json back immediately after writing. Confirm `status` is `"in-progress"` and `pendingComponents` is non-empty.
173
+ If the read fails or content is wrong, stop: "Failed to initialize state file. Cannot proceed safely."
130
174
 
131
175
  Then remove the planning guard marker (implementation is starting):
132
176
 
@@ -134,26 +178,51 @@ Then remove the planning guard marker (implementation is starting):
134
178
  rm -f .5/.planning-active
135
179
  ```
136
180
 
181
+ ### Step 7b: Create Progress Checklist
182
+
183
+ Create one TaskCreate entry per component:
184
+ - Subject: `"Implement {component-name}"`
185
+ - activeForm: `"Implementing {component-name}"`
186
+
187
+ Plus one final task:
188
+ - Subject: `"Run verification"`
189
+ - activeForm: `"Running build and tests"`
190
+
191
+ Mark the first component's task as `in_progress`.
192
+
137
193
  ### Step 8: Execute Implementation
138
194
 
139
195
  **Decision criteria for execution approach:**
140
196
 
141
197
  - **Direct execution** (1-2 components, simple edits): Execute skills directly in current context
142
- - **Step-executor** (3+ components or complex work): Spawn step-executor agent
198
+ - **Agent delegation** (3+ components or complex work): Spawn a general-purpose agent
143
199
 
144
200
  #### Direct Execution
145
201
 
146
- For each component:
202
+ For each component in `pendingComponents`:
147
203
  1. Invoke appropriate skill using Skill tool
148
- 2. **Update state file after each component** (MANDATORY):
204
+ 2. Use Glob to verify `FILES_CREATED` exist on disk
205
+ 3. **Update state file after each component** (MANDATORY):
149
206
  - Read current state file
150
- - Move component from `pending` to `completed`
207
+ - Move component from `pendingComponents` to `completedComponents`:
208
+ ```json
209
+ { "name": "{name}", "step": 1, "timestamp": "{ISO}", "filesCreated": [...], "filesModified": [...] }
210
+ ```
151
211
  - Update `lastUpdated` timestamp
152
212
  - Write back to state file
153
- - Verify write succeeded
154
- 3. Track created/modified files
213
+ - **Verify write:** Read state.json back and confirm `lastUpdated` changed. If verify fails, stop.
214
+ 4. Mark component's TaskCreate task as `completed`. Mark next component's task as `in_progress`.
215
+
216
+ **If a component fails:**
217
+ - **Small fix** (syntax, import, path): Apply fix with Edit tool directly, retry the skill. Count as retry 1.
218
+ - **Large fix** (logic error, wrong pattern): Re-invoke skill with additional context. Count as retry 1.
219
+ - If retry also fails: Use AskUserQuestion: "Component '{name}' failed twice. Error: {error}. How to proceed?" Options: "Skip and continue" / "I'll fix manually — pause"
220
+ - Never retry more than 2 times. Record failures in `failedAttempts`:
221
+ ```json
222
+ { "component": "{name}", "step": 1, "error": "{message}", "timestamp": "{ISO}", "retryCount": {0|1|2} }
223
+ ```
155
224
 
156
- #### Step-Executor Delegation
225
+ #### Agent Delegation
157
226
 
158
227
  Determine the model based on the highest complexity in the plan's components:
159
228
  - All components `simple` → `haiku`
@@ -191,8 +260,12 @@ Task tool call:
191
260
  3. Verify the change
192
261
 
193
262
  ## Output
194
- Report what you created/modified:
195
- - {path}: {brief description}
263
+ End your response with a ---RESULT--- block:
264
+ ---RESULT---
265
+ STATUS: success|failed
266
+ FILES_CREATED: path/to/file1, path/to/file2
267
+ FILES_MODIFIED: path/to/file3
268
+ ERROR: {error message if failed}
196
269
 
197
270
  ## Rules
198
271
  - Find patterns from existing code, don't invent conventions
@@ -200,16 +273,22 @@ Task tool call:
200
273
  - Don't interact with user - just execute and report
201
274
  ```
202
275
 
203
- Process results and **update state file** (MANDATORY):
204
- - Read current state file
205
- - Move completed components from `pending` to `completed`
206
- - Record any failures in `failed`
207
- - Update `lastUpdated` timestamp
208
- - Write back to state file
209
- - Verify write succeeded
276
+ After the agent returns:
277
+ 1. Parse the `---RESULT---` block. If missing, treat as success if files were mentioned, otherwise failed.
278
+ 2. **File existence check:** Use Glob to verify each file in `FILES_CREATED` exists on disk. If a file is missing, treat that component as failed.
279
+ 3. **Retry logic:** For any `STATUS: failed` component or missing file, re-spawn the agent with an `## Error Context` block (counts as retry 1). If retry fails again, use AskUserQuestion as in direct execution.
280
+ 4. **Update state file** (MANDATORY):
281
+ - Move succeeded components: remove from `pendingComponents`, append to `completedComponents` with structured object
282
+ - Move failed components: append to `failedAttempts` with `retryCount`
283
+ - Update `lastUpdated`
284
+ - Write back to state file
285
+ - **Verify write:** Read state.json back and confirm `lastUpdated` changed. If verify fails, stop.
286
+ 5. Mark TaskCreate tasks: completed components → `completed`, remaining → adjust `in_progress`.
210
287
 
211
288
  ### Step 9: Verification
212
289
 
290
+ Mark the "Run verification" TaskCreate task as `in_progress`.
291
+
213
292
  Run build verification if a build skill is configured:
214
293
 
215
294
  **If build skill is available:**
@@ -232,17 +311,39 @@ Skill tool call:
232
311
  args: "{affected test modules}"
233
312
  ```
234
313
 
314
+ Update `verificationResults` in state.json:
315
+ ```json
316
+ {
317
+ "buildStatus": "success|failed",
318
+ "testStatus": "success|skipped|failed",
319
+ "builtAt": "{ISO-timestamp}"
320
+ }
321
+ ```
322
+ Also update `lastUpdated`. **Verify write:** Read state.json back and confirm `verificationResults.builtAt` is set.
323
+
324
+ Mark the "Run verification" TaskCreate task as `completed`.
325
+
235
326
  ### Step 9b: Auto-Commit (if enabled)
236
327
 
237
- Only fires if `git.autoCommit: true` AND build passed. Creates a single commit: stage only plan files (never `git add .`), commit with configured `git.commitMessage.pattern` (body: one bullet per component). If commit fails, log warning and continue.
328
+ Only fires if `git.autoCommit: true` AND build passed. Stage only the component 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.
238
329
 
239
330
  ### Step 10: Update State and Report (MANDATORY)
240
331
 
241
332
  **CRITICAL**: You MUST update the state file to mark completion.
242
333
 
243
- Update state file to `status: "completed"`, `phase: "completed"`, with `verificationResults` (buildStatus, testStatus, timestamp), `completedAt`, `lastUpdated`. Verify the write.
334
+ Update state file:
335
+ ```json
336
+ {
337
+ "status": "completed",
338
+ "completedAt": "{ISO-timestamp}",
339
+ "lastUpdated": "{ISO-timestamp}"
340
+ }
341
+ ```
342
+
343
+ **MANDATORY VERIFICATION:** Read state.json back and confirm `status` is `"completed"`.
344
+ If read fails, warn the user but do not re-attempt — the implementation work is done; only tracking failed.
244
345
 
245
- Report: ticket, description, files created/modified, build/test status, commit status (if auto-commit), and next steps (commit if needed, `/clear` before new task).
346
+ Report: ticket, description, files created/modified, build/test status, commit status (if auto-commit), skipped components (if any), and next steps (manual commit if needed, `/clear` before new task).
246
347
 
247
348
  **🛑 YOUR JOB IS COMPLETE. DO NOT START NEW TASKS.**
248
349
 
@@ -260,3 +361,30 @@ Skills are project-specific and should be configured in your project's `.claude/
260
361
  | Tests | Project-specific test skill |
261
362
  | Simple edits | Edit tool directly |
262
363
 
364
+ ## Instructions Summary
365
+
366
+ ### Before starting:
367
+ 1. Get task description from user
368
+ 2. Extract and sanitize ticket ID from branch name
369
+ 3. Generate `feature_name` slug
370
+ 4. Check for existing state.json → handle resume / restart / completed cases
371
+ 5. Analyze codebase, identify components (max 5)
372
+ 6. Create plan.md → get user approval (iterate if needed)
373
+ 7. Initialize state.json with richer schema → **MANDATORY: verify write**
374
+ 8. Create TaskCreate tasks for all components + verification → mark first component `in_progress`
375
+
376
+ ### For each component:
377
+ 1. Invoke skill or spawn agent
378
+ 2. Verify files exist on disk (Glob)
379
+ 3. Apply retry logic if failed (max 2 retries per component)
380
+ 4. Update state.json → **MANDATORY: verify write**
381
+ 5. Mark component task `completed`, mark next task `in_progress`
382
+
383
+ ### After all components:
384
+ 1. Run build skill (if configured)
385
+ 2. Run test skill (if affected)
386
+ 3. Update `verificationResults` in state.json → **verify write**
387
+ 4. Auto-commit if enabled (stage specific files only)
388
+ 5. Update `status: "completed"` in state.json → **MANDATORY: verify write**
389
+ 6. Mark verification task `completed`
390
+ 7. Report to user
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: 5:reconfigure
3
+ description: Lightweight refresh of project documentation and skills without full Q&A. Re-detects codebase changes, regenerates .5/*.md docs, updates CLAUDE.md, and refreshes all skills.
4
+ allowed-tools: Read, Write, Bash, Glob, Grep, Task, AskUserQuestion
5
+ context: fork
6
+ user-invocable: true
7
+ ---
8
+
9
+ # Reconfigure (Lightweight Refresh)
10
+
11
+ ## Overview
12
+
13
+ Single-command refresh that skips the full Q&A of `/5:configure`. Re-detects codebase state, regenerates documentation and skills based on existing `config.json` preferences.
14
+
15
+ **When to use which:**
16
+
17
+ | Scenario | Command |
18
+ |----------|---------|
19
+ | First-time setup | `/5:configure` |
20
+ | Change preferences (ticket pattern, review tool, etc.) | `/5:configure` |
21
+ | Codebase evolved, refresh docs/skills | **`/5:reconfigure`** |
22
+ | Add new skill patterns | `/5:configure` |
23
+
24
+ ## ⚠️ CRITICAL SCOPE CONSTRAINT
25
+
26
+ **THIS COMMAND REGENERATES DOCS AND SKILLS. IT DOES NOT CHANGE USER PREFERENCES.**
27
+
28
+ Your job:
29
+ ✅ Validate that config.json exists
30
+ ✅ Re-detect codebase patterns and commands (same as configure Steps 1b-1h)
31
+ ✅ Compare detected state with config.json skill selections
32
+ ✅ Show summary and ask for confirmation
33
+ ✅ Invoke configure-project skill in refresh mode
34
+ ✅ Update version.json with artifacts and timestamps
35
+ ✅ Clean up .reconfig-reminder flag
36
+ ✅ Report what was updated
37
+
38
+ Your job is NOT:
39
+ ❌ Ask preference questions (ticket pattern, branch convention, review tool, etc.)
40
+ ❌ Modify config.json preferences (only the `skills` section may be updated if user confirms new patterns)
41
+ ❌ Skip confirmation — always show what will be regenerated
42
+
43
+ ## Process
44
+
45
+ ### Step 1: Validate Config
46
+
47
+ Read `.5/config.json`. If it does not exist:
48
+ - Tell the user: "No configuration found. Please run `/5:configure` first to set up your project."
49
+ - **EXIT IMMEDIATELY**
50
+
51
+ Read `.5/version.json` for current state (configuredAt, configuredAtCommit).
52
+
53
+ ### Step 2: Re-detect Codebase State
54
+
55
+ Perform the same detection as configure Steps 1b-1h:
56
+
57
+ **2a. Detect project type** — same table as configure Step 1b (package.json deps, build files, etc.)
58
+
59
+ **2b. Detect build/test commands** — same as configure Step 1c
60
+
61
+ **2c. Detect codebase patterns** — same as configure Step 1g:
62
+ - Scan for architectural patterns (Controllers, Services, Components, etc.)
63
+ - Use both suffix-based and directory-based globs
64
+ - For each pattern: count files, identify location, sample filename
65
+
66
+ **2d. Detect runnable commands** — same as configure Step 1h:
67
+ - Scan package.json scripts, Makefile targets, etc.
68
+ - Categorize: Build, Test, Lint, Format, Type Check, etc.
69
+
70
+ **2e. Scan existing skills** — list ALL skills in `.claude/skills/`:
71
+ - Read each skill's SKILL.md frontmatter
72
+ - Categorize as workflow-generated (create-*, run-*) or user-created
73
+
74
+ ### Step 3: Compare and Prepare Summary
75
+
76
+ Use the existing skills in `.claude/skills/` (from Step 2e) as the source of truth — not config.json. Compare what's installed with what's detected in the codebase:
77
+
78
+ - **Existing `create-*` skills** — extract the pattern name from each (e.g., `create-controller` → `controller`)
79
+ - **Existing `run-*` skills** — extract the command name from each (e.g., `run-tests` → `tests`)
80
+ - **New patterns**: detected in codebase (Step 2c) but no matching `create-*` skill exists → offer to create
81
+ - **Stale patterns**: a `create-*` skill exists but the pattern is no longer detected in the codebase → offer to remove or keep
82
+ - **New commands**: detected (Step 2d) but no matching `run-*` skill exists → offer to create
83
+ - **Stale commands**: a `run-*` skill exists but the command is no longer detected → offer to remove or keep
84
+ - **User-created skills** (not matching `create-*` or `run-*` naming) → always refresh with current conventions, never remove
85
+
86
+ ### Step 4: Confirm with User
87
+
88
+ Use `AskUserQuestion` to show a summary and get confirmation. Present:
89
+
90
+ 1. **Documentation files that will be rewritten** — list all 7 `.5/*.md` files + CLAUDE.md
91
+ 2. **Skills that will be refreshed** — list ALL skills found in `.claude/skills/` (both workflow-generated and user-created)
92
+ 3. **New patterns detected** (if any) — "These patterns were found in your codebase but don't have skills yet: [list]. Create skills for them?"
93
+ 4. **Stale patterns** (if any) — "These patterns are in your config but weren't found in the codebase: [list]. Remove them?"
94
+
95
+ Options:
96
+ - "Proceed with refresh" — regenerate everything as shown
97
+ - "Cancel" — exit without changes
98
+
99
+ If there are new or stale patterns, use additional `AskUserQuestion` calls with multiSelect to let the user pick which new patterns to add and which stale patterns to remove.
100
+
101
+ New skills will be created and stale skills removed based on the user's choices.
102
+
103
+ ### Step 5: Regenerate
104
+
105
+ Invoke the `configure-project` skill in **refresh mode** via the Task tool:
106
+
107
+ ```
108
+ Task prompt: "Run configure-project skill in REFRESH MODE.
109
+
110
+ Refresh ALL existing skills in .claude/skills/:
111
+ - Existing create-* skills: [list from Step 2e]
112
+ - Existing run-* skills: [list from Step 2e]
113
+ - User-created skills: [list from Step 2e]
114
+ - New skills to create: [list from user confirmation, if any]
115
+ - Skills to remove: [list from user confirmation, if any]
116
+
117
+ Re-analyze the entire codebase (A1 analysis) and:
118
+ 1. Rewrite all 7 .5/*.md documentation files
119
+ 2. Update CLAUDE.md (preserve user-written sections)
120
+ 3. Refresh ALL skills in .claude/skills/ — read current conventions from codebase and update each skill
121
+ 4. Create new skills for newly-added patterns
122
+ 5. Remove skills the user chose to drop"
123
+ ```
124
+
125
+ Use `subagent_type: "general-purpose"` for the Task.
126
+
127
+ ### Step 6: Track
128
+
129
+ After the skill completes, update `.5/version.json`:
130
+
131
+ 1. Read current version.json
132
+ 2. Set `configuredAt` to current ISO timestamp
133
+ 3. Set `configuredAtCommit` to current short commit hash (`git rev-parse --short HEAD`)
134
+ 4. Write back version.json preserving all other fields
135
+
136
+ ### Step 7: Clean Up
137
+
138
+ Remove the `.5/.reconfig-reminder` flag file if it exists:
139
+ ```bash
140
+ rm -f .5/.reconfig-reminder
141
+ ```
142
+
143
+ ### Step 8: Report
144
+
145
+ Show the user a summary:
146
+ - List of documentation files updated
147
+ - List of skills refreshed
148
+ - List of new skills created (if any)
149
+ - List of skills removed (if any)
150
+ - Timestamp of reconfiguration
151
+ - Suggest running `/clear` to reset context
152
+
153
+ ## Related Documentation
154
+ - [configure command](./configure.md) — full Q&A configuration
155
+ - [configure-project skill](../../skills/configure-project/SKILL.md) — the skill that does the heavy lifting
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { execSync } = require('child_process');
6
+
7
+ // Read JSON from stdin
8
+ let input = '';
9
+ process.stdin.setEncoding('utf8');
10
+ process.stdin.on('data', chunk => input += chunk);
11
+ process.stdin.on('end', () => {
12
+ try {
13
+ let workspaceDir = process.cwd();
14
+ if (input.trim()) {
15
+ const data = JSON.parse(input);
16
+ workspaceDir = data.cwd || data.workspace?.current_dir || workspaceDir;
17
+ }
18
+
19
+ checkReconfigure(workspaceDir);
20
+ } catch (e) {
21
+ // Silent failure - don't block on errors
22
+ process.exit(0);
23
+ }
24
+ });
25
+
26
+ function checkReconfigure(workspaceDir) {
27
+ const versionFile = path.join(workspaceDir, '.5', 'version.json');
28
+ const flagFile = path.join(workspaceDir, '.5', '.reconfig-reminder');
29
+
30
+ if (!fs.existsSync(versionFile)) {
31
+ process.exit(0);
32
+ }
33
+
34
+ let versionData;
35
+ try {
36
+ versionData = JSON.parse(fs.readFileSync(versionFile, 'utf8'));
37
+ } catch (e) {
38
+ process.exit(0);
39
+ }
40
+
41
+ const { configuredAt, configuredAtCommit } = versionData;
42
+
43
+ // No configure data yet - skip (user hasn't run /5:configure)
44
+ if (!configuredAt) {
45
+ process.exit(0);
46
+ }
47
+
48
+ // Calculate days elapsed
49
+ let daysElapsed = 0;
50
+ try {
51
+ daysElapsed = Math.floor((Date.now() - new Date(configuredAt).getTime()) / (1000 * 60 * 60 * 24));
52
+ } catch (e) {
53
+ process.exit(0);
54
+ }
55
+
56
+ // Count commits since configured
57
+ let commitCount = 0;
58
+ if (configuredAtCommit) {
59
+ try {
60
+ const result = execSync(`git rev-list --count ${configuredAtCommit}..HEAD`, {
61
+ cwd: workspaceDir,
62
+ timeout: 3000,
63
+ encoding: 'utf8',
64
+ stdio: ['pipe', 'pipe', 'pipe']
65
+ });
66
+ commitCount = parseInt(result.trim(), 10) || 0;
67
+ } catch (e) {
68
+ // Git command failed (commit not found, not a repo, etc.) - skip
69
+ }
70
+ }
71
+
72
+ // Write or remove temp flag file (never touches version.json)
73
+ const COMMIT_THRESHOLD = 50;
74
+ const DAYS_THRESHOLD = 30;
75
+ const shouldRemind = daysElapsed >= DAYS_THRESHOLD || commitCount >= COMMIT_THRESHOLD;
76
+
77
+ try {
78
+ if (shouldRemind) {
79
+ fs.writeFileSync(flagFile, '1');
80
+ } else if (fs.existsSync(flagFile)) {
81
+ fs.unlinkSync(flagFile);
82
+ }
83
+ } catch (e) {
84
+ // Can't write/delete temp file - skip
85
+ }
86
+
87
+ process.exit(0);
88
+ }
@@ -43,22 +43,31 @@ process.stdin.on('end', () => {
43
43
  // Shorten directory path for display
44
44
  const shortDir = dir.replace(os.homedir(), '~');
45
45
 
46
- // Check for available update
46
+ // Check for available update and reconfigure reminder
47
47
  let updateIndicator = '';
48
+ let reconfigIndicator = '';
48
49
  try {
49
50
  const versionFile = path.join(dir, '.5', 'version.json');
50
51
  const versionData = JSON.parse(fs.readFileSync(versionFile, 'utf8'));
52
+
53
+ // Update check
51
54
  const latest = versionData.latestAvailableVersion;
52
55
  const installed = versionData.installedVersion;
53
56
  if (latest && installed && compareVersions(installed, latest) < 0) {
54
57
  updateIndicator = ` | \x1b[33m↑${latest} → /5:update\x1b[0m`;
55
58
  }
59
+
60
+ // Reconfigure check (reads flag file in .5/, gitignored)
61
+ const flagFile = path.join(dir, '.5', '.reconfig-reminder');
62
+ if (fs.existsSync(flagFile)) {
63
+ reconfigIndicator = ` | \x1b[35m↻ /5:reconfigure\x1b[0m`;
64
+ }
56
65
  } catch (e) {
57
66
  // No version file or parse error — no indicator
58
67
  }
59
68
 
60
- // Build and output statusline: model | directory | context | update
61
- const statusline = `\x1b[36m${model}\x1b[0m | \x1b[90m${shortDir}\x1b[0m${ctx}${updateIndicator}`;
69
+ // Build and output statusline: model | directory | context | update | reconfig
70
+ const statusline = `\x1b[36m${model}\x1b[0m | \x1b[90m${shortDir}\x1b[0m${ctx}${updateIndicator}${reconfigIndicator}`;
62
71
  process.stdout.write(statusline);
63
72
 
64
73
  } catch (e) {
package/src/settings.json CHANGED
@@ -14,6 +14,16 @@
14
14
  "timeout": 10
15
15
  }
16
16
  ]
17
+ },
18
+ {
19
+ "matcher": "startup",
20
+ "hooks": [
21
+ {
22
+ "type": "command",
23
+ "command": "node .claude/hooks/check-reconfig.js",
24
+ "timeout": 10
25
+ }
26
+ ]
17
27
  }
18
28
  ],
19
29
  "PreToolUse": [
@@ -22,6 +22,29 @@ Note: config.json is written directly by `/5:configure` during the Q&A phase.
22
22
 
23
23
  ---
24
24
 
25
+ ## Modes
26
+
27
+ This skill supports two modes. The analysis (A1), template filling (A2-A3), CLAUDE.md update (A4-A5), and skill generation (B) logic is the same in both modes — only the **input source** changes.
28
+
29
+ ### Full Mode (default)
30
+
31
+ Used by `/5:configure` → `/5:implement-feature CONFIGURE` flow.
32
+
33
+ - **Input:** Pattern/command selections from feature spec (`.5/features/CONFIGURE/feature.md`)
34
+ - **Behavior:** Creates everything from scratch based on feature spec requirements
35
+
36
+ ### Refresh Mode
37
+
38
+ Used by `/5:reconfigure` for lightweight refresh.
39
+
40
+ - **Input:** The Task prompt lists which skills to refresh, create, and remove (determined by `/5:reconfigure` after scanning `.claude/skills/` and comparing with detected codebase patterns)
41
+ - **Behavior:** Re-analyzes codebase, overwrites docs and refreshes/creates/removes skills as specified
42
+ - **Trigger:** Task prompt includes "REFRESH MODE"
43
+
44
+ In both modes, the analysis and generation logic is identical — only where the skill list comes from differs.
45
+
46
+ ---
47
+
25
48
  ## A. Analyze Codebase and Create/Update CLAUDE.md
26
49
 
27
50
  **Process:**
@@ -3,7 +3,12 @@
3
3
  "feature": "{feature-name}",
4
4
  "status": "in-progress",
5
5
  "currentStep": 1,
6
- "completed": [],
7
- "failed": [],
8
- "startedAt": "{ISO-timestamp}"
6
+ "totalSteps": 0,
7
+ "pendingComponents": [],
8
+ "completedComponents": [],
9
+ "failedAttempts": [],
10
+ "verificationResults": {},
11
+ "commitResults": [],
12
+ "startedAt": "{ISO-timestamp}",
13
+ "lastUpdated": "{ISO-timestamp}"
9
14
  }