@massu/core 0.5.0 → 0.6.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 (119) hide show
  1. package/README.md +40 -0
  2. package/agents/massu-architecture-reviewer.md +104 -0
  3. package/agents/massu-blast-radius-analyzer.md +84 -0
  4. package/agents/massu-competitive-scorer.md +126 -0
  5. package/agents/massu-help-sync.md +73 -0
  6. package/agents/massu-migration-writer.md +94 -0
  7. package/agents/massu-output-scorer.md +87 -0
  8. package/agents/massu-pattern-reviewer.md +84 -0
  9. package/agents/massu-plan-auditor.md +170 -0
  10. package/agents/massu-schema-sync-verifier.md +70 -0
  11. package/agents/massu-security-reviewer.md +98 -0
  12. package/agents/massu-ux-reviewer.md +106 -0
  13. package/commands/_shared-preamble.md +53 -23
  14. package/commands/_shared-references/auto-learning-protocol.md +71 -0
  15. package/commands/_shared-references/blast-radius-protocol.md +76 -0
  16. package/commands/_shared-references/security-pre-screen.md +64 -0
  17. package/commands/_shared-references/test-first-protocol.md +87 -0
  18. package/commands/_shared-references/verification-table.md +55 -0
  19. package/commands/massu-article-review.md +343 -0
  20. package/commands/massu-autoresearch/references/eval-runner.md +84 -0
  21. package/commands/massu-autoresearch/references/safety-rails.md +125 -0
  22. package/commands/massu-autoresearch/references/scoring-protocol.md +151 -0
  23. package/commands/massu-autoresearch.md +258 -0
  24. package/commands/massu-batch.md +44 -12
  25. package/commands/massu-bearings.md +42 -8
  26. package/commands/massu-checkpoint.md +588 -0
  27. package/commands/massu-ci-fix.md +2 -2
  28. package/commands/massu-command-health.md +132 -0
  29. package/commands/massu-command-improve.md +232 -0
  30. package/commands/massu-commit.md +205 -44
  31. package/commands/massu-create-plan.md +239 -57
  32. package/commands/massu-data/references/common-queries.md +79 -0
  33. package/commands/massu-data/references/table-guide.md +50 -0
  34. package/commands/massu-data.md +66 -0
  35. package/commands/massu-dead-code.md +29 -34
  36. package/commands/massu-debug/references/auto-learning.md +61 -0
  37. package/commands/massu-debug/references/codegraph-tracing.md +80 -0
  38. package/commands/massu-debug/references/common-shortcuts.md +98 -0
  39. package/commands/massu-debug/references/investigation-phases.md +294 -0
  40. package/commands/massu-debug/references/report-format.md +107 -0
  41. package/commands/massu-debug.md +105 -386
  42. package/commands/massu-docs.md +1 -1
  43. package/commands/massu-full-audit.md +61 -0
  44. package/commands/massu-gap-enhancement-analyzer.md +276 -16
  45. package/commands/massu-golden-path/references/approval-points.md +216 -0
  46. package/commands/massu-golden-path/references/competitive-mode.md +273 -0
  47. package/commands/massu-golden-path/references/error-handling.md +121 -0
  48. package/commands/massu-golden-path/references/phase-0-requirements.md +53 -0
  49. package/commands/massu-golden-path/references/phase-1-plan-creation.md +168 -0
  50. package/commands/massu-golden-path/references/phase-2-implementation.md +403 -0
  51. package/commands/massu-golden-path/references/phase-2.5-gap-analyzer.md +170 -0
  52. package/commands/massu-golden-path/references/phase-3-simplify.md +40 -0
  53. package/commands/massu-golden-path/references/phase-3.5-security-audit.md +108 -0
  54. package/commands/massu-golden-path/references/phase-4-commit.md +94 -0
  55. package/commands/massu-golden-path/references/phase-5-push.md +116 -0
  56. package/commands/massu-golden-path/references/phase-5.5-production-verify.md +170 -0
  57. package/commands/massu-golden-path/references/phase-6-completion.md +113 -0
  58. package/commands/massu-golden-path/references/qa-evaluator-spec.md +137 -0
  59. package/commands/massu-golden-path/references/sprint-contract-protocol.md +117 -0
  60. package/commands/massu-golden-path/references/vr-visual-calibration.md +73 -0
  61. package/commands/massu-golden-path.md +121 -844
  62. package/commands/massu-guide.md +72 -69
  63. package/commands/massu-hooks.md +27 -12
  64. package/commands/massu-hotfix.md +221 -144
  65. package/commands/massu-incident.md +49 -20
  66. package/commands/massu-infra-audit.md +187 -0
  67. package/commands/massu-learning-audit.md +211 -0
  68. package/commands/massu-loop/references/auto-learning.md +49 -0
  69. package/commands/massu-loop/references/checkpoint-audit.md +40 -0
  70. package/commands/massu-loop/references/guardrails.md +17 -0
  71. package/commands/massu-loop/references/iteration-structure.md +115 -0
  72. package/commands/massu-loop/references/loop-controller.md +188 -0
  73. package/commands/massu-loop/references/plan-extraction.md +78 -0
  74. package/commands/massu-loop/references/vr-plan-spec.md +140 -0
  75. package/commands/massu-loop-playwright.md +9 -9
  76. package/commands/massu-loop.md +115 -670
  77. package/commands/massu-new-pattern.md +423 -0
  78. package/commands/massu-perf.md +422 -0
  79. package/commands/massu-plan-audit.md +1 -1
  80. package/commands/massu-plan.md +389 -122
  81. package/commands/massu-production-verify.md +433 -0
  82. package/commands/massu-push.md +62 -378
  83. package/commands/massu-recap.md +29 -3
  84. package/commands/massu-rollback.md +613 -0
  85. package/commands/massu-scaffold-hook.md +2 -4
  86. package/commands/massu-scaffold-page.md +2 -3
  87. package/commands/massu-scaffold-router.md +1 -2
  88. package/commands/massu-security.md +619 -0
  89. package/commands/massu-simplify.md +115 -85
  90. package/commands/massu-squirrels.md +2 -2
  91. package/commands/massu-tdd.md +38 -22
  92. package/commands/massu-test.md +3 -3
  93. package/commands/massu-type-mismatch-audit.md +469 -0
  94. package/commands/massu-ui-audit.md +587 -0
  95. package/commands/massu-verify-playwright.md +287 -32
  96. package/commands/massu-verify.md +150 -46
  97. package/dist/cli.js +146 -95
  98. package/package.json +6 -2
  99. package/patterns/build-patterns.md +302 -0
  100. package/patterns/component-patterns.md +246 -0
  101. package/patterns/display-patterns.md +185 -0
  102. package/patterns/form-patterns.md +890 -0
  103. package/patterns/integration-testing-checklist.md +445 -0
  104. package/patterns/security-patterns.md +219 -0
  105. package/patterns/testing-patterns.md +569 -0
  106. package/patterns/tool-routing.md +81 -0
  107. package/patterns/ui-patterns.md +371 -0
  108. package/protocols/plan-implementation.md +267 -0
  109. package/protocols/recovery.md +225 -0
  110. package/protocols/verification.md +404 -0
  111. package/reference/command-taxonomy.md +178 -0
  112. package/reference/cr-rules-reference.md +76 -0
  113. package/reference/hook-execution-order.md +148 -0
  114. package/reference/lessons-learned.md +175 -0
  115. package/reference/patterns-quickref.md +208 -0
  116. package/reference/standards.md +135 -0
  117. package/reference/subagents-reference.md +17 -0
  118. package/reference/vr-verification-reference.md +867 -0
  119. package/src/commands/install-commands.ts +149 -53
