mindsystem-cc 3.22.1 → 4.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 (46) hide show
  1. package/README.md +210 -222
  2. package/agents/ms-adhoc-planner.md +133 -0
  3. package/agents/ms-code-reviewer.md +186 -0
  4. package/agents/ms-compounder.md +144 -0
  5. package/agents/ms-roadmapper.md +4 -0
  6. package/commands/ms/add-todo.md +46 -131
  7. package/commands/ms/adhoc.md +42 -57
  8. package/commands/ms/audit-milestone.md +66 -89
  9. package/commands/ms/complete-milestone.md +6 -4
  10. package/commands/ms/compound.md +64 -0
  11. package/commands/ms/config.md +66 -49
  12. package/commands/ms/create-roadmap.md +8 -7
  13. package/commands/ms/doctor.md +29 -4
  14. package/commands/ms/help.md +53 -64
  15. package/commands/ms/new-milestone.md +4 -3
  16. package/commands/ms/progress.md +23 -3
  17. package/commands/ms/update.md +102 -0
  18. package/mindsystem/references/linear-cli.md +71 -0
  19. package/mindsystem/references/plan-format.md +1 -1
  20. package/mindsystem/references/plan-risk-assessment.md +1 -1
  21. package/mindsystem/references/routing/audit-result-routing.md +9 -4
  22. package/mindsystem/references/todo-file.md +63 -0
  23. package/mindsystem/templates/adhoc-summary.md +4 -5
  24. package/mindsystem/templates/knowledge.md +1 -1
  25. package/mindsystem/templates/project.md +15 -4
  26. package/mindsystem/templates/state.md +3 -14
  27. package/mindsystem/templates/tech-debt.md +2 -2
  28. package/mindsystem/workflows/adhoc.md +128 -316
  29. package/mindsystem/workflows/complete-milestone.md +20 -0
  30. package/mindsystem/workflows/compound.md +121 -0
  31. package/mindsystem/workflows/doctor-fixes.md +1 -1
  32. package/mindsystem/workflows/plan-phase.md +1 -1
  33. package/package.json +1 -1
  34. package/scripts/__pycache__/ms-tools.cpython-314.pyc +0 -0
  35. package/scripts/__pycache__/test_ms_tools.cpython-314-pytest-9.0.2.pyc +0 -0
  36. package/scripts/fixtures/scan-context/.planning/adhoc/20260225-refactor-api/adhoc-01-SUMMARY.md +39 -0
  37. package/scripts/fixtures/scan-context/.planning/todos/{pending/add-logout.md → add-logout.md} +2 -2
  38. package/scripts/fixtures/scan-context/.planning/todos/done/setup-db.md +2 -2
  39. package/scripts/fixtures/scan-context/expected-output.json +21 -7
  40. package/scripts/ms-tools.py +42 -23
  41. package/scripts/test_ms_tools.py +84 -5
  42. package/skills/senior-review/SKILL.md +0 -3
  43. package/commands/ms/check-phase.md +0 -134
  44. package/commands/ms/check-todos.md +0 -240
  45. package/commands/ms/plan-milestone-gaps.md +0 -288
  46. package/skills/senior-review/AGENTS.md +0 -531
@@ -1,36 +1,10 @@
1
1
  <purpose>
2
- Execute small work items discovered during verification or debugging without the overhead of phase insertion.
3
-
4
- Provides "describe → quick plan → execute → verify → log" flow for work that's too small for a phase but needs tracking.
2
+ Execute discovered work with knowledge-aware planning, subagent execution, and knowledge consolidation.
5
3
  </purpose>
6
4
 
7
- <scope_guard>
8
- **Maximum scope: 2 tasks**
9
-
10
- If work requires more than 2 tasks, REFUSE with:
11
- ```
12
- This work requires [N] tasks (max: 2 for adhoc work).
13
-
14
- Use `/ms:insert-phase [current_phase] [description]` instead.
15
- ```
16
-
17
- If work requires architectural changes, REFUSE with:
18
- ```
19
- This work requires architectural changes.
20
-
21
- Use `/ms:insert-phase` for proper planning and context tracking.
22
- ```
23
- </scope_guard>
24
-
25
- <required_reading>
26
- Read STATE.md before any operation to load project context.
27
-
28
- @~/.claude/mindsystem/templates/adhoc-summary.md
29
- </required_reading>
30
-
31
5
  <process>
