mindsystem-cc 3.12.0 → 3.13.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 (33) hide show
  1. package/agents/ms-consolidator.md +4 -4
  2. package/agents/ms-executor.md +19 -351
  3. package/agents/ms-flutter-code-quality.md +7 -6
  4. package/agents/ms-mock-generator.md +51 -138
  5. package/agents/ms-plan-checker.md +170 -175
  6. package/agents/ms-plan-writer.md +120 -115
  7. package/agents/ms-verifier.md +22 -18
  8. package/commands/ms/check-phase.md +3 -3
  9. package/commands/ms/execute-phase.md +8 -6
  10. package/commands/ms/plan-phase.md +4 -3
  11. package/commands/ms/verify-work.md +7 -7
  12. package/mindsystem/references/goal-backward.md +10 -25
  13. package/mindsystem/references/mock-patterns.md +149 -240
  14. package/mindsystem/references/plan-format.md +326 -247
  15. package/mindsystem/references/scope-estimation.md +29 -24
  16. package/mindsystem/references/tdd-execution.md +70 -0
  17. package/mindsystem/references/tdd.md +53 -194
  18. package/mindsystem/templates/UAT.md +16 -16
  19. package/mindsystem/templates/phase-prompt.md +51 -367
  20. package/mindsystem/templates/roadmap.md +1 -1
  21. package/mindsystem/templates/verification-report.md +2 -2
  22. package/mindsystem/workflows/adhoc.md +16 -21
  23. package/mindsystem/workflows/execute-phase.md +71 -49
  24. package/mindsystem/workflows/execute-plan.md +183 -1054
  25. package/mindsystem/workflows/plan-phase.md +47 -38
  26. package/mindsystem/workflows/verify-phase.md +16 -20
  27. package/mindsystem/workflows/verify-work.md +54 -67
  28. package/package.json +1 -1
  29. package/scripts/update-state.sh +59 -0
  30. package/scripts/validate-execution-order.sh +102 -0
  31. package/skills/flutter-code-quality/SKILL.md +4 -3
  32. package/mindsystem/templates/summary.md +0 -293
  33. package/mindsystem/workflows/generate-mocks.md +0 -261
@@ -1,5 +1,5 @@
1
1
  <purpose>
2
- Execute a phase prompt (PLAN.md) and create the outcome summary (SUMMARY.md).
2
+ Execute a plan prompt (PLAN.md) and create the outcome summary (SUMMARY.md).
3
3
  </purpose>
4
4
 
5
5
  <required_reading>
@@ -9,662 +9,178 @@ Read STATE.md before any operation to load project context.
9
9
  <process>
10
10
 
11
11
  <step name="load_project_state" priority="first">
12
- Before any operation, read project state:
12
+ Read project state:
13
13
 
14
14
  ```bash
15
15
  cat .planning/STATE.md 2>/dev/null
16
16
  ```
17
17
 
18
18
  **If file exists:** Parse and internalize:
19
-
20
19
  - Current position (phase, plan, status)
21
20
  - Accumulated decisions (constraints on this execution)
22
21
  - Blockers/concerns (things to watch for)
23
- - Brief alignment status
24
-
25
- **If file missing but .planning/ exists:**
26
-
27
- ```
28
- STATE.md missing but planning artifacts exist.
29
- Options:
30
- 1. Reconstruct from existing artifacts
31
- 2. Continue without project state (may lose accumulated context)
32
- ```
33
22
 
34
- **If .planning/ doesn't exist:** Error - project not initialized.
23
+ **If file missing but .planning/ exists:** Present options reconstruct from artifacts or continue without state.
35
24
 
36
- This ensures every execution has full project context.
25
+ **If .planning/ doesn't exist:** Error project not initialized.
37
26
  </step>
38
27
 
39
- <step name="identify_plan">
40
- Find the next plan to execute:
41
- - Check roadmap for "In progress" phase
42
- - Find plans in that phase directory
43
- - Identify first plan without corresponding SUMMARY
44
-
45
- ```bash
46
- cat .planning/ROADMAP.md
47
- # Look for phase with "In progress" status
48
- # Then find plans in that phase
49
- ls .planning/phases/XX-name/*-PLAN.md 2>/dev/null | sort
50
- ls .planning/phases/XX-name/*-SUMMARY.md 2>/dev/null | sort
51
- ```
52
-
53
- **Logic:**
54
-
55
- - If `01-01-PLAN.md` exists but `01-01-SUMMARY.md` doesn't → execute 01-01
56
- - If `01-01-SUMMARY.md` exists but `01-02-SUMMARY.md` doesn't → execute 01-02
57
- - Pattern: Find first PLAN file without matching SUMMARY file
58
-
59
- **Decimal phase handling:**
60
-
61
- Phase directories can be integer or decimal format:
28
+ <step name="load_plan">
29
+ Read the plan file provided in your prompt context.
62
30
 
63
- - Integer: `.planning/phases/01-foundation/01-01-PLAN.md`
64
- - Decimal: `.planning/phases/01.1-hotfix/01.1-01-PLAN.md`
65
-
66
- Parse phase number from path (handles both formats):
67
-
68
- ```bash
69
- # Extract phase number (handles XX or XX.Y format)
70
- PHASE=$(echo "$PLAN_PATH" | grep -oE '[0-9]+(\.[0-9]+)?-[0-9]+')
71
- ```
72
-
73
- SUMMARY naming follows same pattern:
74
-
75
- - Integer: `01-01-SUMMARY.md`
76
- - Decimal: `01.1-01-SUMMARY.md`
77
-
78
- Confirm with user if ambiguous.
79
-
80
- ```
81
- ⚡ Auto-approved: Execute {phase}-{plan}-PLAN.md
82
- [Plan X of Y for Phase Z]
83
-
84
- Starting execution...
85
- ```
31
+ Parse inline metadata from header: `**Subsystem:**` and `**Type:**` values.
86
32
 
87
- Proceed directly to execution.
88
- </step>
89
-
90
- <step name="record_start_time">
91
- Record execution start time for performance tracking:
92
-
93
- ```bash
94
- PLAN_START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
95
- PLAN_START_EPOCH=$(date +%s)
96
- ```
97
-
98
- Store in shell variables for duration calculation at completion.
99
- </step>
100
-
101
- <step name="init_agent_tracking">
102
- **Initialize agent tracking for subagent resume capability.**
103
-
104
- Before spawning any subagents, set up tracking infrastructure:
105
-
106
- **1. Create/verify tracking files:**
107
-
108
- ```bash
109
- # Create agent history file if doesn't exist
110
- if [ ! -f .planning/agent-history.json ]; then
111
- echo '{"version":"1.0","max_entries":50,"entries":[]}' > .planning/agent-history.json
112
- fi
113
-
114
- # Clear any stale current-agent-id (from interrupted sessions)
115
- # Will be populated when subagent spawns
116
- rm -f .planning/current-agent-id.txt
117
- ```
118
-
119
- **2. Check for interrupted agents (resume detection):**
120
-
121
- ```bash
122
- # Check if current-agent-id.txt exists from previous interrupted session
123
- if [ -f .planning/current-agent-id.txt ]; then
124
- INTERRUPTED_ID=$(cat .planning/current-agent-id.txt)
125
- echo "Found interrupted agent: $INTERRUPTED_ID"
126
- fi
127
- ```
128
-
129
- **If interrupted agent found:**
130
- - The agent ID file exists from a previous session that didn't complete
131
- - This agent can potentially be resumed using Task tool's `resume` parameter
132
- - Present to user: "Previous session was interrupted. Resume agent [ID] or start fresh?"
133
- - If resume: Use Task tool with `resume` parameter set to the interrupted ID
134
- - If fresh: Clear the file and proceed normally
135
-
136
- **3. Prune old entries (housekeeping):**
137
-
138
- If agent-history.json has more than `max_entries`:
139
- - Remove oldest entries with status "completed"
140
- - Never remove entries with status "spawned" (may need resume)
141
- - Keep file under size limit for fast reads
142
-
143
- **When to run this step:**
144
- - Pattern A (fully autonomous): Before spawning the single subagent
145
- - Pattern B (segmented): Before the segment execution loop
146
- - Pattern C (main context): Skip - no subagents spawned
147
- </step>
33
+ Parse plan sections:
34
+ - Context (files to read, @-references)
35
+ - Changes (tasks with implementation details)
36
+ - Verification criteria
37
+ - Must-Haves checklist
148
38
 