@@ -0,0 +1,588 @@
1
+ ---
2
+ name: massu-checkpoint
3
+ description: "When user wants mid-implementation verification, says 'checkpoint', 'check progress', or needs a quality gate during a multi-phase plan"
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), mcp__supabase__DEV__*, mcp__supabase__NEW_PROD__*, mcp__supabase__OLD_PROD__*
5
+ ---
6
+ name: massu-checkpoint
7
+
8
+ # Massu Checkpoint: Phase Boundary Audit Protocol
9
+
10
+ **Shared rules**: Read `.claude/commands/_shared-preamble.md` for POST-COMPACTION (CR-12), ENTERPRISE-GRADE (CR-14), AWS SECRETS (CR-5) rules.
11
+
12
+ Both Code Quality and Plan Coverage gates must pass (see shared preamble). GAPS_DISCOVERED semantics and schema mismatches are also documented there.
13
+
14
+ ---
15
+
16
+ ## MANDATORY LOOP CONTROLLER (EXECUTE THIS - DO NOT SKIP)
17
+
18
+ ### How This Command Works
19
+
20
+ This command is a **loop controller** for phase boundary verification:
21
+ 1. Spawn a `massu-plan-auditor` subagent for ONE complete 15-step checkpoint pass
22
+ 2. Parse the structured result (`GAPS_DISCOVERED: N`)
23
+ 3. If gaps > 0: fix gaps, then spawn ANOTHER FRESH checkpoint pass
24
+ 4. Only when a COMPLETE FRESH PASS discovers ZERO gaps does checkpoint pass
25
+
26
+ ### Execution Protocol
27
+
28
+ ```
29
+ iteration = 0
30
+
31
+ WHILE true:
32
+ iteration += 1
33
+
34
+ result = Task(subagent_type="massu-plan-auditor", model="opus", prompt="
35
+ Checkpoint iteration {iteration}.
36
+ Execute ONE complete 15-step checkpoint audit.
37
+ Run all verification steps. Fix any gaps you find.
38
+
39
+ CRITICAL: GAPS_DISCOVERED = total gaps FOUND during this pass,
40
+ EVEN IF you also fixed them. Finding 5 gaps and fixing all 5 = GAPS_DISCOVERED: 5.
41
+ A clean pass that finds nothing wrong from the start = GAPS_DISCOVERED: 0.
42
+
43
+ Return the structured result block with GAPS_DISCOVERED.
44
+ ")
45
+
46
+ gaps = parse GAPS_DISCOVERED from result
47
+ Output: "Checkpoint iteration {iteration}: {gaps} gaps discovered"
48
+
49
+ IF gaps == 0:
50
+ Output: "CHECKPOINT PASSED - Clean pass with zero gaps in iteration {iteration}"
51
+ BREAK
52
+ ELSE:
53
+ Output: "{gaps} gaps discovered, starting fresh re-check..."
54
+ CONTINUE
55
+ END WHILE
56
+ ```
57
+
58
+ ### Loop Rules
59
+
60
+ 1. NEVER pass checkpoint while gaps > 0 - only a CLEAN zero-gap-from-start iteration allows progression
61
+ 2. NEVER treat "found and fixed" as zero gaps
62
+ 3. NEVER ask user "should I continue?" - the loop is mandatory
63
+ 4. ALWAYS use Task tool for checkpoint passes
64
+ 5. Maximum 10 iterations - if still failing, report to user
65
+
66
+ ---
67
+
68
+ ## Objective
69
+
70
+ Execute full 15-step checkpoint audit for current phase. Require ZERO gaps before allowing progression. Update session state with checkpoint result. Commit only after checkpoint passes.
71
+
72
+ ---
73
+
74
+ ## NON-NEGOTIABLE RULES
75
+
76
+ 1. Zero gaps required - cannot proceed until gaps = 0
77
+ 2. ALL steps executed - no shortcuts (includes Step 0: Plan Coverage)
78
+ 3. Proof required - show verification output
79
+ 4. Session state update mandatory - record checkpoint result
80
+ 5. All 3 DB environments verified (DEV, OLD PROD, NEW PROD)
81
+ 6. UI/UX verification required for UI changes
82
+ 7. Schema verification required - verify column names against real schema
83
+ 8. Plan Coverage required - ALL plan items verified at 100%
84
+ 9. FIX ALL ISSUES ENCOUNTERED (CR-9) - pre-existing or current, "not in scope" is NEVER valid
85
+
86
+ ---
87
+
88
+ ## DOMAIN-SPECIFIC PATTERN LOADING
89
+
90
+ Based on scope, load: `patterns/database-patterns.md`, `patterns/auth-patterns.md`, `patterns/ui-patterns.md`, `patterns/realtime-patterns.md`, `patterns/build-patterns.md` as relevant.
91
+
92
+ ---
93
+
94
+ ## CHECKPOINT AUDIT FLOW (Step 0 + 15 Steps)
95
+
96
+ ### Step 0: PLAN COVERAGE GATE (MANDATORY FIRST STEP)
97
+
98
+ #### 0.1 Extract Plan Items
99
+ ```markdown
100
+ ## PLAN ITEM EXTRACTION - Phase [N]
101
+ | Item # | Type | Description | Expected Location | Verification Command | Status |
102
+ |--------|------|-------------|-------------------|---------------------|--------|
103
+ | P[N]-001 | FILE | [component.tsx] | src/components/ | ls -la [path] | PENDING |
104
+ | P[N]-002 | PROCEDURE | [api.method] | routers/[file].ts | grep "[name]:" | PENDING |
105
+ | P[N]-003 | REMOVAL | [pattern] | all files | grep -rn = 0 | PENDING |
106
+ | P[N]-004 | FEATURE | [UI feature] | src/app/ | VR-RENDER | PENDING |
107
+
108
+ ### Item Type Reference
109
+ | Type | Verification | Expected |
110
+ |------|--------------|----------|
111
+ | FILE | ls -la [path] | Exists, size > 0 |
112
+ | COMPONENT | VR-FILE + VR-RENDER | File exists AND rendered in page |
113
+ | PROCEDURE | grep "[name]:" [router] | Procedure defined |
114
+ | FEATURE | Feature-specific grep | Functionality works |
115
+ | REMOVAL | grep -rn "[pattern]" | 0 matches |
116
+ | MIGRATION | VR-SCHEMA | Column/table exists in ALL 3 envs |
117
+ ```
118
+
119
+ #### 0.2 Verify Each Plan Item
120
+ For EACH item: run verification command, record VERIFIED/MISSING/PARTIAL, update Status.
121
+
122
+ #### 0.3 Calculate Coverage
123
+ ```markdown
124
+ | Metric | Value |
125
+ |--------|-------|
126
+ | Total Items | [N] |
127
+ | Verified | [X] |
128
+ | Missing | [Y] |
129
+ | Coverage | [X/N]% |
130
+ **Coverage Gate: PASS (100%) / FAIL (<100%)**
131
+ ```
132
+
133
+ #### 0.4 Gate Decision
134
+ - Coverage = 100%: Proceed to Step 1
135
+ - Coverage < 100%: LIST missing items, FIX them, RESTART from Step 0
136
+
137
+ ---
138
+
139
+ ### Step 1: READ Plan Section
140
+ Read plan section for this phase. Extract requirements into checklist.
141
+
142
+ ---
143
+
144
+ ### Step 2: QUERY Database (All 3 Environments)
145
+
146
+ | Environment | Project ID | MCP Tool Prefix |
147
+ |-------------|------------|-----------------|
148
+ | DEV | `gwqkbjymbarkufwvdmar` | `mcp__supabase__DEV__` |
149
+ | OLD PROD | `hwaxogapihsqleyzpqtj` | `mcp__supabase__OLD_PROD__` |
150
+ | NEW PROD | `cnfxxvrhhvjefyvpoqlq` | `mcp__supabase__NEW_PROD__` |
151
+
152
+ For EACH affected table, verify: table exists, columns match, RLS policies exist, grants present.
153
+
154
+ ```markdown
155
+ ### DB Verification: [TABLE]
156
+ | Env | Exists | Columns | RLS | Grants | Status |
157
+ |-----|--------|---------|-----|--------|--------|
158
+ | DEV | YES | X/X | X policies | YES | PASS |
159
+ | OLD PROD | YES | X/X | X policies | YES | PASS |
160
+ | NEW PROD | YES | X/X | X policies | YES | PASS |
161
+ ```
162
+
163
+ ---
164
+
165
+ ### Step 2.5: VERIFY Config-Code Alignment (VR-DATA)
166
+
167
+ If config-driven features exist, query actual config JSONB values and compare keys to code expectations. Config schema existing does NOT mean data is correct (Incident #12).
168
+
169
+ ```markdown
170
+ ### VR-DATA Verification: [CONFIG_TABLE]
171
+ | Check | Result | Status |
172
+ |-------|--------|--------|
173
+ | Queried actual config values | [values] | DONE |
174
+ | Extracted config keys | [keys] | DONE |
175
+ | Compared to code expectations | [match?] | MATCH/MISMATCH |
176
+ | Key alignment | 100% | PASS/FAIL |
177
+ ```
178
+
179
+ ---
180
+
181
+ ### Step 3: GREP Router Files (VR-GREP)
182
+
183
+ For each procedure: verify exists, verify input schema, verify protectedProcedure for mutations.
184
+
185
+ ```markdown
186
+ ### Router Verification
187
+ | Procedure | Router | Line | Protected | Status |
188
+ |-----------|--------|------|-----------|--------|
189
+ | [name] | [file] | N | YES/NO | PASS/FAIL |
190
+ ```
191
+
192
+ ---
193
+
194
+ ### Step 4: LS Component Files (VR-FILE)
195
+
196
+ ```markdown
197
+ ### Component Verification
198
+ | Component | Path | Exists | Size | Status |
199
+ |-----------|------|--------|------|--------|
200
+ | [name] | [path] | YES/NO | N bytes | PASS/FAIL |
201
+ ```
202
+
203
+ ### Step 4.5: VR-RENDER - Component Render Verification (CRITICAL)
204
+
205
+ For EVERY UI component created, verify it is RENDERED in a page:
206
+ ```bash
207
+ grep "<ComponentName" src/app/**/page.tsx
208
+ # If 0 matches: THE FEATURE IS NOT IMPLEMENTED
209
+ ```
210
+
211
+ ```markdown
212
+ ### VR-RENDER Verification
213
+ | Component | File Exists | Exported | RENDERED in Page | Status |
214
+ |-----------|-------------|----------|------------------|--------|
215
+ | [name] | YES | YES | YES (page.tsx:L42) | PASS |
216
+ | [name] | YES | YES | NO (0 matches) | **FAIL** |
217
+ ```
218
+
219
+ ---
220
+
221
+ ### Step 5: GREP Pattern Violations
222
+
223
+ ```bash
224
+ ./scripts/pattern-scanner.sh # Exit 0 = PASS
225
+ ```
226
+
227
+ Then manual checks (all expect 0):
228
+ - P-001: `grep -rn "ctx.prisma" src/server/`
229
+ - P-002: `grep -rn "include:" src/server/api/routers/ | grep -v "//"`
230
+ - P-003: `grep -rn "ctx.db.users" src/`
231
+ - P-004: `grep -rn "publicProcedure.mutation" src/`
232
+ - P-005: `grep -rn "prototype:" src/ | grep -v "Object.prototype"`
233
+ - P-006: `grep -rn "from 'jsdom'" src/ | grep -v "await import"`
234
+ - P-007: `grep -rn "BigInt(" src/server/ | grep -i "create\|insert"`
235
+ - P-008: `grep -rn 'value=""' src/ | grep -i "select"`
236
+ - P-009: `grep -rn "updateMany(" src/server/`
237
+ - P-010: `grep -rn "deleteMany(" src/server/`
238
+
239
+ ```markdown
240
+ ### Pattern Compliance
241
+ | Pattern | Count | Status |
242
+ |---------|-------|--------|
243
+ | Pattern Scanner | Exit 0/N | PASS/FAIL |
244
+ | P-001 through P-010 | 0 each | PASS/FAIL |
245
+ ```
246
+
247
+ ---
248
+
249
+ ### Step 6: RUN Build Verification (VR-BUILD)
250
+
251
+ ```bash
252
+ npm run build
253
+ ```
254
+
255
+ ### Step 6.5: Additional Verification Gates
256
+
257
+ ```bash
258
+ npx tsc --noEmit # VR-TYPE: 0 errors
259
+ npm run lint # VR-LINT: Exit 0
260
+ npx prisma validate # VR-SCHEMA-VALIDATE: Exit 0
261
+ npm test # VR-TEST: MANDATORY, ALL pass
262
+ ./scripts/pre-deploy-check.sh 2>/dev/null || echo "No pre-deploy script"
263
+ ```
264
+
265
+ ```markdown
266
+ ### Additional Gates
267
+ | Gate | Command | Result | Status |
268
+ |------|---------|--------|--------|
269
+ | Type Safety | npx tsc --noEmit | 0 errors | PASS/FAIL |
270
+ | Lint | npm run lint | Exit 0 | PASS/FAIL |
271
+ | Prisma Validate | npx prisma validate | Valid | PASS/FAIL |
272
+ | Tests | npm test | ALL Pass | PASS/FAIL |
273
+ | Pre-deploy | pre-deploy-check.sh | Pass/N/A | PASS/FAIL/N/A |
274
+ ```
275
+
276
+ ---
277
+
278
+ ### Step 6.6: VR-COUPLING - Backend-Frontend Coupling (CRITICAL)
279
+
280
+ If backend changes exist, verify UI exposes them:
281
+ ```bash
282
+ ./scripts/check-coupling.sh # Exit 0
283
+ ```
284
+
285
+ ```markdown
286
+ ### VR-COUPLING Verification
287
+ | Check | Result |
288
+ |-------|--------|
289
+ | Enum parity (scraperType) | PASS/FAIL |
290
+ | Enum parity (sourceType) | PASS/FAIL |
291
+ | Form field completeness | PASS/FAIL |
292
+ | Component reuse | N warnings |
293
+ ```
294
+
295
+ ---
296
+
297
+ ### Step 6.7: Knowledge Base Health Check
298
+
299
+ Run the staleness audit to verify knowledge base freshness:
300
+ ```bash
301
+ bash scripts/kb-staleness-audit.sh --verbose
302
+ ```
303
+
304
+ - **WARN results**: Report in checkpoint summary as informational
305
+ - **FAIL results**: Include as action items in the checkpoint report
306
+ - **Does NOT block**: Staleness warnings don't prevent checkpoint completion, but failures should be addressed
307
+
308
+ ```markdown
309
+ ### KB Health Verification
310
+ | Check | Result | Status |
311
+ |-------|--------|--------|
312
+ | Pattern file staleness (30d) | N stale | PASS/WARN |
313
+ | Reference file staleness (90d) | N stale | PASS/WARN |
314
+ | Incident count match | N == N | PASS/FAIL |
315
+ | Agent-command cross-ref | N unreferenced | PASS/WARN |
316
+ | db.ts table count delta | delta N | PASS/WARN |
317
+ | SHAME-RECORDS freshness | up-to-date | PASS/WARN |
318
+ | Session state freshness (7d) | N days | PASS/WARN |
319
+ ```
320
+
321
+ ---
322
+
323
+ ### Step 7: UI/UX Verification (If UI Changes)
324
+
325
+ #### 7.1 Page & Route Verification
326
+ Verify pages exist, nav links valid, auth guards correct.
327
+
328
+ #### 7.2 Button & Action Verification
329
+ All buttons have handlers, all forms have onSubmit.
330
+
331
+ #### 7.3 State Verification
332
+ Loading, empty, error, success states exist.
333
+
334
+ #### 7.4 Mobile & Accessibility
335
+ No `sm:page-container`, images have alt text.
336
+
337
+ #### 7.5 Elegance Check (non-trivial changes only)
338
+ - [ ] No unnecessary abstractions or indirection
339
+ - [ ] No "clever" code that's hard to follow
340
+ - [ ] Could this be simpler while remaining correct?
341
+ - [ ] Would a staff engineer approve this approach?
342
+
343
+ ```markdown
344
+ ### UI/UX Verification
345
+ | Check | Count/Result | Expected | Status |
346
+ |-------|--------------|----------|--------|
347
+ | Pages exist | N pages | All render | PASS/FAIL |
348
+ | Buttons with handlers | N/N | 100% | PASS/FAIL |
349
+ | Forms with onSubmit | N/N | 100% | PASS/FAIL |
350
+ | Loading states | N | > 0 | PASS/FAIL |
351
+ | Empty states | N | > 0 | PASS/FAIL |
352
+ | Error states | N | > 0 | PASS/FAIL |
353
+ | Mobile containers | 0 violations | 0 | PASS/FAIL |
354
+ | Image alt text | 0 missing | 0 | PASS/FAIL |
355
+ ```
356
+
357
+ ---
358
+
359
+ ### Step 8: User Flow Verification (If UI Changes)
360
+
361
+ For each critical user flow:
362
+ ```markdown
363
+ ### User Flow: [FLOW_NAME]
364
+ | Step | Action | Element | Handler/API | Expected | Actual | Status |
365
+ |------|--------|---------|-------------|----------|--------|--------|
366
+ | 1 | Navigate | Link | href | Page loads | Page loads | PASS |
367
+ ```
368
+
369
+ ---
370
+
371
+ ### Step 9: API/Router Verification (If API Changes)
372
+
373
+ Verify procedures exist, are protected, have input validation, and client calls match server.
374
+
375
+ ```markdown
376
+ ### API Verification
377
+ | Procedure | Router | Protected | Input Schema | Client Calls | Status |
378
+ |-----------|--------|-----------|--------------|--------------|--------|
379
+ ```
380
+
381
+ ---
382
+
383
+ ### Step 10: Environment & Console Check
384
+
385
+ Check env vars, no hardcoded secrets, console.log audit.
386
+
387
+ ### Step 10.5: Security - Secrets Check (CR-3 CRITICAL)
388
+
389
+ ```bash
390
+ git diff --cached --name-only | grep -E '\.(env|pem|key|secret)' && echo "FAIL" || echo "PASS"
391
+ ls -la .env* 2>/dev/null | grep -v ".env.example" | wc -l # Expected: 0 in repo
392
+ grep -n "\.env" .gitignore # Patterns present
393
+ ```
394
+
395
+ **If ANY security check fails: HARD STOP.**
396
+
397
+ ---
398
+
399
+ ### Step 11: COUNT Gaps Found
400
+
401
+ ```markdown
402
+ ### Gap Count
403
+ | Category | Gaps | Details |
404
+ |----------|------|---------|
405
+ | Plan Coverage | N | [items] |
406
+ | Requirements | N | [list] |
407
+ | Database | N | [list] |
408
+ | Routers | N | [list] |
409
+ | Components | N | [list] |
410
+ | VR-RENDER | N | [list] |
411
+ | Patterns | N | [list] |
412
+ | Build | N | [list] |
413
+ | UI/UX | N | [list] |
414
+ | User Flows | N | [list] |
415
+ | API Contracts | N | [list] |
416
+ | Environment | N | [list] |
417
+
418
+ **TOTAL GAPS: N**
419
+ **Plan Coverage Gate: [X]/[Y] = [%]% (MUST be 100%)**
420
+ ```
421
+
422
+ ---
423
+
424
+ ### Step 12: FIX Each Gap (If Gaps > 0)
425
+
426
+ For each gap: identify fix, apply fix, run VR-* verification, confirm resolved.
427
+
428
+ ### Step 13: Return to Step 1 (If Gaps > 0)
429
+
430
+ Re-run ENTIRE checkpoint from Step 1. Partial re-checks are NOT valid.
431
+
432
+ ---
433
+
434
+ ### Step 14: CREATE Checkpoint Sign-off (If Gaps = 0)
435
+
436
+ ```markdown
437
+ ## CHECKPOINT [N] SIGN-OFF
438
+
439
+ ### DUAL VERIFICATION STATUS
440
+ | Gate | Status | Evidence |
441
+ |------|--------|----------|
442
+ | **Plan Coverage** | PASS | [X]/[X] items = 100% |
443
+ | **Code Quality** | PASS | All 15 steps passed |
444
+
445
+ ### Requirements Verification
446
+ | Req | Description | Verification | Status |
447
+ |-----|-------------|--------------|--------|
448
+ | R-001 | [desc] | [VR-* proof] | VERIFIED |
449
+
450
+ ### Summary
451
+ - Database: DEV/OLD PROD/NEW PROD verified: PASS
452
+ - Pattern scanner exit 0: PASS
453
+ - Build: PASS (Exit 0)
454
+ - UI/UX: All checks passed
455
+ - API: All procedures verified
456
+ - **TOTAL GAPS: 0**
457
+ - **Status**: CHECKPOINT PASSED
458
+ - **Ready for**: Phase [N+1] / Commit / Complete
459
+ ```
460
+
461
+ ---
462
+
463
+ ### Step 15: COMMIT (If Gaps = 0)
464
+
465
+ Update session state, then commit:
466
+ ```bash
467
+ git add [relevant files]
468
+ git commit -m "$(cat <<'EOF'
469
+ [type]: [description] - Checkpoint [N]
470
+
471
+ Phase [N] complete with zero gaps.
472
+
473
+ Verified:
474
+ - Pattern scanner: PASS
475
+ - Type check: 0 errors
476
+ - Build: PASS
477
+ - DB: DEV/OLD PROD/NEW PROD verified
478
+
479
+ Co-Authored-By: Claude <noreply@anthropic.com>
480
+ EOF
481
+ )"
482
+ ```
483
+
484
+ ---
485
+
486
+ ## SESSION STATE UPDATE
487
+
488
+ After checkpoint, update `session-state/CURRENT.md`:
489
+
490
+ ```markdown
491
+ ## CHECKPOINT SESSION
492
+
493
+ ### Checkpoint
494
+ - **Phase**: [N]
495
+ - **Status**: PASSED / FAILED
496
+ - **Date**: [timestamp]
497
+ - **Audit loops**: [N]
498
+ - **Gaps found**: [N] (all resolved)
499
+
500
+ ### Verification Results
501
+ | Check | Result |
502
+ |-------|--------|
503
+ | Pattern scanner | PASS |
504
+ | Type check | 0 errors |
505
+ | Build | PASS |
506
+ | DB (DEV/OLD PROD/NEW PROD) | PASS |
507
+
508
+ ### Files Changed
509
+ - [file1.ts]
510
+
511
+ ### Next Phase
512
+ - Phase [N+1]: [description]
513
+ ```
514
+
515
+ ---
516
+
517
+ ## PLAN DOCUMENT COMPLETION TRACKING
518
+
519
+ When checkpoint passes, update plan document with completion status at TOP:
520
+
521
+ ```markdown
522
+ # IMPLEMENTATION STATUS
523
+ **Status**: IN_PROGRESS / COMPLETE
524
+ **Last Checkpoint**: Phase [N]
525
+
526
+ | # | Task/Phase | Status | Date |
527
+ |---|------------|--------|------|
528
+ | 1 | Phase 1 | 100% COMPLETE | 2026-01-20 |
529
+ | 2 | Phase 2 | IN PROGRESS | - |
530
+ ```
531
+
532
+ VR-PLAN-STATUS: Verify with `grep "IMPLEMENTATION STATUS" [plan_file]` after updating.
533
+
534
+ ---
535
+
536
+ ## QUALITY SCORING GATE
537
+
538
+ Before declaring complete, spawn `massu-output-scorer` (model="sonnet"):
539
+ - Code Clarity, Pattern Compliance, Error Handling, UX Quality, Test Coverage (1-5 each)
540
+ - All scores >= 3: PASS | Any < 3: FAIL | Average >= 4: EXCELLENT
541
+
542
+ ---
543
+
544
+ ## ABORT CONDITIONS
545
+
546
+ Checkpoint MUST abort if: pattern scanner fails, security violation detected, build fails after 3 attempts, or DB drift between environments. Report reason, details, recovery options.
547
+
548
+ ---
549
+
550
+ ## PARALLEL EXECUTION
551
+
552
+ Independent checks can run simultaneously via Task agents:
553
+ - Agent 1: `npx tsc --noEmit`
554
+ - Agent 2: `./scripts/pattern-scanner.sh`
555
+ - Agent 3: `npm run build`
556
+ - Agent 4: `npm run test:run`
557
+
558
+ ---
559
+
560
+ ## START NOW
561
+
562
+ **Step 0: Write AUTHORIZED_COMMAND to session state (CR-12)**
563
+
564
+ Update `session-state/CURRENT.md` to include:
565
+ ```
566
+ AUTHORIZED_COMMAND: massu-checkpoint
567
+ ```
568
+
569
+ **Execute the LOOP CONTROLLER at the top of this file.**
570
+
571
+ 1. Identify current phase number and read the plan section
572
+ 2. Spawn `massu-plan-auditor` subagent (via Task tool) for checkpoint iteration 1
573
+ 3. Parse `GAPS_FOUND` from the subagent result
574
+ 4. If gaps > 0: fix gaps, spawn another iteration
575
+ 5. If gaps == 0: checkpoint passes - proceed to commit
576
+ 6. Update session state with checkpoint result
577
+
578
+ **Zero gaps required. No exceptions. Show all verification output.**
579
+
580
+ ---
581
+
582
+ ## AUTO-LEARNING PROTOCOL (MANDATORY at every checkpoint)
583
+
584
+ After phase passes:
585
+ 1. **Ingest learnings**: `massu_memory_ingest` with type="checkpoint" for bugs, patterns, failed approaches
586
+ 2. **Update MEMORY.md**: Record wrong vs correct patterns discovered
587
+ 3. **Update pattern scanner**: Add new grep-able bad patterns to `scripts/pattern-scanner.sh`
588
+ 4. **Codebase-wide search (CR-9)**: For each bug fixed, verify no other instances exist
@@ -5,10 +5,10 @@ allowed-tools: Bash(*), Read(*), Edit(*), Write(*), Grep(*), Glob(*)
5
5
  ---
6
6
  name: massu-ci-fix
7
7
 
8
- # Massu CI Fix: Auto-Diagnose and Fix CI Failures
9
-
10
8
  > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
11
9
 
10
+ # Massu CI Fix: Auto-Diagnose and Fix CI Failures
11
+
12
12
  ## Objective
13
13
 
14
14
  Automatically pull CI failure logs, diagnose root cause, fix, commit, and re-push. Zero cognitive load.