32
6
 
33
- <step name="parse_arguments" priority="first">
7
+ <step name="parse_and_validate" priority="first">
34
8
  Parse the work description from $ARGUMENTS:
35
9
 
36
10
  ```bash
@@ -45,9 +19,7 @@ description="$ARGUMENTS"
45
19
  ```
46
20
 
47
21
  Validate description is actionable (not vague like "fix stuff" or "make it work").
48
- </step>
49
22
 
50
- <step name="validate_project">
51
23
  Verify active Mindsystem project:
52
24
 
53
25
  ```bash
@@ -61,155 +33,119 @@ if [ ! -f .planning/STATE.md ]; then
61
33
  fi
62
34
  ```
63
35
 
64
- Load project context:
65
- - Current phase (for related_phase in adhoc artifacts)
66
- - Accumulated decisions (constraints on this work)
67
- - Blockers/concerns (things to watch for)
68
- </step>
69
-
70
- <step name="analyze_scope">
71
- Quick analysis of what tasks are needed:
72
-
73
- 1. Identify files that need modification
74
- 2. Determine discrete tasks required
75
- 3. Check for architectural implications
76
-
77
- **Task estimation:**
78
- - Single file, simple change → 1 task
79
- - Multiple files, related change → 1-2 tasks
80
- - Multiple files, different concerns → likely >2 tasks
81
-
82
- **Architectural check:**
83
- - New patterns or abstractions → architectural
84
- - Changes to core interfaces → architectural
85
- - Cross-cutting concerns → architectural
36
+ Read STATE.md for project context (current phase, accumulated decisions, blockers).
86
37
 
87
- **Decision point:**
38
+ **Ticket detection:** Check `task_tracker` in config.json. If configured and `$ARGUMENTS` matches the ticket ID pattern, lazy-load `~/.claude/mindsystem/references/{type}-cli.md` and follow its **Ticket Detection** process. If no tracker configured or no match, proceed with `$ARGUMENTS` as free-text.
88
39
 
89
- If tasks > 2:
40
+ ```bash
41
+ TRACKER_TYPE=$(jq -r '.task_tracker.type // empty' .planning/config.json 2>/dev/null)
42
+ TRACKER_CLI=$(jq -r '.task_tracker.cli // empty' .planning/config.json 2>/dev/null)
90
43
  ```
91
- This work requires approximately [N] tasks:
92
- 1. [task description]
93
- 2. [task description]
94
- 3. [task description]
95
- ...
96
44
 
97
- Adhoc work is limited to 2 tasks maximum.
45
+ **Todo detection:** If `$ARGUMENTS` matches a `.planning/todos/*.md` file path and the file exists, lazy-load `~/.claude/mindsystem/references/todo-file.md` and follow its **Todo Detection** process. Todo detection is independent of ticket detection — both can be inactive.
46
+ </step>
98
47
 