149
- <step name="load_prompt">
150
- Read the plan prompt:
151
- ```bash
152
- cat .planning/phases/XX-name/{phase}-{plan}-PLAN.md
153
- ````
39
+ **If plan references CONTEXT.md:** The CONTEXT.md file provides the user's vision for this phase — how they imagine it working, what's essential, and what's out of scope. Honor this context throughout execution.
154
40
 
155
- This IS the execution instructions. Follow it exactly.
41
+ **If plan references DESIGN.md:** The DESIGN.md provides visual/UX specifications — exact colors (hex), spacing (px), component states, and layouts. Use exact values from the spec, implement all component states, match wireframe layouts, include DESIGN.md verification criteria in task verification.
156
42
 
157
- **If plan references CONTEXT.md:**
158
- The CONTEXT.md file provides the user's vision for this phase — how they imagine it working, what's essential, and what's out of scope. Honor this context throughout execution.
43
+ **If `**Type:** tdd`:** Read `~/.claude/mindsystem/references/tdd-execution.md` for RED-GREEN-REFACTOR execution flow.
159
44
  </step>
160
45
 
161
- <step name="previous_phase_check">
162
- Before executing, check if previous phase had issues:
163
-
164
- ```bash
165
- # Find previous phase summary
166
- ls .planning/phases/*/SUMMARY.md 2>/dev/null | sort -r | head -2 | tail -1
167
- ```
168
-
169
- If previous phase SUMMARY.md has "Issues Encountered" != "None" or "Next Phase Readiness" mentions blockers:
170
-
171
- Use AskUserQuestion:
172
-
173
- - header: "Previous Issues"
174
- - question: "Previous phase had unresolved items: [summary]. How to proceed?"
175
- - options:
176
- - "Proceed anyway" - Issues won't block this phase
177
- - "Address first" - Let's resolve before continuing
178
- - "Review previous" - Show me the full summary
179
- </step>
180
-
181
46
  <step name="execute">
182
- Execute each task in the prompt. **Deviations are normal** - handle them automatically using embedded rules below.
183
-
184
- 1. Read the @context files listed in the prompt
185
-
186
- 2. For each task:
187
-
188
- **If `type="auto"`:**
189
-
190
- **Before executing:** Check if task has `tdd="true"` attribute:
191
- - If yes: Follow TDD execution flow (see `<tdd_execution>`) - RED → GREEN → REFACTOR cycle with atomic commits per stage
192
- - If no: Standard implementation
193
-
194
- - Work toward task completion
195
- - **If CLI/API returns authentication error:** Handle as authentication gate (see below)
196
- - **When you discover additional work not in plan:** Apply deviation rules (see below) automatically
197
- - Continue implementing, applying rules as needed
198
- - Run the verification
199
- - Confirm done criteria met
200
- - **Commit the task** (see `<task_commit>` below)
201
- - Track task completion and commit hash for Summary documentation
202
- - Continue to next task
203
-
204
- 3. Run overall verification checks from `<verification>` section
205
- 4. Confirm all success criteria from `<success_criteria>` section met
206
- 5. Document all deviations in Summary (automatic - see deviation_documentation below)
207
- </step>
208
-
209
- <authentication_gates>
210
-
211
- ## Handling Authentication Errors During Execution
212
-
213
- **When you encounter authentication errors during `type="auto"` task execution:**
214
-
215
- This is NOT a failure. Authentication gates are expected and normal. Handle them dynamically:
216
-
217
- **Authentication error indicators:**
218
-
219
- - CLI returns: "Error: Not authenticated", "Not logged in", "Unauthorized", "401", "403"
220
- - API returns: "Authentication required", "Invalid API key", "Missing credentials"
221
- - Command fails with: "Please run {tool} login" or "Set {ENV_VAR} environment variable"
222
-
223
- **Authentication gate protocol:**
224
-
225
- 1. **Recognize it's an auth gate** - Not a bug, just needs credentials
226
- 2. **STOP current task execution** - Don't retry repeatedly
227
- 3. **Use AskUserQuestion** - Present it to user immediately
228
- 4. **Provide exact authentication steps** - CLI commands, where to get keys
229
- 5. **Wait for user to authenticate** - Let them complete auth flow
230
- 6. **Verify authentication works** - Test that credentials are valid
231
- 7. **Retry the original task** - Resume automation where you left off
232
- 8. **Continue normally** - Don't treat this as an error in Summary
233
-
234
- **Example: Vercel deployment hits auth error**
235
-
236
- ```
237
- Task 3: Deploy to Vercel
238
- Running: vercel --yes
239
-
240
- Error: Not authenticated. Please run 'vercel login'
241
-
242
- [Present via AskUserQuestion]
243
-
244
- ╔═══════════════════════════════════════════════════════╗
245
- ║ CHECKPOINT: Action Required ║
246
- ╚═══════════════════════════════════════════════════════╝
247
-
248
- Progress: 2/8 tasks complete
249
- Task: Authenticate Vercel CLI
250
-
251
- Attempted: vercel --yes
252
- Error: Not authenticated
253
-
254
- What you need to do:
255
- 1. Run: vercel login
256
- 2. Complete browser authentication
257
-
258
- I'll verify: vercel whoami returns your account
259
-
260
- ────────────────────────────────────────────────────────
261
- → YOUR ACTION: Type "done" when authenticated
262
- ────────────────────────────────────────────────────────
263
-
264
- [Wait for user response]
265
-
266
- [User types "done"]
267
-
268
- Verifying authentication...
269
- Running: vercel whoami
270
- ✓ Authenticated as: user@example.com
271
-
272
- Retrying deployment...
273
- Running: vercel --yes
274
- ✓ Deployed to: https://myapp-abc123.vercel.app
275
-
276
- Task 3 complete. Continuing to task 4...
277
- ```
278
-
279
- **In Summary documentation:**
280
-
281
- Document authentication gates as normal flow, not deviations:
282
-
283
- ```markdown
284
- ## Authentication Gates
285
-
286
- During execution, I encountered authentication requirements:
287
-
288
- 1. Task 3: Vercel CLI required authentication
289
- - Paused for `vercel login`
290
- - Resumed after authentication
291
- - Deployed successfully
292
-
293
- These are normal gates, not errors.
294
- ```
295
-
296
- **Key principles:**
297
-
298
- - Authentication gates are NOT failures or bugs
299
- - They're expected interaction points during first-time setup
300
- - Handle them gracefully and continue automation after unblocked
301
- - Don't mark tasks as "failed" or "incomplete" due to auth gates
302
- - Document them as normal flow, separate from deviations
303
- </authentication_gates>
47
+ Record start time: `PLAN_START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ"); PLAN_START_EPOCH=$(date +%s)`
48
+
49
+ Execute each task in the plan. Deviations are normal handle them using `<deviation_rules>` below.
50
+
51
+ For each task:
52
+ 1. Read any @context files listed
53
+ 2. Implement the task
54
+ 3. **If CLI/API returns auth error (401, 403, "Not authenticated", "Please run X login"):** Use AskUserQuestion with exact auth steps and verification command. Wait, verify, resume. Document as normal flow, not deviation.
55
+ 4. When you discover work not in plan: apply deviation rules automatically
56
+ 5. Run task verification
57
+ 6. Confirm done criteria met
58
+ 7. Commit the task (see `<task_commit>`)
59
+ 8. Track task completion and commit hash for summary
60
+
61
+ After all tasks:
62
+ - Run overall verification from plan's Verification section
63
+ - Confirm all Must-Haves met
64
+ </step>
304
65
 
305
66
  <deviation_rules>
306
67
 
307
68
  ## Automatic Deviation Handling
308
69
 
309
- **While executing tasks, you WILL discover work not in the plan.** This is normal.
70
+ **While executing tasks, you WILL discover work not in the plan.** Apply these rules automatically. Track all deviations for summary.
310
71
 
311
- Apply these rules automatically. Track all deviations for Summary documentation.
72
+ **RULE PRIORITY:**
73
+ 1. If Rule 4 applies → STOP and ask user (architectural decision)
74
+ 2. If Rules 1-3 apply → fix automatically, track for summary
75
+ 3. If genuinely unsure → apply Rule 4 (stop and ask)
312
76
 
313
77
  ---
314
78
 
315
79
  **RULE 1: Auto-fix bugs**
316
80
 
317
- **Trigger:** Code doesn't work as intended (broken behavior, incorrect output, errors)
318
-
319
- **Action:** Fix immediately, track for Summary
81
+ Trigger: Code doesn't work as intended (broken behavior, errors, crashes)
320
82
 
321
- **Examples:**
83
+ Action: Fix immediately, track for summary. No user permission needed.
322
84
 
323
- - Wrong SQL query returning incorrect data
324
- - Logic errors (inverted condition, off-by-one, infinite loop)
325
- - Type errors, null pointer exceptions, undefined references
326
- - Broken validation (accepts invalid input, rejects valid input)
327
- - Security vulnerabilities (SQL injection, XSS, CSRF, insecure auth)
328
- - Race conditions, deadlocks
329
- - Memory leaks, resource leaks
330
-
331
- **Process:**
332
-
333
- 1. Fix the bug inline
334
- 2. Add/update tests to prevent regression
335
- 3. Verify fix works
336
- 4. Continue task
337
- 5. Track in deviations list: `[Rule 1 - Bug] [description]`
338
-
339
- **No user permission needed.** Bugs must be fixed for correct operation.
85
+ Example: Logic error causing inverted condition — fix inline, add regression test, verify, track as `[Rule 1 - Bug]`.
340
86
 
341
87
  ---
342
88
 
343
89
  **RULE 2: Auto-add missing critical functionality**
344
90
 
345
- **Trigger:** Code is missing essential features for correctness, security, or basic operation
346
-
347
- **Action:** Add immediately, track for Summary
348
-
349
- **Examples:**
350
-
351
- - Missing error handling (no try/catch, unhandled promise rejections)
352
- - No input validation (accepts malicious data, type coercion issues)
353
- - Missing null/undefined checks (crashes on edge cases)
354
- - No authentication on protected routes
355
- - Missing authorization checks (users can access others' data)
356
- - No CSRF protection, missing CORS configuration
357
- - No rate limiting on public APIs
358
- - Missing required database indexes (causes timeouts)
359
- - No logging for errors (can't debug production)
91
+ Trigger: Code missing essential features for correctness, security, or operation
360
92
 
361
- **Process:**
93
+ Action: Add immediately, track for summary. No user permission needed.
362
94
 
363
- 1. Add the missing functionality inline
364
- 2. Add tests for the new functionality
365
- 3. Verify it works
366
- 4. Continue task
367
- 5. Track in deviations list: `[Rule 2 - Missing Critical] [description]`
95
+ Example: Auth middleware not checking token expiry — add exp validation, add test, track as `[Rule 2 - Missing Critical]`.
368
96
 
369
- **Critical = required for correct/secure/performant operation**
370
- **No user permission needed.** These are not "features" - they're requirements for basic correctness.
97
+ Boundary: "Add missing validation" = Rule 2. "Add new table" = Rule 4.
371
98
 
372
99
  ---
373
100
 
374
101
  **RULE 3: Auto-fix blocking issues**
375
102
 
376
- **Trigger:** Something prevents you from completing current task
103
+ Trigger: Something prevents completing current task
377
104
 
378
- **Action:** Fix immediately to unblock, track for Summary
105
+ Action: Fix to unblock, track for summary. No user permission needed.
379
106
 
380
- **Examples:**
381
-
382
- - Missing dependency (package not installed, import fails)
383
- - Wrong types blocking compilation
384
- - Broken import paths (file moved, wrong relative path)
385
- - Missing environment variable (app won't start)
386
- - Database connection config error
387
- - Build configuration error (webpack, tsconfig, etc.)
388
- - Missing file referenced in code
389
- - Circular dependency blocking module resolution
390
-
391
- **Process:**
392
-
393
- 1. Fix the blocking issue
394
- 2. Verify task can now proceed
395
- 3. Continue task
396
- 4. Track in deviations list: `[Rule 3 - Blocking] [description]`
397
-
398
- **No user permission needed.** Can't complete task without fixing blocker.
107
+ Example: Missing dependency blocking import — install package, verify task proceeds, track as `[Rule 3 - Blocking]`.
399
108
 
400
109
  ---
401
110
 
402
111
  **RULE 4: Ask about architectural changes**
403
112
 
404
- **Trigger:** Fix/addition requires significant structural modification
405
-
406
- **Action:** STOP, report via AskUserQuestion, wait for decision
407
-
408
- **Examples:**
113
+ Trigger: Fix/addition requires significant structural modification (new table, new service layer, framework switch, breaking API change)
409
114
 
410
- - Adding new database table (not just column)
411
- - Major schema changes (changing primary key, splitting tables)
412
- - Introducing new service layer or architectural pattern
413
- - Switching libraries/frameworks (React → Vue, REST → GraphQL)
414
- - Changing authentication approach (sessions → JWT)
415
- - Adding new infrastructure (message queue, cache layer, CDN)
416
- - Changing API contracts (breaking changes to endpoints)
417
- - Adding new deployment environment
115
+ Action: STOP. Present via AskUserQuestion: what found, proposed change, why, impact, alternatives. Wait for decision.
418
116
 
419
- **Process:**
420
-
421
- 1. STOP current task
422
- 2. Present clearly:
423
-
424
- ```
425
- ⚠️ Architectural Decision Needed
426
-
427
- Current task: [task name]
428
- Discovery: [what you found that prompted this]
429
- Proposed change: [architectural modification]
430
- Why needed: [rationale]
431
- Impact: [what this affects - APIs, deployment, dependencies, etc.]
432
- Alternatives: [other approaches, or "none apparent"]
433
-
434
- Proceed with proposed change? (yes / different approach / defer)
435
- ```
436
-
437
- 3. WAIT for user response
438
- 4. If approved: implement, track as `[Rule 4 - Architectural] [description]`
439
- 5. If different approach: discuss and implement
440
- 6. If deferred: note in Summary and continue without change
441
-
442
- **User decision required.** These changes affect system design.
117
+ Example: Need to add new database table — STOP, present the architectural decision, wait for approval.
443
118
 
444
119
  ---
445
120
 
446
- **RULE PRIORITY (when multiple could apply):**
447
-
448
- 1. **If Rule 4 applies** → STOP and report to user (architectural decision)
449
- 2. **If Rules 1-3 apply** → Fix automatically, track for Summary
450
- 3. **If genuinely unsure which rule** → Apply Rule 4 (stop and report)
451
-
452
- **Edge case guidance:**
453
-
454
- - "This validation is missing" → Rule 2 (critical for security)
455
- - "This crashes on null" → Rule 1 (bug)
456
- - "Need to add table" → Rule 4 (architectural)
457
- - "Need to add column" → Rule 1 or 2 (depends: fixing bug or adding critical field)
458
-
459
- **When in doubt:** Ask yourself "Does this affect correctness, security, or ability to complete task?"
460
-
461
- - YES → Rules 1-3 (fix automatically)
462
- - MAYBE → Rule 4 (ask user)
463
-
464
- </deviation_rules>
465
-
466
- <deviation_documentation>
467
-
468
- ## Documenting Deviations in Summary
469
-
470
- After all tasks complete, Summary MUST include deviations section.
471
-
472
- **If no deviations:**
473
-
474
- ```markdown
475
- ## Deviations from Plan
476
-
477
- None - plan executed exactly as written.
478
- ```
479
-
480
- **If deviations occurred:**
121
+ **Documentation format for summary:**
481
122
 
482
123
  ```markdown
483
124
  ## Deviations from Plan
484
125
 
485
126
  ### Auto-fixed Issues
486
127
 
487
- **1. [Rule 1 - Bug] Fixed case-sensitive email uniqueness constraint**
488
-
489
- - **Found during:** Task 4 (Follow/unfollow API implementation)
490
- - **Issue:** User.email unique constraint was case-sensitive - Test@example.com and test@example.com were both allowed, causing duplicate accounts
491
- - **Fix:** Changed to `CREATE UNIQUE INDEX users_email_unique ON users (LOWER(email))`
492
- - **Files modified:** src/models/User.ts, migrations/003_fix_email_unique.sql
493
- - **Verification:** Unique constraint test passes - duplicate emails properly rejected
494
- - **Commit:** abc123f
495
-
496
- **2. [Rule 2 - Missing Critical] Added JWT expiry validation to auth middleware**
497
-
498
- - **Found during:** Task 3 (Protected route implementation)
499
- - **Issue:** Auth middleware wasn't checking token expiry - expired tokens were being accepted
500
- - **Fix:** Added exp claim validation in middleware, reject with 401 if expired
501
- - **Files modified:** src/middleware/auth.ts, src/middleware/auth.test.ts
502
- - **Verification:** Expired token test passes - properly rejects with 401
503
- - **Commit:** def456g
504
-
505
- ---
506
-
507
- **Total deviations:** 4 auto-fixed (1 bug, 1 missing critical, 1 blocking, 1 architectural with approval)
508
- **Impact on plan:** All auto-fixes necessary for correctness/security/performance. No scope creep.
128
+ **1. [Rule N - Category] Brief description**
129
+ - **Found during:** Task [N]
130
+ - **Issue:** [what was wrong]
131
+ - **Fix:** [what was done]
132
+ - **Files modified:** [files]
133
+ - **Commit:** [hash]
509
134
  ```
510
135
 
511
- **This provides complete transparency:**
512
-
513
- - Every deviation documented
514
- - Why it was needed
515
- - What rule applied
516
- - What was done
517
- - User can see exactly what happened beyond the plan
518
-
519
- </deviation_documentation>
520
-
521
- <tdd_plan_execution>
522
- ## TDD Plan Execution
523
-
524
- When executing a plan with `type: tdd` in frontmatter, follow the RED-GREEN-REFACTOR cycle for the single feature defined in the plan.
525
-
526
- **1. Check test infrastructure (if first TDD plan):**
527
- If no test framework configured:
528
- - Detect project type from package.json/requirements.txt/etc.
529
- - Install minimal test framework (Jest, pytest, Go testing, etc.)
530
- - Create test config file
531
- - Verify: run empty test suite
532
- - This is part of the RED phase, not a separate task
533
-
534
- **2. RED - Write failing test:**
535
- - Read `<behavior>` element for test specification
536
- - Create test file if doesn't exist (follow project conventions)
537
- - Write test(s) that describe expected behavior
538
- - Run tests - MUST fail (if passes, test is wrong or feature exists)
539
- - Commit: `test({phase}-{plan}): add failing test for [feature]`
540
-
541
- **3. GREEN - Implement to pass:**
542
- - Read `<implementation>` element for guidance
543
- - Write minimal code to make test pass
544
- - Run tests - MUST pass
545
- - Commit: `feat({phase}-{plan}): implement [feature]`
546
-
547
- **4. REFACTOR (if needed):**
548
- - Clean up code if obvious improvements
549
- - Run tests - MUST still pass
550
- - Commit only if changes made: `refactor({phase}-{plan}): clean up [feature]`
551
-
552
- **Commit pattern for TDD plans:**
553
- Each TDD plan produces 2-3 atomic commits:
554
- 1. `test({phase}-{plan}): add failing test for X`
555
- 2. `feat({phase}-{plan}): implement X`
556
- 3. `refactor({phase}-{plan}): clean up X` (optional)
557
-
558
- **Error handling:**
559
- - If test doesn't fail in RED phase: Test is wrong or feature already exists. Investigate before proceeding.
560
- - If test doesn't pass in GREEN phase: Debug implementation, keep iterating until green.
561
- - If tests fail in REFACTOR phase: Undo refactor, commit was premature.
562
-
563
- **Verification:**
564
- After TDD plan completion, ensure:
565
- - All tests pass
566
- - Test coverage for the new behavior exists
567
- - No unrelated tests broken
568
-
569
- **Why TDD uses dedicated plans:** TDD requires 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. This consumes 40-50% of context for a single feature. Dedicated plans ensure full quality throughout the cycle.
570
-
571
- **Comparison:**
572
- - Standard plans: Multiple tasks, 1 commit per task, 2-4 commits total
573
- - TDD plans: Single feature, 2-3 commits for RED/GREEN/REFACTOR cycle
574
-
575
- See `~/.claude/mindsystem/references/tdd.md` for TDD plan structure.
576
- </tdd_plan_execution>
136
+ If no deviations: "None — plan executed exactly as written."
137
+
138
+ </deviation_rules>
577
139
 
578
140
  <task_commit>
579
- ## Task Commit Protocol
580
141
 
581
- After each task completes (verification passed, done criteria met), commit immediately:
142
+ ## Task Commit Protocol
582
143
 
583
- **1. Identify modified files:**
144
+ After each task completes (verification passed, done criteria met), commit immediately.
584
145
 
585
- Track files changed during this specific task (not the entire plan):
146
+ **1. Stage only task-related files** (NEVER `git add .` or `git add -A`):
586
147
 
587
148
  ```bash
588
149
  git status --short
150
+ git add src/specific/file.ts
589
151
  ```
590
152
 
591
- **2. Stage only task-related files:**
592
-
593
- Stage each file individually (NEVER use `git add .` or `git add -A`):
594
-
595
- ```bash
596
- # Example - adjust to actual files modified by this task
597
- git add src/api/auth.ts
598
- git add src/types/user.ts
599
- ```
153
+ **2. Determine commit type:**
600
154
 
601
- **3. Determine commit type:**
155
+ | Type | When |
156
+ |------|------|
157
+ | `feat` | New feature, endpoint, component |
158
+ | `fix` | Bug fix, error correction |
159
+ | `test` | Test-only changes (TDD RED phase) |
160
+ | `refactor` | Code cleanup, no behavior change |
161
+ | `perf` | Performance improvement |
162
+ | `docs` | Documentation changes |
163
+ | `chore` | Config, tooling, dependencies |
602
164
 
603
- | Type | When to Use | Example |
604
- |------|-------------|---------|
605
- | `feat` | New feature, endpoint, component, functionality | feat(08-02): create user registration endpoint |
606
- | `fix` | Bug fix, error correction | fix(08-02): correct email validation regex |
607
- | `test` | Test-only changes (TDD RED phase) | test(08-02): add failing test for password hashing |
608
- | `refactor` | Code cleanup, no behavior change (TDD REFACTOR phase) | refactor(08-02): extract validation to helper |
609
- | `perf` | Performance improvement | perf(08-02): add database index for user lookups |
610
- | `docs` | Documentation changes | docs(08-02): add API endpoint documentation |
611
- | `style` | Formatting, linting fixes | style(08-02): format auth module |
612
- | `chore` | Config, tooling, dependencies | chore(08-02): add bcrypt dependency |
613
-
614
- **4. Craft commit message:**
615
-
616
- Format: `{type}({phase}-{plan}): {task-name-or-description}`
165
+ **3. Commit with conventional format:**
617
166
 
618
167
  ```bash
619
- git commit -m "{type}({phase}-{plan}): {concise task description}
168
+ git commit -m "$(cat <<'EOF'
169
+ {type}({phase}-{plan}): {concise task description}
620
170
 
621
171
  - {key change 1}
622
172
  - {key change 2}
623
- - {key change 3}
624
- "
625
- ```
626
-
627
- **Examples:**
628
-
629
- ```bash
630
- # Standard plan task
631
- git commit -m "feat(08-02): create user registration endpoint
632
-
633
- - POST /auth/register validates email and password
634
- - Checks for duplicate users
635
- - Returns JWT token on success
636
- "
637
-
638
- # Another standard task
639
- git commit -m "fix(08-02): correct email validation regex
640
-
641
- - Fixed regex to accept plus-addressing
642
- - Added tests for edge cases
643
- "
173
+ EOF
174
+ )"
644
175
  ```
645
176
 
646
- **Note:** TDD plans have their own commit pattern (test/feat/refactor for RED/GREEN/REFACTOR phases). See `<tdd_plan_execution>` section above.
647
-
648
- **5. Record commit hash:**
649
-
650
- After committing, capture hash for SUMMARY.md:
177
+ **4. Capture hash:**
651
178
 
652
179
  ```bash
653
180
  TASK_COMMIT=$(git rev-parse --short HEAD)
654
- echo "Task ${TASK_NUM} committed: ${TASK_COMMIT}"
655
- ```
656
-
657
- Store in array or list for SUMMARY generation:
658
- ```bash
659
- TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
660
181
  ```
661
182
 
662
- **Atomic commit benefits:**
663
- - Each task independently revertable
664
- - Git bisect finds exact failing task
665
- - Git blame traces line to specific task context
666
- - Clear history for Claude in future sessions
667
- - Better observability for AI-automated workflow
183
+ Track commit hash for summary generation.
668
184
 
669
185
  </task_commit>
670
186
 
@@ -673,537 +189,150 @@ If any task verification fails:
673
189
 
674
190
  STOP. Do not continue to next task.
675
191
 
676
- Present inline:
677
- "Verification failed for Task [X]: [task name]
192
+ Present via AskUserQuestion:
193
+ - What failed (expected vs actual)
194
+ - Options: Retry, Skip (mark incomplete), Stop (investigate)
678
195
 
679
- Expected: [verification criteria]
680
- Actual: [what happened]
681
-
682
- How to proceed?
683
-
684
- 1. Retry - Try the task again
685
- 2. Skip - Mark as incomplete, continue
686
- 3. Stop - Pause execution, investigate"
687
-
688
- Wait for user decision.
689
-
690
- If user chose "Skip", note it in SUMMARY.md under "Issues Encountered".
196
+ If user chose "Skip", note in summary under "Issues Encountered".
691
197
  </step>
692
198
 
693
- <step name="record_completion_time">
694
- Record execution end time and calculate duration:
199
+ <step name="create_summary">
200
+ Record end time and calculate duration:
695
201
 
696
202
  ```bash
697
203
  PLAN_END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
698
204
  PLAN_END_EPOCH=$(date +%s)
699
-
700
205
  DURATION_SEC=$(( PLAN_END_EPOCH - PLAN_START_EPOCH ))
701
206
  DURATION_MIN=$(( DURATION_SEC / 60 ))
702
-
703
- if [[ $DURATION_MIN -ge 60 ]]; then
704
- HRS=$(( DURATION_MIN / 60 ))
705
- MIN=$(( DURATION_MIN % 60 ))
706
- DURATION="${HRS}h ${MIN}m"
707
- else
708
- DURATION="${DURATION_MIN} min"
709
- fi
710
207
  ```
711
208
 
712
- Pass timing data to SUMMARY.md creation.
713
- </step>
714
-
715
- <step name="generate_user_setup">
716
- **Generate USER-SETUP.md if plan has user_setup in frontmatter.**
209
+ Create `{phase}-{plan}-SUMMARY.md` in the plan's phase directory.
717
210
 
718
- Check PLAN.md frontmatter for `user_setup` field:
211
+ **Frontmatter fields populate ALL:**
719
212
 
720
- ```bash
721
- grep -A 50 "^user_setup:" .planning/phases/XX-name/{phase}-{plan}-PLAN.md | head -50
213
+ ```yaml
214
+ ---
215
+ phase: XX-name
216
+ plan: YY
217
+ subsystem: [from plan metadata or .planning/config.json subsystems]
218
+ tags: [searchable tech keywords: jwt, stripe, react, postgres]
219
+
220
+ requires:
221
+ - phase: [prior phase this depends on]
222
+ provides: [what that phase built that this uses]
223
+ provides:
224
+ - [what this plan delivered]
225
+ affects: [phase names/keywords that will need this context]
226
+
227
+ tech-stack:
228
+ added: [new libraries/tools from this plan]
229
+ patterns: [architectural patterns established]
230
+
231
+ key-files:
232
+ created: [important files created]
233
+ modified: [important files modified]
234
+
235
+ key-decisions:
236
+ - "Decision 1"
237
+ - "Decision 2"
238
+
239
+ patterns-established:
240
+ - "Pattern 1: description"
241
+
242
+ mock_hints:
243
+ transient_states:
244
+ - state: "[brief transient UI state description]"
245
+ component: "[file path]"
246
+ trigger: "[async call | animation | timer]"
247
+ external_data:
248
+ - source: "[API endpoint or data source]"
249
+ data_type: "[what kind of data]"
250
+ components: ["[file1]", "[file2]"]
251
+
252
+ duration: Xmin
253
+ completed: YYYY-MM-DD
254
+ ---
722
255
  ```
723
256
 
724
- **If user_setup exists and is not empty:**
725
-
726
- Create `.planning/phases/XX-name/{phase}-USER-SETUP.md` using template from `~/.claude/mindsystem/templates/user-setup.md`.
727
-
728
- **Content generation:**
257
+ **Subsystem:** Use inline `**Subsystem:**` metadata from plan header if present. Otherwise select from `jq -r '.subsystems[]' .planning/config.json`. If novel, append to config.json and log in decisions.
729
258
 
730
- 1. Parse each service in `user_setup` array
731
- 2. For each service, generate sections:
732
- - Environment Variables table (from `env_vars`)
733
- - Account Setup checklist (from `account_setup`, if present)
734
- - Dashboard Configuration steps (from `dashboard_config`, if present)
735
- - Local Development notes (from `local_dev`, if present)
736
- 3. Add verification section with commands to confirm setup works
737
- 4. Set status to "Incomplete"
259
+ **Mock hints:** Reflect on what you built. If UI with transient states (loading, animations, async transitions) or external data dependencies, populate accordingly. If purely backend or no async UI, write `mock_hints: none # reason`. Always populate.
738
260
 
739
- **Example output:**
261
+ **Body structure:**
740
262
 
741
263
  ```markdown
742
- # Phase 10: User Setup Required
264
+ # Phase [X] Plan [Y]: [Name] Summary
743
265
 
744
- **Generated:** 2025-01-14
745
- **Phase:** 10-monetization
746
- **Status:** Incomplete
266
+ **[Substantive one-liner — e.g., "JWT auth with refresh rotation using jose library"]**
747
267
 
748
- ## Environment Variables
268
+ ## Performance
269
+ - **Duration:** [time]
270
+ - **Started:** [ISO timestamp]
271
+ - **Completed:** [ISO timestamp]
272
+ - **Tasks:** [count]
273
+ - **Files modified:** [count]
749
274
 
750
- | Status | Variable | Source | Add to |
751
- |--------|----------|--------|--------|
752
- | [ ] | `STRIPE_SECRET_KEY` | Stripe Dashboard → Developers → API keys → Secret key | `.env.local` |
753
- | [ ] | `STRIPE_WEBHOOK_SECRET` | Stripe Dashboard → Developers → Webhooks → Signing secret | `.env.local` |
275
+ ## Accomplishments
276
+ - [Most important outcome]
277
+ - [Second key accomplishment]
754
278
 
755
- ## Dashboard Configuration
279
+ ## Task Commits
280
+ 1. **Task 1: [name]** - `hash` (type)
281
+ 2. **Task 2: [name]** - `hash` (type)
756
282
 
757
- - [ ] **Create webhook endpoint**
758
- - Location: Stripe Dashboard Developers → Webhooks → Add endpoint
759
- - Details: URL: https://[your-domain]/api/webhooks/stripe, Events: checkout.session.completed
283
+ ## Files Created/Modified
284
+ - `path/file` - What it does
760
285
 
761
- ## Local Development
286
+ ## Decisions Made
287
+ [Key decisions with rationale, or "None — followed plan as specified"]
762
288
 
763
- For local testing:
764
- \`\`\`bash
765
- stripe listen --forward-to localhost:3000/api/webhooks/stripe
766
- \`\`\`
767
-
768
- ## Verification
289
+ ## Deviations from Plan
290
+ [From deviation tracking, or "None — plan executed exactly as written."]
769
291
 
770
- [Verification commands based on service]
292
+ ## Issues Encountered
293
+ [Problems during planned work, or "None"]
771
294
 
772
- ---
773
- **Once all items complete:** Mark status as "Complete"
295
+ ## Next Step
296
+ [Ready for next plan, or "Phase complete, ready for transition"]
774
297
  ```
775
298
 
776
- **If user_setup is empty or missing:**
777
-
778
- Skip this step - no USER-SETUP.md needed.
779
-
780
- **Track for offer_next:**
781
-
782
- Set `USER_SETUP_CREATED=true` if file was generated, for use in completion messaging.
783
- </step>
784
-
785
- <step name="create_summary">
786
- Create `{phase}-{plan}-SUMMARY.md` as specified in the prompt's `<output>` section.
787
- Use ~/.claude/mindsystem/templates/summary.md for structure.
788
-
789
- **File location:** `.planning/phases/XX-name/{phase}-{plan}-SUMMARY.md`
790
-
791
- **Frontmatter population:**
792
-
793
- Before writing summary content, populate frontmatter fields from execution context:
794
-
795
- 1. **Basic identification:**
796
- - phase: From PLAN.md frontmatter
797
- - plan: From PLAN.md frontmatter
798
- - subsystem: Use `subsystem_hint` from PLAN.md frontmatter if present. Otherwise select from config.json subsystems list via `jq -r '.subsystems[]' .planning/config.json`. If novel work, append new value to config.json and log in "Decisions Made".
799
- - tags: Extract tech keywords (libraries, frameworks, tools used)
800
-
801
- 2. **Dependency graph:**
802
- - requires: List prior phases this built upon (check PLAN.md context section for referenced prior summaries)
803
- - provides: Extract from accomplishments - what was delivered
804
- - affects: Infer from phase description/goal what future phases might need this
805
-
806
- 3. **Tech tracking:**
807
- - tech-stack.added: New libraries from package.json changes or requirements
808
- - tech-stack.patterns: Architectural patterns established (from decisions/accomplishments)
809
-
810
- 4. **File tracking:**
811
- - key-files.created: From "Files Created/Modified" section
812
- - key-files.modified: From "Files Created/Modified" section
813
-
814
- 5. **Decisions:**
815
- - key-decisions: Extract from "Decisions Made" section
816
-
817
- 6. **Verification hints (required):**
818
- - mock_hints.transient_states: Reflect on what you built. Any UI with async loading, animations, or transitions that produce brief intermediate states? List each with component file and trigger.
819
- - mock_hints.external_data: Any feature that fetches from an API? List the source, data type, and rendering components.
820
- - If no UI work, no async operations, no external data: write `mock_hints: none` with a brief reason comment (e.g., `mock_hints: none # no transient states or external data dependencies`). Always populate — `none` tells verify-work to skip mock analysis.
821
-
822
- 7. **Metrics:**
823
- - duration: From $DURATION variable
824
- - completed: From $PLAN_END_TIME (date only, format YYYY-MM-DD)
825
-
826
- Note: Subsystem must match config.json vocabulary (or extend it). If affects are unclear, use best judgment based on phase name and accomplishments.
827
-
828
- **Title format:** `# Phase [X] Plan [Y]: [Name] Summary`
829
-
830
- The one-liner must be SUBSTANTIVE:
831
-
299
+ **One-liner must be SUBSTANTIVE:**
832
300
  - Good: "JWT auth with refresh rotation using jose library"
833
301
  - Bad: "Authentication implemented"
834
-
835
- **Include performance data:**
836
-
837
- - Duration: `$DURATION`
838
- - Started: `$PLAN_START_TIME`
839
- - Completed: `$PLAN_END_TIME`
840
- - Tasks completed: (count from execution)
841
- - Files modified: (count from execution)
842
-
843
- **Next Step section:**
844
-
845
- - If more plans exist in this phase: "Ready for {phase}-{next-plan}-PLAN.md"
846
- - If this is the last plan: "Phase complete, ready for transition"
847
- </step>
848
-
849
- <step name="update_current_position">
850
- Update Current Position section in STATE.md to reflect plan completion.
851
-
852
- **Format:**
853
-
854
- ```markdown
855
- Phase: [current] of [total] ([phase name])
856
- Plan: [just completed] of [total in phase]
857
- Status: [In progress / Phase complete]
858
- Last activity: [today] - Completed {phase}-{plan}-PLAN.md
859
-
860
- Progress: [progress bar]
861
- ```
862
-
863
- **Calculate progress bar:**
864
-
865
- - Count total plans across all phases (from ROADMAP.md or ROADMAP.md)
866
- - Count completed plans (count SUMMARY.md files that exist)
867
- - Progress = (completed / total) × 100%
868
- - Render: ░ for incomplete, █ for complete
869
-
870
- **Example - completing 02-01-PLAN.md (plan 5 of 10 total):**
871
-
872
- Before:
873
-
874
- ```markdown
875
- ## Current Position
876
-
877
- Phase: 2 of 4 (Authentication)
878
- Plan: Not started
879
- Status: Ready to execute
880
- Last activity: 2025-01-18 - Phase 1 complete
881
-
882
- Progress: ██████░░░░ 40%
883
- ```
884
-
885
- After:
886
-
887
- ```markdown
888
- ## Current Position
889
-
890
- Phase: 2 of 4 (Authentication)
891
- Plan: 1 of 2 in current phase
892
- Status: In progress
893
- Last activity: 2025-01-19 - Completed 02-01-PLAN.md
894
-
895
- Progress: ███████░░░ 50%
896
- ```
897
-
898
- **Step complete when:**
899
-
900
- - [ ] Phase number shows current phase (X of total)
901
- - [ ] Plan number shows plans complete in current phase (N of total-in-phase)
902
- - [ ] Status reflects current state (In progress / Phase complete)
903
- - [ ] Last activity shows today's date and the plan just completed
904
- - [ ] Progress bar calculated correctly from total completed plans
905
- </step>
906
-
907
- <step name="extract_decisions_and_issues">
908
- Extract decisions, issues, and concerns from SUMMARY.md into STATE.md accumulated context.
909
-
910
- **Decisions Made:**
911
-
912
- - Read SUMMARY.md "## Decisions Made" section
913
- - If content exists (not "None"):
914
- - Add each decision to STATE.md Decisions table
915
- - Format: `| [phase number] | [decision summary] | [rationale] |`
916
-
917
- **Blockers/Concerns:**
918
-
919
- - Read SUMMARY.md "## Next Phase Readiness" section
920
- - If contains blockers or concerns:
921
- - Add to STATE.md "Blockers/Concerns Carried Forward"
922
- </step>
923
-
924
- <step name="update_session_continuity">
925
- Update Session Continuity section in STATE.md to enable resumption in future sessions.
926
-
927
- **Format:**
928
-
929
- ```markdown
930
- Last session: [current date and time]
931
- Stopped at: Completed {phase}-{plan}-PLAN.md
932
- ```
933
-
934
- **Size constraint note:** Keep STATE.md under 150 lines total.
935
302
  </step>
936
303
 
937
- <step name="issues_review_gate">
938
- Before proceeding, check SUMMARY.md content.
939
-
940
- If "Issues Encountered" is NOT "None":
941
-
942
- ```
943
- ⚡ Auto-approved: Issues acknowledgment
944
- ⚠️ Note: Issues were encountered during execution:
945
- - [Issue 1]
946
- - [Issue 2]
947
- (Logged - continuing)
948
- ```
304
+ <step name="return_to_orchestrator">
305
+ Do NOT commit the SUMMARY.md file. Do NOT update STATE.md or ROADMAP.md. The orchestrator handles all post-execution artifacts.
949
306
 
950
- Continue without waiting.
951
- </step>
952
-
953
- <step name="update_roadmap">
954
- Update the roadmap file:
955
-
956
- ```bash
957
- ROADMAP_FILE=".planning/ROADMAP.md"
958
- ```
307
+ Return structured completion format:
959
308
 
960
- **If more plans remain in this phase:**
961
-
962
- - Update plan count: "2/3 plans complete"
963
- - Keep phase status as "In progress"
964
-
965
- **If this was the last plan in the phase:**
966
-
967
- - Mark phase complete: status → "Complete"
968
- - Add completion date
969
- </step>
970
-
971
- <step name="git_commit_metadata">
972
- Commit execution metadata (SUMMARY + STATE + ROADMAP):
973
-
974
- **Note:** All task code has already been committed during execution (one commit per task).
975
- PLAN.md was already committed during plan-phase. This final commit captures execution results only.
976
-
977
- **1. Stage execution artifacts:**
978
-
979
- ```bash
980
- git add .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md
981
- git add .planning/STATE.md
982
- ```
983
-
984
- **2. Stage roadmap:**
985
-
986
- ```bash
987
- git add .planning/ROADMAP.md
988
- ```
989
-
990
- **3. Verify staging:**
991
-
992
- ```bash
993
- git status
994
- # Should show only execution artifacts (SUMMARY, STATE, ROADMAP), no code files
995
- ```
996
-
997
- **4. Commit metadata:**
998
-
999
- ```bash
1000
- git commit -m "$(cat <<'EOF'
1001
- docs({phase}-{plan}): complete [plan-name] plan
1002
-
1003
- Tasks completed: [N]/[N]
1004
- - [Task 1 name]
1005
- - [Task 2 name]
1006
- - [Task 3 name]
1007
-
1008
- SUMMARY: .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md
1009
- EOF
1010
- )"
1011
- ```
1012
-
1013
- **Example:**
1014
-
1015
- ```bash
1016
- git commit -m "$(cat <<'EOF'
1017
- docs(08-02): complete user registration plan
1018
-
1019
- Tasks completed: 3/3
1020
- - User registration endpoint
1021
- - Password hashing with bcrypt
1022
- - Email confirmation flow
1023
-
1024
- SUMMARY: .planning/phases/08-user-auth/08-02-registration-SUMMARY.md
1025
- EOF
1026
- )"
1027
- ```
1028
-
1029
- **Git log after plan execution:**
1030
-
1031
- ```
1032
- abc123f docs(08-02): complete user registration plan
1033
- def456g feat(08-02): add email confirmation flow
1034
- hij789k feat(08-02): implement password hashing with bcrypt
1035
- lmn012o feat(08-02): create user registration endpoint
1036
- ```
1037
-
1038
- Each task has its own commit, followed by one metadata commit documenting plan completion.
1039
-
1040
- For commit message conventions, see ~/.claude/mindsystem/references/git-integration.md
1041
- </step>
1042
-
1043
- <step name="update_codebase_map">
1044
- **If .planning/codebase/ exists:**
1045
-
1046
- Check what changed across all task commits in this plan:
1047
-
1048
- ```bash
1049
- # Find first task commit (right after previous plan's docs commit)
1050
- FIRST_TASK=$(git log --oneline --grep="feat({phase}-{plan}):" --grep="fix({phase}-{plan}):" --grep="test({phase}-{plan}):" --reverse | head -1 | cut -d' ' -f1)
1051
-
1052
- # Get all changes from first task through now
1053
- git diff --name-only ${FIRST_TASK}^..HEAD 2>/dev/null
1054
- ```
1055
-
1056
- **Update only if structural changes occurred:**
1057
-
1058
- | Change Detected | Update Action |
1059
- |-----------------|---------------|
1060
- | New directory in src/ | STRUCTURE.md: Add to directory layout |
1061
- | package.json deps changed | STACK.md: Add/remove from dependencies list |
1062
- | New file pattern (e.g., first .test.ts) | CONVENTIONS.md: Note new pattern |
1063
- | New external API client | INTEGRATIONS.md: Add service entry with file path |
1064
- | Config file added/changed | STACK.md: Update configuration section |
1065
- | File renamed/moved | Update paths in relevant docs |
1066
-
1067
- **Skip update if only:**
1068
- - Code changes within existing files
1069
- - Bug fixes
1070
- - Content changes (no structural impact)
1071
-
1072
- **Update format:**
1073
- Make single targeted edits - add a bullet point, update a path, or remove a stale entry. Don't rewrite sections.
1074
-
1075
- ```bash
1076
- git add .planning/codebase/*.md
1077
- git commit --amend --no-edit # Include in metadata commit
1078
- ```
1079
-
1080
- **If .planning/codebase/ doesn't exist:**
1081
- Skip this step.
1082
- </step>
1083
-
1084
- <step name="offer_next">
1085
- **MANDATORY: Verify remaining work before presenting next steps.**
1086
-
1087
- Do NOT skip this verification. Do NOT assume phase or milestone completion without checking.
1088
-
1089
- **Step 0: Check for USER-SETUP.md**
1090
-
1091
- If `USER_SETUP_CREATED=true` (from generate_user_setup step), always include this warning block at the TOP of completion output:
1092
-
1093
- ```
1094
- ⚠️ USER SETUP REQUIRED
1095
-
1096
- This phase introduced external services requiring manual configuration:
1097
-
1098
- 📋 .planning/phases/{phase-dir}/{phase}-USER-SETUP.md
1099
-
1100
- Quick view:
1101
- - [ ] {ENV_VAR_1}
1102
- - [ ] {ENV_VAR_2}
1103
- - [ ] {Dashboard config task}
1104
-
1105
- Complete this setup for the integration to function.
1106
- Run `cat .planning/phases/{phase-dir}/{phase}-USER-SETUP.md` for full details.
1107
-
1108
- ---
1109
- ```
1110
-
1111
- This warning appears BEFORE "Plan complete" messaging. User sees setup requirements prominently.
1112
-
1113
- **Step 1: Count plans and summaries in current phase**
1114
-
1115
- List files in the phase directory:
1116
-
1117
- ```bash
1118
- ls -1 .planning/phases/[current-phase-dir]/*-PLAN.md 2>/dev/null | wc -l
1119
- ls -1 .planning/phases/[current-phase-dir]/*-SUMMARY.md 2>/dev/null | wc -l
1120
- ```
1121
-
1122
- State the counts: "This phase has [X] plans and [Y] summaries."
1123
-
1124
- **Step 2: Route based on plan completion**
1125
-
1126
- Compare the counts from Step 1:
1127
-
1128
- | Condition | Meaning | Action |
1129
- |-----------|---------|--------|
1130
- | summaries < plans | More plans remain | Go to **Route A** |
1131
- | summaries = plans | Phase complete | Go to Step 3 |
1132
-
1133
- ---
1134
-
1135
- **Route A: More plans remain in this phase**
1136
-
1137
- Identify the next unexecuted plan:
1138
- - Find the first PLAN.md file that has no matching SUMMARY.md
1139
- - Read its `<objective>` section
1140
-
1141
- ```
1142
- Plan {phase}-{plan} complete.
1143
- Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1144
-
1145
- {Y} of {X} plans complete for Phase {Z}.
1146
-
1147
- ⚡ Auto-continuing: Execute next plan ({phase}-{next-plan})
1148
- ```
1149
-
1150
- Loop back to identify_plan step automatically.
1151
-
1152
- **STOP here if Route A applies. Do not continue to Step 3.**
1153
-
1154
- ---
1155
-
1156
- **Step 3: Check milestone status (only when all plans in phase are complete)**
1157
-
1158
- Read ROADMAP.md and extract:
1159
- 1. Current phase number (from the plan just completed)
1160
- 2. All phase numbers listed in the current milestone section
1161
-
1162
- To find phases in the current milestone, look for:
1163
- - Phase headers: lines starting with `### Phase` or `#### Phase`
1164
- - Phase list items: lines like `- [ ] **Phase X:` or `- [x] **Phase X:`
1165
-
1166
- Count total phases in the current milestone and identify the highest phase number.
1167
-
1168
- State: "Current phase is {X}. Milestone has {N} phases (highest: {Y})."
1169
-
1170
- **Step 4: Route based on milestone status**
1171
-
1172
- | Condition | Meaning | Action |
1173
- |-----------|---------|--------|
1174
- | current phase < highest phase | More phases remain | Go to **Route B** |
1175
- | current phase = highest phase | Milestone complete | Go to **Route C** |
1176
-
1177
- ---
309
+ ```markdown
310
+ ## PLAN COMPLETE
1178
311
 
1179
- **Route B: Phase complete, more phases remain in milestone**
312
+ **Plan:** {phase}-{plan}
313
+ **Tasks:** {completed}/{total}
314
+ **Duration:** {duration}
315
+ **SUMMARY:** {path to SUMMARY.md}
1180
316
 
1181
- Show phase completion summary, then read `~/.claude/mindsystem/references/routing/next-phase-routing.md` and follow its instructions to present "Next Up" with pre-work context for the next phase.
317
+ **Commits:**
318
+ - {hash}: {message}
319
+ - {hash}: {message}
1182
320
 
1183
- After the "Next Up" section, add:
1184
- ```
1185
- **Also available:**
1186
- - `/ms:verify-work {Z}` — manual acceptance testing before continuing
321
+ **Deviations:** {count} ({breakdown by rule, or "none"})
322
+ **Issues:** {count or "none"}
1187
323
  ```
1188
-
1189
- ---
1190
-
1191
- **Route C: Milestone complete (all phases done)**
1192
-
1193
- Show phase completion summary, then read `~/.claude/mindsystem/references/routing/milestone-complete-routing.md` and follow its instructions to present the milestone complete section.
1194
-
1195
324
  </step>
1196
325
 
1197
326
  </process>
1198
327
 
1199
328
  <success_criteria>
1200
-
1201
- - All tasks from PLAN.md completed
329
+ - All tasks from plan executed
1202
330
  - All verifications pass
1203
- - USER-SETUP.md generated if user_setup in frontmatter
1204
- - SUMMARY.md created with substantive content
1205
- - STATE.md updated (position, decisions, issues, session)
1206
- - ROADMAP.md updated
1207
- - If codebase map exists: map updated with execution changes (or skipped if no significant changes)
1208
- - If USER-SETUP.md created: prominently surfaced in completion output
1209
- </success_criteria>
331
+ - Each task committed individually with conventional format
332
+ - All deviations documented
333
+ - SUMMARY.md created with substantive content and ALL frontmatter fields
334
+ - Structured completion format returned to orchestrator
335
+ - No STATE.md updates (orchestrator responsibility)
336
+ - No ROADMAP.md updates (orchestrator responsibility)
337
+ - No SUMMARY commit (orchestrator responsibility)
338
+ </success_criteria>