mindsystem-cc 3.11.0 → 3.13.0

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