99
- **Suggestion:** `/ms:insert-phase [current_phase] [description]`
100
- ```
48
+ <step name="load_knowledge">
49
+ Read subsystems and match knowledge files to work description:
101
50
 
102
- If architectural:
51
+ ```bash
52
+ # Read subsystems from config
53
+ jq -r '.subsystems[]' .planning/config.json 2>/dev/null
103
54
  ```
104
- This work involves architectural changes:
105
- - [what makes it architectural]
106
55
 
107
- Adhoc work handles small, isolated fixes not structural changes.
56
+ Match keywords from work description against subsystem names. Read matching `.planning/knowledge/*.md` files (1-3 most relevant).
108
57
 
109
- **Suggestion:** `/ms:insert-phase [current_phase] [description]`
110
- ```
111
-
112
- If ≤2 tasks and not architectural: PROCEED
58
+ This knowledge informs both the exploration step (what to look for) and the plan (established patterns, pitfalls to avoid).
113
59
  </step>
114
60
 
115
- <step name="create_adhoc_directory">
116
- Ensure adhoc directory exists:
117
-
118
- ```bash
119
- mkdir -p .planning/adhoc
120
- ```
121
- </step>
61
+ <step name="explore_codebase">
62
+ Spawn Explore agents with search focuses derived from work description + loaded knowledge.
122
63
 
123
- <step name="create_lightweight_plan">
124
- Generate timestamp and slug:
64
+ Count: 1 for simple/focused work, 2-3 for work touching multiple areas.
125
65
 
126
- ```bash
127
- timestamp=$(date "+%Y-%m-%d")
128
- slug=$(echo "$description" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//' | cut -c1-50)
129
- plan_file=".planning/adhoc/${timestamp}-${slug}-PLAN.md"
130
- ```
66
+ Each agent receives:
67
+ - Specific search focus (e.g., "find auth token refresh logic", "find API client interceptors")
68
+ - Relevant knowledge context (patterns to look for, files known to be involved)
69
+ - Thoroughness: "medium" for most work, "very thorough" for unfamiliar areas
70
+ </step>
131
71
 
132
- Create minimal PLAN.md:
72
+ <step name="present_and_clarify">
73
+ Present exploration findings as a briefing with externalized assumptions, then cross the information asymmetry boundary with targeted questions.
133
74
 
134
- ```markdown
135
- # Adhoc: [User's description]
75
+ **Part 1 — Briefing (always):**
136
76
 
137
- **Subsystem:** [subsystem or "general"] | **Type:** execute
77
+ Present a dense, specific summary:
78
+ - What changes and why (files, purpose)
79
+ - Claude's assumptions about expected behavior, scope boundaries, and approach — each marked with confidence: **high** / **medium** / **low** to focus user attention on uncertain areas
80
+ - Patterns and constraints from knowledge files and exploration
138
81
 
139
- ## Context
140
- [User's description of what needs to be done and why]
82
+ **Part 2 — AskUserQuestion:**
141
83
 
142
- ## Changes
84
+ Governing principle: each question must save more context than it costs. A question that prevents a wrong assumption from reaching the executor saves an entire subagent context window.
143
85
 
144
- ### 1. [Action-oriented name]
145
- **Files:** `[file paths]`
86
+ - Q1 (always): Assumption validation — "Are these assumptions correct?" with options:
87
+ - Looks right
88
+ - Some corrections (let me clarify)
89
+ - Let me reframe the task
90
+ - Additional questions (conditional): Only when exploration surfaced genuine behavioral ambiguity the user must resolve. Frame with implementation context discovered during exploration. Typically 1-2 for focused work, 3-4 for multi-area work.
146
91
 
147
- [What to do, what to avoid and WHY]
92
+ **What NOT to ask** (Claude determines these from exploration):
93
+ - Technical approach or patterns
94
+ - Error handling strategy
95
+ - Implementation details the user can't meaningfully influence
96
+ - Only ask about: user intent, expected behavior, scope boundaries
148
97
 
149
- [### 2. if needed, same structure]
98
+ **Fast path:** All assumptions high-confidence + no ambiguity → collapse to single validation question.
150
99
 
151
- ## Verification
152
- - [How to verify the work is complete]
100
+ **On corrections:** Absorb user feedback and proceed to planning. Do not re-present the full briefing.
101
+ </step>
153
102
 
154
- ## Must-Haves
155
- - [ ] [Observable outcome 1]
156
- - [ ] [Observable outcome 2]
157
- ```
103
+ <step name="spawn_plan_writer">
104
+ Create per-execution subdirectory:
158
105
 
159
- Write to file:
160
106
  ```bash
161
- echo "Plan created: $plan_file"
162
- ```
107
+ timestamp=$(date "+%Y-%m-%d")
108
+ slug=$(echo "$description" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//' | cut -c1-50)
109
+ exec_dir=".planning/adhoc/${timestamp}-${slug}"
110
+ mkdir -p "$exec_dir"
111
+ ```
112
+
113
+ Assemble context payload for ms-adhoc-planner:
114
+ - Work description
115
+ - Exploration findings (from Explore agents)
116
+ - Knowledge file contents (loaded in step 2)
117
+ - User decisions (from clarification step)
118
+ - STATE.md context (current phase, accumulated decisions)
119
+ - Subsystem list from config.json
120
+ - Output path: `${exec_dir}/adhoc-01-PLAN.md`
121
+ - Ticket context when detected (per loaded ticket reference)
122
+ - Todo context when detected (per loaded todo reference)
123
+
124
+ Spawn ms-adhoc-planner via Task tool. Receive completion report with plan path.
163
125
  </step>
164
126
 
165
- <step name="execute_tasks">
166
- Execute each task inline (no subagent for small work).
167
-
168
- For each task:
169
- 1. Read current file state (use Explore subagent if context gathering needed)
170
- 2. Make changes
171
- 3. Run verify command
172
- 4. Track files modified
173
-
174
- **Deviation rules apply:**
175
- - Rule 1 (Bug): Auto-fix bugs found during execution
176
- - Rule 2 (Critical): Auto-fix security/data issues
177
- - Rule 3 (Blocking): Auto-fix missing dependencies, typos
178
-
179
- **Rule 4 (Architectural) triggers STOP:**
180
- If execution reveals architectural changes needed:
181
- ```
182
- STOP: Architectural changes required
183
-
184
- During execution, discovered:
185
- - [what architectural change is needed]
186
-
187
- This exceeds adhoc scope.
127
+ <step name="review_plan">
128
+ Read the generated plan at `${exec_dir}/adhoc-01-PLAN.md`.
188
129
 
189
- Work completed so far:
190
- - [list completed tasks]
130
+ Present a summary to the user:
131
+ - Number of Changes sections
132
+ - Key files affected
133
+ - Must-Haves checklist
191
134
 
192
- **Next steps:**
193
- 1. Commit partial work (if valuable)
194
- 2. Use `/ms:insert-phase` for remaining work
195
- ```
196
-
197
- Use AskUserQuestion to confirm how to proceed.
135
+ Allow the user to approve, request edits, or abort. If edits requested, apply them directly to the plan file.
198
136
  </step>
199
137
 
200
- <step name="lightweight_verification">
201
- Verify the work is complete:
202
-
203
- 1. Run verify commands from each task
204
- 2. Check files exist/changed as expected
205
- 3. Run relevant tests if specified in verify
138
+ <step name="spawn_executor">
139
+ Spawn ms-executor via Task tool.
206
140
 
207
- **Not required for adhoc:**
208
- - Full goal-backward verification
209
- - Cross-system integration checks
210
- - Regression test suite
141
+ Provide in the prompt:
142
+ - Plan path: `${exec_dir}/adhoc-01-PLAN.md`
143
+ - SUMMARY output path: `${exec_dir}/adhoc-01-SUMMARY.md`
144
+ - Instruction to use phase-style SUMMARY format (with key-decisions, patterns-established, key-files, mock_hints frontmatter fields) for consolidator compatibility
145
+ - Ticket commit instructions when detected (per loaded ticket reference)
146
+ - Todo commit instructions when detected (per loaded todo reference)
211
147
 
212
- Keep verification focused on the specific changes made.
148
+ The executor reads the plan, executes tasks with atomic commits, creates SUMMARY.md, and returns completion report.
213
149
  </step>
214
150
 
215
151
  <step name="code_review">
@@ -219,195 +155,90 @@ Read code review agent from config:
219
155
  CODE_REVIEW=$(cat .planning/config.json 2>/dev/null | jq -r '.code_review.adhoc // .code_review.phase // empty')
220
156
  ```
221
157
 
222
- **If CODE_REVIEW = "skip":**
223
- Skip to create_adhoc_summary.
158
+ **If CODE_REVIEW = "skip":** Skip to generate_patch.
224
159
 
225
- **If CODE_REVIEW = empty/null:**
226
- Use default: `CODE_REVIEW="ms-code-simplifier"`
160
+ **If CODE_REVIEW = empty/null:** Use default: `CODE_REVIEW="ms-code-simplifier"`
227
161
 
228
- **Otherwise:**
229
- Use CODE_REVIEW value directly as agent name.
162
+ **Otherwise:** Use CODE_REVIEW value directly as agent name.
230
163
 
231
- 1. **Get modified files:**
164
+ 1. Get modified files from executor's commits:
232
165
  ```bash
233
- git diff --name-only HEAD | grep -E '\.(dart|ts|tsx|js|jsx|swift|kt|py|go|rs)$'
166
+ ADHOC_COMMITS=$(git log --oneline --grep="(adhoc-" --format="%H")
167
+ CHANGED_FILES=$(git diff --name-only $(echo "$ADHOC_COMMITS" | tail -1)^..HEAD | grep -E '\.(dart|ts|tsx|js|jsx|swift|kt|py|go|rs)$')
234
168
  ```
235
169
 
236
- 2. **Spawn code review agent with adhoc scope:**
237
- ```
238
- Task(
239
- prompt="
240
- <objective>
241
- Review code modified in adhoc work.
242
- Preserve all functionality. Improve clarity and consistency.
243
- </objective>
244
-
245
- <scope>
246
- Files to analyze:
247
- {MODIFIED_FILES}
248
- </scope>
249
-
250
- <output>
251
- After review and simplifications, run static analysis and tests.
252
- Report what was improved and verification results.
253
- </output>
254
- ",
255
- subagent_type="{CODE_REVIEW}"
256
- )
257
- ```
170
+ 2. Spawn code review agent with adhoc scope.
258
171
 
259
- 3. **Track review changes:**
260
- - If changes made: Set `CODE_REVIEW_APPLIED=true`
261
- - Reviewed files will be included in the adhoc commit
262
- - Note in SUMMARY.md that code review was applied
172
+ 3. If changes made: commit with message `refactor(adhoc): code review pass`.
263
173
  </step>
264
174
 
265
- <step name="create_adhoc_summary">
266
- Create SUMMARY.md (see @~/.claude/mindsystem/templates/adhoc-summary.md for full template):
175
+ <step name="generate_patch">
176
+ Generate a patch file capturing all adhoc changes:
267
177
 
268
178
  ```bash
269
- summary_file=".planning/adhoc/${timestamp}-${slug}-SUMMARY.md"
270
-
271
- # Read subsystems for categorization
272
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
273
- ```
274
-
275
- ```markdown
276
- ---
277
- type: adhoc
278
- description: [description]
279
- completed: [ISO timestamp]
280
- duration: [X min]
281
- related_phase: [phase or "none"]
282
- subsystem: [select from config.json subsystems based on work performed]
283
- tags: [searchable keywords from work context]
284
- files_modified:
285
- - [path/to/file1.ts]
286
- - [path/to/file2.ts]
287
- commit: [hash - filled after commit]
288
- learnings:
289
- - [optional: include only when work revealed non-obvious insights. Skip for routine fixes.]
290
- ---
291
-
292
- # Adhoc: [Description]
293
-
294
- **[Substantive one-liner describing what was done]**
295
-
296
- ## What Was Done
297
-
298
- - [accomplishment 1]
299
- - [accomplishment 2]
300
-
301
- ## Files Modified
302
-
303
- - `[path]`: [what changed]
304
- - `[path]`: [what changed]
305
-
306
- ## Verification
307
-
308
- - [what was verified and result]
179
+ ADHOC_COMMITS=$(git log --oneline --grep="(adhoc-" --format="%H")
180
+ FIRST_COMMIT=$(echo "$ADHOC_COMMITS" | tail -1)
181
+ LAST_COMMIT=$(echo "$ADHOC_COMMITS" | head -1)
182
+ patch_file="${exec_dir}/adhoc-01-changes.patch"
183
+ ms-tools generate-adhoc-patch "$FIRST_COMMIT" "$patch_file" --end "$LAST_COMMIT"
309
184
  ```
310
185
 
311
- Write to file.
186
+ If no adhoc commits found or patch generation reports no changes, skip silently.
312
187
  </step>
313
188
 
314
- <step name="update_state">
315
- Update STATE.md with adhoc work entry:
316
-
317
- 1. Read current STATE.md
318
- 2. Find or create "### Recent Adhoc Work" under "## Accumulated Context"
319
- 3. Add entry at top of list
320
- 4. Keep last 5 entries (remove older ones from list, files remain in .planning/adhoc/)
321
-
322
- Format:
323
- ```markdown
324
- ### Recent Adhoc Work
325
-
326
- - [YYYY-MM-DD]: [description] (.planning/adhoc/[filename]-SUMMARY.md)
327
- ```
328
-
329
- If section doesn't exist, add after "### Pending Todos" section:
330
-
331
- ```markdown
332
- ### Recent Adhoc Work
189
+ <step name="consolidate_knowledge">
190
+ Spawn ms-consolidator via Task tool.
333
191
 
334
- - [YYYY-MM-DD]: [description] (.planning/adhoc/[filename]-SUMMARY.md)
192
+ Provide:
193
+ - Phase directory: `${exec_dir}` (the per-execution subdirectory)
194
+ - Phase identifier: "adhoc"
335
195
 
336
- *See `.planning/adhoc/` for full history*
337
- ```
196
+ The consolidator reads `adhoc-01-SUMMARY.md`, extracts knowledge (key-decisions, patterns-established, key-files), updates `.planning/knowledge/*.md` files, and deletes `adhoc-01-PLAN.md`.
338
197
  </step>
339
198
 
340
- <step name="git_commit">
341
- Single commit for all changes (including simplifications if applied):
199
+ <step name="cleanup_and_report">
200
+ **Finalize ticket (when detected):** Follow the **Finalization**, **Commit Message Suffix**, and **Report Additions** sections from the loaded ticket reference.
342
201
 
343
- ```bash
344
- # Add all modified files (code + reviewed files)
345
- git add [code files modified]
346
- git add [reviewed files if CODE_REVIEW_APPLIED]
347
- git add "$plan_file"
348
- git add "$summary_file"
349
- git add .planning/STATE.md
350
-
351
- # Determine commit type
352
- # feat: new functionality
353
- # fix: bug fix, correction
354
- commit_type="fix" # or "feat" based on nature of work
355
-
356
- # Include code review note if applied
357
- if [ "$CODE_REVIEW_APPLIED" = "true" ]; then
358
- review_note="Includes code review pass."
359
- else
360
- review_note=""
361
- fi
202
+ **Finalize todo (when detected):** Follow the **Finalization**, **Commit Message Suffix**, and **Report Additions** sections from the loaded todo reference.
362
203
 
363
- git commit -m "$(cat <<'EOF'
364
- ${commit_type}(adhoc): [description]
204
+ **Commit knowledge updates:**
205
+ ```bash
206
+ git add .planning/knowledge/*.md "${exec_dir}/adhoc-01-SUMMARY.md" .planning/STATE.md
207
+ # Only include patch if it was generated
208
+ [ -f "${exec_dir}/adhoc-01-changes.patch" ] && git add "${exec_dir}/adhoc-01-changes.patch"
209
+ git commit -m "$(cat <<EOF
210
+ docs(adhoc): consolidate knowledge from $description
365
211
 
366
- Files: [count] modified
367
- ${review_note}
212
+ Knowledge files updated, SUMMARY preserved.
368
213
  EOF
369
214
  )"
370
-
371
- # Capture commit hash
372
- commit_hash=$(git rev-parse --short HEAD)
373
215
  ```
374
216
 
375
- Update SUMMARY.md with commit hash in frontmatter.
376
- </step>
377
-
378
- <step name="generate_adhoc_patch">
379
- Generate patch file from the adhoc commit:
217
+ **Update STATE.md** "Recent Adhoc Work" section:
218
+ - Find or create "### Recent Adhoc Work" under "## Accumulated Context"
219
+ - Add entry at top: `- [YYYY-MM-DD]: [description] ({exec_dir}/adhoc-01-SUMMARY.md)`
220
+ - Keep last 5 entries (remove older ones from list)
380
221
 
222
+ **Set last command:**
381
223
  ```bash
382
- patch_file=".planning/adhoc/${timestamp}-${slug}.patch"
383
-
384
- ms-tools generate-adhoc-patch "$commit_hash" "$patch_file"
224
+ ms-tools set-last-command "ms:adhoc $ARGUMENTS"
385
225
  ```
386
226
 
387
- If patch generated (file exists and non-empty):
388
- - Update SUMMARY.md frontmatter to include `patch_file: [path]`
389
-
390
- If skipped (no implementation changes outside exclusions):
391
- - Leave patch_file field empty or omit from SUMMARY.md
392
- </step>
393
-
394
- <step name="completion">
395
- Report completion:
396
-
227
+ **Report completion:**
397
228
  ```
398
229
  Adhoc work complete: [description]
399
230
 
400
231
  **Commit:** [hash]
401
- **Duration:** [X min]
402
232
  **Files modified:** [count]
233
+ **Knowledge updated:** [list of knowledge files]
403
234
 
404
235
  Artifacts:
405
- - Plan: .planning/adhoc/[timestamp]-[slug]-PLAN.md
406
- - Summary: .planning/adhoc/[timestamp]-[slug]-SUMMARY.md
407
- - Patch: .planning/adhoc/[timestamp]-[slug].patch (if generated)
408
-
409
- STATE.md updated with adhoc entry.
236
+ - Summary: {exec_dir}/adhoc-01-SUMMARY.md
237
+ - Patch: {exec_dir}/adhoc-01-changes.patch
238
+ - Knowledge: .planning/knowledge/[subsystem].md
239
+ ```
410
240
 
241
+ ```
411
242
  ---
412
243
 
413
244
  Continue with current work or check project status:
@@ -417,22 +248,3 @@ Continue with current work or check project status:
417
248
  </step>
418
249
 
419
250
  </process>
420
-
421
- <deviation_rules>
422
- Adhoc work uses the same deviation rules as plan execution:
423
-
424
- **Rule 1 - Bug in plan:** Auto-fix
425
- **Rule 2 - Missing critical:** Auto-fix
426
- **Rule 3 - Blocking issue:** Auto-fix
427
- **Rule 4 - Architectural change:** STOP and suggest /ms:insert-phase
428
-
429
- Rule 4 is strict for adhoc work — architectural changes exceed adhoc scope by definition.
430
- </deviation_rules>
431
-
432
- <output_artifacts>
433
- - `.planning/adhoc/{timestamp}-{slug}-PLAN.md` — lightweight plan
434
- - `.planning/adhoc/{timestamp}-{slug}-SUMMARY.md` — completion summary
435
- - `.planning/adhoc/{timestamp}-{slug}.patch` — implementation changes (if any)
436
- - Updated `.planning/STATE.md` — adhoc entry in accumulated context
437
- - Git commit with all changes
438
- </output_artifacts>
@@ -192,6 +192,24 @@ cat .planning/phases/*-*/*-SUMMARY.md
192
192
  - Remove items that are no longer relevant
