@massu/core 0.1.2 → 0.4.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 (84) hide show
  1. package/commands/_shared-preamble.md +76 -0
  2. package/commands/massu-audit-deps.md +211 -0
  3. package/commands/massu-changelog.md +174 -0
  4. package/commands/massu-cleanup.md +315 -0
  5. package/commands/massu-commit.md +481 -0
  6. package/commands/massu-create-plan.md +752 -0
  7. package/commands/massu-dead-code.md +131 -0
  8. package/commands/massu-debug.md +484 -0
  9. package/commands/massu-deploy.md +91 -0
  10. package/commands/massu-deps.md +374 -0
  11. package/commands/massu-doc-gen.md +279 -0
  12. package/commands/massu-docs.md +364 -0
  13. package/commands/massu-estimate.md +313 -0
  14. package/commands/massu-golden-path.md +973 -0
  15. package/commands/massu-guide.md +167 -0
  16. package/commands/massu-hotfix.md +480 -0
  17. package/commands/massu-loop-playwright.md +837 -0
  18. package/commands/massu-loop.md +775 -0
  19. package/commands/massu-new-feature.md +511 -0
  20. package/commands/massu-parity.md +214 -0
  21. package/commands/massu-plan.md +456 -0
  22. package/commands/massu-push-light.md +207 -0
  23. package/commands/massu-push.md +434 -0
  24. package/commands/massu-refactor.md +410 -0
  25. package/commands/massu-release.md +363 -0
  26. package/commands/massu-review.md +238 -0
  27. package/commands/massu-simplify.md +281 -0
  28. package/commands/massu-status.md +278 -0
  29. package/commands/massu-tdd.md +201 -0
  30. package/commands/massu-test.md +516 -0
  31. package/commands/massu-verify-playwright.md +281 -0
  32. package/commands/massu-verify.md +667 -0
  33. package/dist/cli.js +12522 -0
  34. package/dist/hooks/cost-tracker.js +80 -5
  35. package/dist/hooks/post-edit-context.js +72 -6
  36. package/dist/hooks/post-tool-use.js +234 -57
  37. package/dist/hooks/pre-compact.js +144 -5
  38. package/dist/hooks/pre-delete-check.js +141 -11
  39. package/dist/hooks/quality-event.js +80 -5
  40. package/dist/hooks/security-gate.js +29 -0
  41. package/dist/hooks/session-end.js +83 -8
  42. package/dist/hooks/session-start.js +153 -7
  43. package/dist/hooks/user-prompt.js +166 -5
  44. package/package.json +6 -5
  45. package/src/backfill-sessions.ts +5 -4
  46. package/src/cli.ts +6 -0
  47. package/src/commands/doctor.ts +193 -6
  48. package/src/commands/init.ts +235 -6
  49. package/src/commands/install-commands.ts +137 -0
  50. package/src/config.ts +68 -2
  51. package/src/db.ts +115 -2
  52. package/src/docs-tools.ts +8 -6
  53. package/src/hooks/post-edit-context.ts +1 -1
  54. package/src/hooks/post-tool-use.ts +130 -0
  55. package/src/hooks/pre-compact.ts +23 -1
  56. package/src/hooks/pre-delete-check.ts +92 -4
  57. package/src/hooks/security-gate.ts +32 -0
  58. package/src/hooks/session-start.ts +97 -4
  59. package/src/hooks/user-prompt.ts +46 -1
  60. package/src/import-resolver.ts +2 -1
  61. package/src/knowledge-db.ts +169 -0
  62. package/src/knowledge-indexer.ts +704 -0
  63. package/src/knowledge-tools.ts +1413 -0
  64. package/src/license.ts +482 -0
  65. package/src/memory-db.ts +14 -1
  66. package/src/observation-extractor.ts +11 -4
  67. package/src/page-deps.ts +3 -2
  68. package/src/python/coupling-detector.ts +124 -0
  69. package/src/python/domain-enforcer.ts +83 -0
  70. package/src/python/impact-analyzer.ts +95 -0
  71. package/src/python/import-parser.ts +244 -0
  72. package/src/python/import-resolver.ts +135 -0
  73. package/src/python/migration-indexer.ts +115 -0
  74. package/src/python/migration-parser.ts +332 -0
  75. package/src/python/model-indexer.ts +70 -0
  76. package/src/python/model-parser.ts +279 -0
  77. package/src/python/route-indexer.ts +58 -0
  78. package/src/python/route-parser.ts +317 -0
  79. package/src/python-tools.ts +629 -0
  80. package/src/sentinel-db.ts +2 -1
  81. package/src/server.ts +29 -6
  82. package/src/session-archiver.ts +4 -5
  83. package/src/tools.ts +283 -31
  84. package/README.md +0 -40
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: massu-dead-code
3
+ description: Detect and remove dead code — orphaned modules, unused exports, unused dependencies
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
+ ---
6
+ name: massu-dead-code
7
+
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9 enforced.
9
+
10
+ # Massu Dead Code: Automated Dead Code Detection & Removal
11
+
12
+ ## Objective
13
+
14
+ Identify and safely remove dead code (orphaned modules, unused exports, unused dependencies, unreferenced files) using manual verification and codebase analysis.
15
+
16
+ ---
17
+
18
+ ## NON-NEGOTIABLE RULES
19
+
20
+ - **Verify before removing** - grep for alternative import paths, barrel exports, dynamic imports
21
+ - **Blast radius analysis** - every removal gets a grep check for references
22
+ - **Build must pass after** - VR-BUILD + VR-TYPE mandatory after removals
23
+ - **No false positives** - if unsure, KEEP the code
24
+ - **FIX ALL ISSUES ENCOUNTERED (CR-9)** - if dead code reveals other issues, fix them too
25
+
26
+ ---
27
+
28
+ ## PROTOCOL
29
+
30
+ ### Step 1: Inventory Source Files
31
+
32
+ ```bash
33
+ # List all source files
34
+ find packages/core/src -name "*.ts" -not -path "*/__tests__/*" -not -path "*/node_modules/*" | sort
35
+
36
+ # List all exports
37
+ grep -rn "export " packages/core/src/ --include="*.ts" | grep -v "__tests__" | grep -v "node_modules"
38
+ ```
39
+
40
+ ### Step 2: Find Unused Exports
41
+
42
+ For each exported function/class/constant, check if it's imported elsewhere:
43
+
44
+ ```bash
45
+ # For each export, verify it has importers
46
+ grep -rn "import.*[name]" packages/core/src/ --include="*.ts"
47
+ ```
48
+
49
+ Cross-reference with `tools.ts` registrations - tool definitions and handlers are always "used" even if not directly imported elsewhere.
50
+
51
+ ### Step 3: Categorize Findings
52
+
53
+ | Category | Source | Action |
54
+ |----------|--------|--------|
55
+ | ORPHANED_MODULE | No imports found | Verify not dynamically loaded, remove if truly orphaned |
56
+ | UNUSED_EXPORT | No importers | Check if used via re-export, remove if dead |
57
+ | UNUSED_DEPENDENCY | package.json | `npm uninstall` after verifying not dynamically required |
58
+ | UNUSED_FILE | No references | Verify no require() or dynamic import(), remove if dead |
59
+ | DEAD_FUNCTION | Never called | Verify not exported for external use, remove if dead |
60
+
61
+ ### Step 4: Verify Each Finding
62
+
63
+ For EACH candidate removal:
64
+
65
+ ```bash
66
+ # Check for all possible import patterns
67
+ grep -rn "import.*[name]" packages/core/src/ --include="*.ts"
68
+ grep -rn "require.*[name]" packages/core/src/ --include="*.ts"
69
+ grep -rn "[name]" packages/core/src/tools.ts
70
+ grep -rn "[name]" massu.config.yaml
71
+ ```
72
+
73
+ If ANY reference found: KEEP (mark as false positive).
74
+ If NO references found: candidate for removal.
75
+
76
+ ### Step 5: Present Removal Plan
77
+
78
+ ```markdown
79
+ ## Dead Code Removal Plan
80
+
81
+ | # | File/Export | Category | References Found | Action | Risk |
82
+ |---|------------|----------|-----------------|--------|------|
83
+ | 1 | packages/core/src/X.ts | ORPHAN | 0 | REMOVE | Low |
84
+ | 2 | lodash (dep) | UNUSED_DEP | 0 direct | UNINSTALL | Medium |
85
+ ```
86
+
87
+ **WAIT FOR USER APPROVAL before executing removals.**
88
+
89
+ ### Step 6: Execute Removals
90
+
91
+ After user approval:
92
+ 1. Remove files/exports/dependencies
93
+ 2. Run `npm run build` (VR-BUILD)
94
+ 3. Run `cd packages/core && npx tsc --noEmit` (VR-TYPE)
95
+ 4. Run `npm test` (VR-TEST)
96
+ 5. Run `bash scripts/massu-pattern-scanner.sh`
97
+
98
+ ### Step 7: Report
99
+
100
+ ```markdown
101
+ ## Dead Code Removal Report
102
+
103
+ - **Files removed**: N
104
+ - **Exports removed**: N
105
+ - **Dependencies uninstalled**: N
106
+ - **Build**: PASS
107
+ - **Types**: PASS
108
+ - **Tests**: PASS
109
+ ```
110
+
111
+ ---
112
+
113
+ ## QUICK COMMANDS
114
+
115
+ ```bash
116
+ # Check for unused dependencies
117
+ npx depcheck packages/core
118
+
119
+ # Pattern scanner (verify no violations introduced)
120
+ bash scripts/massu-pattern-scanner.sh
121
+
122
+ # Full build verification
123
+ npm run build
124
+
125
+ # Full test suite
126
+ npm test
127
+ ```
128
+
129
+ ---
130
+
131
+ **Remember: Dead code removal is a cleanup operation. When in doubt, keep the code.**
@@ -0,0 +1,484 @@
1
+ ---
2
+ name: massu-debug
3
+ description: Systematic debugging with hypothesis testing, root cause tracing, and verified fixes
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
+ ---
6
+ name: massu-debug
7
+
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-35 enforced.
9
+
10
+ # CS Debug: Systematic Debugging Protocol
11
+
12
+ ## Objective
13
+
14
+ Trace errors to root cause systematically using hypothesis-driven investigation. Never guess — read the code, form hypotheses, test them, and verify fixes don't break anything else.
15
+
16
+ **Usage**: `/massu-debug [error description, test name, or stack trace]`
17
+
18
+ ---
19
+
20
+ ## NON-NEGOTIABLE RULES
21
+
22
+ - **Never guess the root cause** — read the code
23
+ - **Never apply a fix without understanding WHY it works**
24
+ - **Always verify the fix doesn't break other tests**
25
+ - **Record each hypothesis and its outcome**
26
+ - **FIX ALL ISSUES ENCOUNTERED (CR-9)** — if you find additional bugs while debugging, fix those too
27
+ - **Proof > reasoning. Commands > assumptions.**
28
+ - **No blind changes** — Understand before modifying
29
+
30
+ ---
31
+
32
+ ## ZERO-GAP AUDIT LOOP
33
+
34
+ **Debugging does NOT complete until a SINGLE COMPLETE VERIFICATION finds ZERO remaining issues.**
35
+
36
+ ```
37
+ DEBUG VERIFICATION LOOP:
38
+ 1. Apply fix(es)
39
+ 2. Run ALL verification checks for the fix
40
+ 3. Count remaining issues found
41
+ 4. IF issues > 0:
42
+ - Root cause not fully addressed
43
+ - Re-investigate and fix
44
+ - Return to Step 2
45
+ 5. IF issues == 0:
46
+ - BUG FIXED AND VERIFIED
47
+ ```
48
+
49
+ | Scenario | Action |
50
+ |----------|--------|
51
+ | Fix reveals new issue | Address it, re-verify ENTIRE fix |
52
+ | Re-verify finds 1 issue | Fix it, re-verify ENTIRELY |
53
+ | Re-verify finds 0 issues | **NOW** debug complete |
54
+
55
+ **Partial verification is NOT valid. The fix must be fully verified in a SINGLE run.**
56
+
57
+ ---
58
+
59
+ ## DOMAIN-SPECIFIC PATTERN LOADING
60
+
61
+ Based on the bug's domain, load relevant pattern sections from CLAUDE.md:
62
+
63
+ | Domain | Section | Load When |
64
+ |--------|---------|-----------|
65
+ | Tool modules | Tool Registration Pattern | Tool registration/handler bugs |
66
+ | Config | Config Access Pattern | Config parsing/access bugs |
67
+ | Hooks | Hook stdin/stdout Pattern | Hook compilation/runtime bugs |
68
+ | Build | Build & Test Commands | Build/compilation errors |
69
+ | Database | SQLite Database Pattern | DB access bugs |
70
+
71
+ ---
72
+
73
+ ## STEP 0: REPRODUCE THE FAILURE (MANDATORY)
74
+
75
+ Before investigating root cause, CONFIRM you can trigger the exact error.
76
+
77
+ 1. Identify the exact reproduction steps from user report
78
+ 2. Execute those steps (or equivalent verification commands)
79
+ 3. Capture the actual error output
80
+ 4. If you CANNOT reproduce: document that and investigate why
81
+
82
+ WHY: Debugging without reproduction is guessing. Fixes without reproduction cannot be verified.
83
+
84
+ ### 0.2 Memory Check
85
+
86
+ Before investigating, search for past failures related to this issue:
87
+
88
+ - Check session state (`.claude/session-state/CURRENT.md`) for recent failures
89
+ - Search codebase for similar error patterns
90
+ - Check if this is a known issue with an established fix pattern
91
+
92
+ If matches found: read the previous failures and avoid repeating failed approaches.
93
+
94
+ ---
95
+
96
+ ## STEP 1: SYMPTOM CAPTURE
97
+
98
+ ### 1.0 Error Category Matrix
99
+
100
+ | Error Type | Likely Cause | First Check |
101
+ |------------|--------------|-------------|
102
+ | TypeError | Null/undefined value | Null guards in source |
103
+ | Import error | Missing/wrong module path | ESM import path |
104
+ | Config error | Missing config key | massu.config.yaml |
105
+ | Build fail | TypeScript/esbuild error | tsc output |
106
+ | Test fail | Assertion mismatch | Test expectations |
107
+ | Tool not found | Missing registration | tools.ts wiring |
108
+ | Hook timeout | Heavy dependency or infinite loop | Hook source |
109
+
110
+ Record the exact error from `$ARGUMENTS`:
111
+
112
+ ```markdown
113
+ ### Symptom
114
+ - **Error**: [exact error message or test name]
115
+ - **Stack trace**: [if provided]
116
+ - **Unexpected behavior**: [what happened vs what was expected]
117
+ - **Reproducible**: [how to reproduce — test command, user action, etc.]
118
+ ```
119
+
120
+ **If `$ARGUMENTS` is a test name:**
121
+ ```bash
122
+ # Run the specific test to capture the full error
123
+ npx vitest run [test-file-or-pattern] 2>&1
124
+ ```
125
+
126
+ **If `$ARGUMENTS` is an error message:**
127
+ ```bash
128
+ # Search for the error message in the codebase
129
+ grep -rn "[error message]" packages/core/src/ --include="*.ts" --include="*.tsx"
130
+ ```
131
+
132
+ **If `$ARGUMENTS` is vague or missing:**
133
+ ```
134
+ OUTPUT: "Please provide one of: (1) exact error message, (2) failing test name, (3) stack trace, (4) steps to reproduce"
135
+ ABORT
136
+ ```
137
+
138
+ ---
139
+
140
+ ## STEP 2: LOCATE ERROR SOURCE
141
+
142
+ ### From Stack Trace
143
+
144
+ Parse the stack trace for the originating file and line number:
145
+
146
+ ```bash
147
+ # Read the file at the error location with 50 lines of surrounding context
148
+ # (25 lines before, 25 lines after the error line)
149
+ ```
150
+
151
+ ### From Error Message
152
+
153
+ ```bash
154
+ # Grep for the error message string in source code
155
+ grep -rn "[error message text]" packages/core/src/ --include="*.ts"
156
+ # Also search in other package directories if applicable
157
+ grep -rn "[error message text]" packages/ --include="*.ts" --include="*.tsx"
158
+ ```
159
+
160
+ ### From Test Failure
161
+
162
+ ```bash
163
+ # Read the failing test to understand what it expects
164
+ # Read the source module the test imports
165
+ ```
166
+
167
+ ```markdown
168
+ ### Error Location
169
+ - **File**: [file path]
170
+ - **Line**: [line number]
171
+ - **Function**: [function name]
172
+ - **Context**: [what this code is supposed to do]
173
+ ```
174
+
175
+ ---
176
+
177
+ ## STEP 3: TRACE CALL CHAIN
178
+
179
+ Follow function calls upstream to understand the full execution path:
180
+
181
+ ```bash
182
+ # Find who calls this function
183
+ grep -rn "[function_name](" packages/core/src/ --include="*.ts"
184
+
185
+ # Find what arguments are passed
186
+ # Read each caller to understand the data flow
187
+ ```
188
+
189
+ Build the call chain:
190
+
191
+ ```markdown
192
+ ### Call Chain
193
+ ```
194
+ caller_1() [file_1.ts:NN]
195
+ → caller_2() [file_2.ts:NN]
196
+ → error_site() [file_3.ts:NN] ← ERROR HERE
197
+ ```
198
+
199
+ ### Data Flow
200
+ | Step | Variable | Value/Type | Source |
201
+ |------|----------|------------|--------|
202
+ | 1 | [var] | [value/type] | [where it comes from] |
203
+ | 2 | [var] | [value/type] | [transformation] |
204
+ | 3 | [var] | [unexpected value] | ← MISMATCH |
205
+ ```
206
+
207
+ ---
208
+
209
+ ## STEP 4: HYPOTHESIS FORMATION
210
+
211
+ Based on code reading (NOT guessing), form up to 3 ranked hypotheses:
212
+
213
+ ```markdown
214
+ ### Hypotheses
215
+
216
+ | # | Hypothesis | Confidence | Verification Method |
217
+ |---|-----------|------------|---------------------|
218
+ | H1 | [most likely cause based on code reading] | HIGH/MED/LOW | [specific command or check to verify] |
219
+ | H2 | [alternative cause] | HIGH/MED/LOW | [specific command or check to verify] |
220
+ | H3 | [least likely cause] | HIGH/MED/LOW | [specific command or check to verify] |
221
+ ```
222
+
223
+ **Hypothesis quality requirements:**
224
+ - Each hypothesis must be based on SPECIFIC code you read (cite file:line)
225
+ - Each verification method must be a CONCRETE action (bash command, grep, read specific file)
226
+ - "Something might be wrong" is NOT a valid hypothesis
227
+
228
+ ---
229
+
230
+ ## STEP 5: HYPOTHESIS TESTING
231
+
232
+ Test hypotheses in order of confidence (highest first):
233
+
234
+ ```
235
+ FOR EACH hypothesis (highest confidence first):
236
+ 1. Execute the verification method
237
+ 2. Record the result
238
+ 3. IF confirmed → proceed to STEP 6
239
+ 4. IF rejected → record why and test next hypothesis
240
+
241
+ IF all hypotheses rejected:
242
+ - Expand search scope
243
+ - Read more files in the call chain
244
+ - Check for environmental factors (config, DB state, imports)
245
+ - Form new hypotheses and repeat from STEP 4
246
+ ```
247
+
248
+ ```markdown
249
+ ### Hypothesis Testing Results
250
+
251
+ | # | Hypothesis | Verification | Result | Outcome |
252
+ |---|-----------|-------------|--------|---------|
253
+ | H1 | [hypothesis] | [what you did] | [what you found] | CONFIRMED / REJECTED |
254
+ | H2 | [hypothesis] | [what you did] | [what you found] | CONFIRMED / REJECTED |
255
+ | H3 | [hypothesis] | [what you did] | [what you found] | CONFIRMED / REJECTED |
256
+ ```
257
+
258
+ ---
259
+
260
+ ## STEP 6: ROOT CAUSE DOCUMENTATION
261
+
262
+ Document the confirmed root cause before applying any fix:
263
+
264
+ ```markdown
265
+ ### Root Cause
266
+
267
+ - **What**: [precise description of the bug]
268
+ - **Why**: [why this bug exists — missing check, wrong assumption, stale code, etc.]
269
+ - **Where**: [file(s) and line(s) affected]
270
+ - **When introduced**: [if determinable — recent commit, original code, etc.]
271
+ - **Blast radius**: [what else could be affected by this bug and by the fix]
272
+ ```
273
+
274
+ ---
275
+
276
+ ## STEP 7: APPLY FIX
277
+
278
+ ### Scope Check
279
+
280
+ ```
281
+ IF fix touches > 5 files:
282
+ OUTPUT: "Fix scope is large ([N] files). Consider using /massu-create-plan for a structured approach."
283
+ ASK user whether to proceed or create a plan
284
+ ```
285
+
286
+ ### Apply the Fix
287
+
288
+ 1. **Apply the minimal correct fix** following CLAUDE.md patterns
289
+ 2. **Document what was changed and why**
290
+ 3. **Do NOT make unrelated improvements** — fix the bug only
291
+
292
+ ```markdown
293
+ ### Fix Applied
294
+
295
+ | File | Change | Reason |
296
+ |------|--------|--------|
297
+ | [file:line] | [what was changed] | [why this fixes the root cause] |
298
+ ```
299
+
300
+ ---
301
+
302
+ ## STEP 8: VERIFY FIX
303
+
304
+ ### 8a. Targeted Test (if exists)
305
+
306
+ ```bash
307
+ # Run the originally-failing test
308
+ npx vitest run [test file] 2>&1
309
+ ```
310
+
311
+ **Must pass.** If it still fails, go back to STEP 4 with new information.
312
+
313
+ ### 8b. Full Test Suite (VR-TEST)
314
+
315
+ ```bash
316
+ npm test 2>&1
317
+ # MUST exit 0, ALL tests pass
318
+ ```
319
+
320
+ ### 8c. Type Check (VR-TYPE)
321
+
322
+ ```bash
323
+ cd packages/core && npx tsc --noEmit
324
+ # MUST show 0 errors
325
+ ```
326
+
327
+ ### 8d. Pattern Scanner (VR-PATTERN)
328
+
329
+ ```bash
330
+ bash scripts/massu-pattern-scanner.sh
331
+ # MUST exit 0
332
+ ```
333
+
334
+ ### 8e. Hook Build (VR-HOOK-BUILD, if hooks modified)
335
+
336
+ ```bash
337
+ cd packages/core && npm run build:hooks
338
+ # MUST exit 0
339
+ ```
340
+
341
+ **If ANY verification fails:**
342
+ 1. Investigate the new failure
343
+ 2. Determine if it was caused by the fix or is pre-existing
344
+ 3. Fix it (CR-9: fix ALL issues encountered)
345
+ 4. Re-run ALL verification from 8a
346
+
347
+ ---
348
+
349
+ ## STEP 9: RECORD FOR LEARNING
350
+
351
+ Update session state with the debugging outcome:
352
+
353
+ ```bash
354
+ # Update .claude/session-state/CURRENT.md with:
355
+ # - Bug description
356
+ # - Root cause
357
+ # - Fix applied
358
+ # - Lesson learned
359
+ ```
360
+
361
+ ```markdown
362
+ ### Learning Record
363
+ - **Bug**: [one-line description]
364
+ - **Root Cause**: [one-line explanation]
365
+ - **Fix**: [one-line description of fix]
366
+ - **Lesson**: [what to watch for in the future to prevent similar bugs]
367
+ - **Pattern**: [if this reveals a recurring pattern, note it for potential pattern scanner rule]
368
+ ```
369
+
370
+ ---
371
+
372
+ ## ABORT CONDITIONS
373
+
374
+ | Condition | Action |
375
+ |-----------|--------|
376
+ | Cannot reproduce the error | Report reproduction failure, ask for more details |
377
+ | Root cause is in external dependency | Report finding, suggest dependency update or workaround |
378
+ | Fix requires architectural changes | Abort, suggest `/massu-create-plan` |
379
+ | All hypotheses rejected after 2 rounds | Report findings, escalate to user with all evidence gathered |
380
+
381
+ ---
382
+
383
+ ## MANDATORY PLAN DOCUMENT UPDATE (If Debug From Plan)
384
+
385
+ **If debug session was part of a plan, update the plan document.**
386
+
387
+ ```markdown
388
+ # IMPLEMENTATION STATUS
389
+
390
+ **Plan**: [Plan Name]
391
+ **Status**: DEBUG COMPLETE / PARTIAL
392
+ **Last Updated**: [YYYY-MM-DD HH:MM]
393
+
394
+ ## Bug Fixes Applied
395
+
396
+ | # | Bug Description | Status | Verification | Date |
397
+ |---|-----------------|--------|--------------|------|
398
+ | 1 | [Bug from plan] | FIXED | VR-BUILD: Pass | [date] |
399
+
400
+ ## Root Causes Identified
401
+
402
+ | Bug | Root Cause | Prevention |
403
+ |-----|-----------|------------|
404
+ | [bug] | [cause] | [how to prevent] |
405
+ ```
406
+
407
+ ---
408
+
409
+ ## AUTO-LEARNING PROTOCOL (MANDATORY after every fix)
410
+
411
+ After EVERY bug fix:
412
+
413
+ ### Step 1: Record the Pattern
414
+ Update `.claude/session-state/CURRENT.md` with:
415
+ - What was wrong (the incorrect pattern)
416
+ - What fixed it (the correct pattern)
417
+ - File(s) affected
418
+
419
+ ### Step 2: Add to Pattern Scanner (if grep-able)
420
+ If the incorrect pattern can be detected by grep, consider adding it to `scripts/massu-pattern-scanner.sh`.
421
+
422
+ ### Step 3: Search Codebase-Wide (CR-9)
423
+ ```bash
424
+ grep -rn "[bad_pattern]" packages/core/src/ --include="*.ts"
425
+ ```
426
+ Fix ALL instances found, not just the one that was reported.
427
+
428
+ ---
429
+
430
+ ## COMPLETION REPORT
431
+
432
+ ```markdown
433
+ ## CS DEBUG COMPLETE
434
+
435
+ ### Symptom
436
+ - **Error**: [original error]
437
+
438
+ ### Investigation
439
+ - **Hypotheses tested**: [N]
440
+ - **Confirmed hypothesis**: H[N] — [description]
441
+
442
+ ### Root Cause
443
+ - **What**: [bug description]
444
+ - **Why**: [why it happened]
445
+ - **Where**: [file:line]
446
+
447
+ ### Fix Applied
448
+ | File | Change |
449
+ |------|--------|
450
+ | [file] | [change description] |
451
+
452
+ ### Verification
453
+ | Check | Status |
454
+ |-------|--------|
455
+ | Target test | PASS |
456
+ | Full test suite | PASS ([N] tests) |
457
+ | Type check | PASS (0 errors) |
458
+ | Pattern scanner | PASS |
459
+
460
+ ### Learning
461
+ - **Lesson**: [what was learned]
462
+ - **Prevention**: [how to prevent in future]
463
+ ```
464
+
465
+ ---
466
+
467
+ ## START NOW
468
+
469
+ 1. Capture the symptom with exact error messages
470
+ 2. **Reproduce the failure** (Step 0 - MANDATORY)
471
+ 3. Categorize the error type using the matrix
472
+ 4. Load relevant pattern section from CLAUDE.md
473
+ 5. Check session-state for past related failures
474
+ 6. Trace the call chain
475
+ 7. Form hypotheses and test each
476
+ 8. Identify root cause with evidence
477
+ 9. Apply minimal fix following CLAUDE.md
478
+ 10. Verify fix with VR-* protocols
479
+ 11. Check for regressions (full test suite)
480
+ 12. **Execute AUTO-LEARNING PROTOCOL** (record, scan, search)
481
+ 13. Update session state
482
+ 14. Produce debug report
483
+
484
+ **Remember: Evidence over assumptions. Prove, don't guess. Learn from every fix.**
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: massu-deploy
3
+ description: Deploy the current project to Vercel
4
+ allowed-tools: Bash(*), Read(*), Grep(*), Glob(*)
5
+ ---
6
+ name: massu-deploy
7
+
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
9
+
10
+ # Massu Deploy: Autonomous Deployment Pipeline
11
+
12
+ ## Workflow Position
13
+
14
+ ```
15
+ /massu-create-plan -> /massu-plan -> /massu-loop -> /massu-commit -> /massu-push -> /massu-deploy
16
+ (CREATE) (AUDIT) (IMPLEMENT) (COMMIT) (PUSH) (DEPLOY)
17
+ ```
18
+
19
+ **This command deploys the website to Vercel production with pre-flight checks.**
20
+
21
+ ---
22
+
23
+ ## CRITICAL: THIS COMMAND DEPLOYS TO PRODUCTION
24
+
25
+ **This command runs `scripts/massu-deploy.sh` which deploys to the Vercel project `massu`.**
26
+
27
+ ### Pre-Flight Checks (automatic)
28
+ 1. Branch check — must be on `main` with clean working tree
29
+ 2. Project target verification — must match projectId `prj_Io7AaGCM27cwRQerAj3BdihUur1Y`
30
+ 3. Local build verification — `npm run build` must succeed
31
+ 4. Deploy to production — `vercel --prod --yes`
32
+ 5. Smoke tests — GET `/` and `/docs` must return 200
33
+ 6. Rollback guidance — if smoke tests fail, prints rollback command
34
+
35
+ ---
36
+
37
+ ## NON-NEGOTIABLE RULES
38
+
39
+ - Never create a new Vercel project — always deploy to the existing `massu` project
40
+ - Never deploy with uncommitted changes
41
+ - Always verify build locally before deploying
42
+ - Always run smoke tests after deployment
43
+ - Use `printf` (not `echo`) for any env var operations
44
+
45
+ ---
46
+
47
+ ## START NOW
48
+
49
+ ### Step 1: Dry Run First
50
+
51
+ Run the deploy script in dry-run mode to verify pre-flight checks:
52
+
53
+ ```bash
54
+ bash scripts/massu-deploy.sh --dry-run
55
+ ```
56
+
57
+ If dry-run passes, ask user for approval:
58
+
59
+ ```
60
+ ===============================================================================
61
+ APPROVAL REQUIRED: DEPLOY TO PRODUCTION
62
+ ===============================================================================
63
+
64
+ Pre-flight checks passed. Ready to deploy.
65
+
66
+ Target: Vercel project "massu" (prj_Io7AaGCM27cwRQerAj3BdihUur1Y)
67
+ Branch: [current branch]
68
+
69
+ OPTIONS:
70
+ - Type "approve" or "deploy" to deploy to production
71
+ - Type "abort" to cancel
72
+
73
+ ===============================================================================
74
+ ```
75
+
76
+ ### Step 2: Deploy
77
+
78
+ After approval, run the full deploy:
79
+
80
+ ```bash
81
+ bash scripts/massu-deploy.sh
82
+ ```
83
+
84
+ ### Step 3: Report Results
85
+
86
+ Report the deployment URL and smoke test results.
87
+
88
+ If smoke tests fail, provide the rollback command:
89
+ ```bash
90
+ cd website && npx vercel rollback --yes
91
+ ```