193
193
  - Add any requirements invalidated during this milestone
194
194
 
195
+ **Deferred triage** (runs while REQUIREMENTS.md and CONTEXT.md files are still available):
196
+
197
+ a. Read REQUIREMENTS.md `## v2 Requirements` section
198
+ b. Scan phase CONTEXT.md files for `<deferred>` sections:
199
+ ```bash
200
+ grep -l "<deferred>" .planning/phases/*/*-CONTEXT.md 2>/dev/null
201
+ ```
202
+ Read each matching file's `<deferred>` section.
203
+ c. Collect all deferred items into a combined list (deduplicate by description similarity)
204
+ d. If no deferred items found: skip silently
205
+ e. If deferred items exist, present as batch decision gate via AskUserQuestion:
206
+ - Show all items grouped by source (v2 requirements vs phase deferred ideas)
207
+ - Options: "Defer all", "Triage individually", "Discard all"
208
+ - If "Triage individually": for each item, options are Keep (→ Deferred), Exclude (→ Out of Scope), Discard
209
+ - If "Defer all": add all to PROJECT.md `## Deferred` section
210
+ f. Update PROJECT.md `## Deferred` and/or `## Out of Scope` sections accordingly
211
+ g. If a Deferred section already exists (from previous milestones), merge — don't replace
212
+
195
213
  4. **Business context review:**
196
214
  - Who It's For — has understanding of audience evolved?
197
215
  - Core Problem — still the right framing?
@@ -289,6 +307,7 @@ Initial user testing showed demand for shape tools.
289
307
  - [ ] "What This Is" reviewed and updated if needed
290
308
  - [ ] Core Value verified as still correct
291
309
  - [ ] All shipped requirements added to Validated
310
+ - [ ] Deferred items triaged (v2 requirements + CONTEXT.md deferred ideas)
292
311
  - [ ] Business context reviewed (Who It's For, Core Problem, How It's Different, Key User Flows)
293
312
  - [ ] Out of Scope reasoning audited
294
313
  - [ ] Technical Context updated with current state
@@ -587,6 +606,7 @@ Milestone completion is successful when (ordered by skip risk):
587
606
 
588
607
  - [ ] PROJECT.md full evolution review completed (What This Is, Core Value, business context, Validated, Key Decisions, Technical Context)
589
608
  - [ ] All shipped requirements moved to Validated in PROJECT.md
609
+ - [ ] Deferred items triaged (v2 requirements + CONTEXT.md deferred ideas)
590
610
  - [ ] Key Decisions updated with outcomes
591
611
  - [ ] MILESTONES.md entry created with stats and accomplishments
592
612
  - [ ] Roadmap archive created (milestones/{slug}/ROADMAP.md)