@massu/core 0.4.2 → 0.6.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 (125) 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 +52 -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 +397 -0
  51. package/commands/massu-golden-path/references/phase-2.5-gap-analyzer.md +156 -0
  52. package/commands/massu-golden-path/references/phase-3-simplify.md +40 -0
  53. package/commands/massu-golden-path/references/phase-4-commit.md +94 -0
  54. package/commands/massu-golden-path/references/phase-5-push.md +116 -0
  55. package/commands/massu-golden-path/references/phase-5.5-production-verify.md +170 -0
  56. package/commands/massu-golden-path/references/phase-6-completion.md +113 -0
  57. package/commands/massu-golden-path/references/qa-evaluator-spec.md +137 -0
  58. package/commands/massu-golden-path/references/sprint-contract-protocol.md +117 -0
  59. package/commands/massu-golden-path/references/vr-visual-calibration.md +73 -0
  60. package/commands/massu-golden-path.md +114 -848
  61. package/commands/massu-guide.md +72 -69
  62. package/commands/massu-hooks.md +27 -12
  63. package/commands/massu-hotfix.md +221 -144
  64. package/commands/massu-incident.md +49 -20
  65. package/commands/massu-infra-audit.md +187 -0
  66. package/commands/massu-learning-audit.md +211 -0
  67. package/commands/massu-loop/references/auto-learning.md +49 -0
  68. package/commands/massu-loop/references/checkpoint-audit.md +40 -0
  69. package/commands/massu-loop/references/guardrails.md +17 -0
  70. package/commands/massu-loop/references/iteration-structure.md +115 -0
  71. package/commands/massu-loop/references/loop-controller.md +188 -0
  72. package/commands/massu-loop/references/plan-extraction.md +78 -0
  73. package/commands/massu-loop/references/vr-plan-spec.md +140 -0
  74. package/commands/massu-loop-playwright.md +9 -9
  75. package/commands/massu-loop.md +115 -670
  76. package/commands/massu-new-pattern.md +423 -0
  77. package/commands/massu-perf.md +422 -0
  78. package/commands/massu-plan-audit.md +1 -1
  79. package/commands/massu-plan.md +389 -122
  80. package/commands/massu-production-verify.md +433 -0
  81. package/commands/massu-push.md +62 -378
  82. package/commands/massu-recap.md +29 -3
  83. package/commands/massu-rollback.md +613 -0
  84. package/commands/massu-scaffold-hook.md +2 -4
  85. package/commands/massu-scaffold-page.md +2 -3
  86. package/commands/massu-scaffold-router.md +1 -2
  87. package/commands/massu-security.md +619 -0
  88. package/commands/massu-simplify.md +115 -85
  89. package/commands/massu-squirrels.md +2 -2
  90. package/commands/massu-tdd.md +38 -22
  91. package/commands/massu-test.md +3 -3
  92. package/commands/massu-type-mismatch-audit.md +469 -0
  93. package/commands/massu-ui-audit.md +587 -0
  94. package/commands/massu-verify-playwright.md +287 -32
  95. package/commands/massu-verify.md +150 -46
  96. package/dist/cli.js +1451 -1047
  97. package/dist/hooks/post-tool-use.js +75 -6
  98. package/dist/hooks/user-prompt.js +16 -0
  99. package/package.json +6 -2
  100. package/patterns/build-patterns.md +302 -0
  101. package/patterns/component-patterns.md +246 -0
  102. package/patterns/display-patterns.md +185 -0
  103. package/patterns/form-patterns.md +890 -0
  104. package/patterns/integration-testing-checklist.md +445 -0
  105. package/patterns/security-patterns.md +219 -0
  106. package/patterns/testing-patterns.md +569 -0
  107. package/patterns/tool-routing.md +81 -0
  108. package/patterns/ui-patterns.md +371 -0
  109. package/protocols/plan-implementation.md +267 -0
  110. package/protocols/recovery.md +225 -0
  111. package/protocols/verification.md +404 -0
  112. package/reference/command-taxonomy.md +178 -0
  113. package/reference/cr-rules-reference.md +76 -0
  114. package/reference/hook-execution-order.md +148 -0
  115. package/reference/lessons-learned.md +175 -0
  116. package/reference/patterns-quickref.md +208 -0
  117. package/reference/standards.md +135 -0
  118. package/reference/subagents-reference.md +17 -0
  119. package/reference/vr-verification-reference.md +867 -0
  120. package/src/commands/init.ts +27 -0
  121. package/src/commands/install-commands.ts +149 -53
  122. package/src/hooks/post-tool-use.ts +17 -0
  123. package/src/hooks/user-prompt.ts +21 -0
  124. package/src/memory-file-ingest.ts +127 -0
  125. package/src/memory-tools.ts +34 -1
@@ -0,0 +1,613 @@
1
+ ---
2
+ name: massu-rollback
3
+ description: "When user says 'rollback', 'revert this', 'undo changes', 'go back', or needs to safely undo code or database changes with state preservation"
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), mcp__supabase__DEV__*, mcp__supabase__NEW_PROD__*, mcp__supabase__OLD_PROD__*
5
+ disable-model-invocation: true
6
+ ---
7
+ name: massu-rollback
8
+
9
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-14, CR-5, CR-12 enforced.
10
+
11
+ # Massu Rollback: Safe Rollback Protocol
12
+
13
+ ## Objective
14
+
15
+ Safely **rollback code and/or database changes** with state preservation, impact assessment, and verification. Know the blast radius before acting.
16
+
17
+ ---
18
+
19
+ ## NON-NEGOTIABLE RULES
20
+
21
+ - **Assess before acting** - Understand what will be undone
22
+ - **Preserve state** - Document current state before rollback
23
+ - **Database caution** - Data loss is permanent
24
+ - **Verify rollback** - Confirm system works after rollback
25
+ - **Never force push to main** - Unless explicitly approved
26
+ - **Document everything** - Full audit trail
27
+
28
+ ---
29
+
30
+ ## ZERO-GAP AUDIT LOOP
31
+
32
+ **Rollback does NOT complete until a SINGLE COMPLETE VERIFICATION finds ZERO issues.**
33
+
34
+ ### The Rule
35
+
36
+ ```
37
+ ROLLBACK VERIFICATION LOOP:
38
+ 1. Apply rollback
39
+ 2. Run ALL verification checks (build, types, tests, DB)
40
+ 3. Count issues found
41
+ 4. IF issues > 0:
42
+ - Address issues
43
+ - Re-run ENTIRE verification from Step 2
44
+ 5. IF issues == 0:
45
+ - ROLLBACK VERIFIED
46
+ - System stable
47
+ ```
48
+
49
+ ### Completion Requirement
50
+
51
+ | Scenario | Action |
52
+ |----------|--------|
53
+ | Rollback causes build failure | Fix it, re-verify ENTIRELY |
54
+ | Re-verify finds DB inconsistency | Fix it, re-verify ENTIRELY |
55
+ | Re-verify finds 0 issues | **NOW** rollback complete |
56
+
57
+ **Partial verification is NOT valid. ALL checks must pass in a SINGLE run after rollback.**
58
+
59
+ ---
60
+
61
+ ## SUPABASE ENVIRONMENTS
62
+
63
+ | Environment | Project ID | MCP Tool Prefix |
64
+ |-------------|------------|-----------------|
65
+ | DEV | `gwqkbjymbarkufwvdmar` | `mcp__supabase__DEV__` |
66
+ | OLD PROD | `hwaxogapihsqleyzpqtj` | `mcp__supabase__OLD_PROD__` |
67
+ | NEW PROD | `cnfxxvrhhvjefyvpoqlq` | `mcp__supabase__NEW_PROD__` |
68
+
69
+ ---
70
+
71
+ ## ROLLBACK TYPES
72
+
73
+ | Type | Scope | Risk | Reversibility |
74
+ |------|-------|------|---------------|
75
+ | **Code Only** | Git revert | LOW | Easy |
76
+ | **Dependencies** | package.json | MEDIUM | Moderate |
77
+ | **Schema** | DB structure | HIGH | Hard |
78
+ | **Data** | DB content | CRITICAL | Impossible |
79
+ | **Full** | Code + DB | CRITICAL | Varies |
80
+
81
+ ---
82
+
83
+ ## MANDATORY PRE-ROLLBACK VERIFICATION (For Schema/Data Rollbacks)
84
+
85
+ ### VR-SCHEMA-PRE: Verify Schema State BEFORE Rollback
86
+
87
+ **BEFORE executing ANY database rollback, you MUST verify current schema state.**
88
+
89
+ ```sql
90
+ -- VR-SCHEMA-PRE: Query ACTUAL current state (NEVER assume)
91
+ SELECT column_name, data_type, is_nullable, column_default
92
+ FROM information_schema.columns
93
+ WHERE table_name = '[AFFECTED_TABLE]'
94
+ ORDER BY ordinal_position;
95
+
96
+ -- Verify target rollback state (from backup/history)
97
+ -- Compare current vs target to understand what will change
98
+ ```
99
+
100
+ **Gate:**
101
+ - [ ] Captured current schema state
102
+ - [ ] Know target (rolled-back) schema state
103
+ - [ ] Understand all differences
104
+ - [ ] Verified in ALL affected environments
105
+
106
+ ### VR-DATA: Verify Data Integrity After Rollback
107
+
108
+ **AFTER database rollback, verify data integrity matches expectations.**
109
+
110
+ ```sql
111
+ -- VR-DATA: Query data to verify integrity
112
+ SELECT COUNT(*) as row_count FROM [TABLE];
113
+
114
+ -- For JSONB columns, verify key structure
115
+ SELECT DISTINCT jsonb_object_keys(config_column) as keys
116
+ FROM [TABLE]
117
+ WHERE config_column IS NOT NULL;
118
+
119
+ -- Verify no orphaned records
120
+ SELECT COUNT(*) FROM [TABLE] t
121
+ LEFT JOIN [RELATED_TABLE] r ON t.foreign_key = r.id
122
+ WHERE r.id IS NULL;
123
+ ```
124
+
125
+ **Why This Is Mandatory:**
126
+ - Rollbacks can leave data in inconsistent state
127
+ - JSONB configs may have different key structures after rollback
128
+ - Foreign key relationships may be broken
129
+
130
+ **Gate:**
131
+ - [ ] Verified row counts match expectations
132
+ - [ ] Verified JSONB key structures match code expectations
133
+ - [ ] Verified no orphaned records
134
+ - [ ] Verified in ALL affected environments
135
+
136
+ ---
137
+
138
+ ## PHASE 1: ASSESSMENT
139
+
140
+ ### 1.1 Identify What to Rollback
141
+ ```markdown
142
+ ## ROLLBACK ASSESSMENT
143
+
144
+ ### Target
145
+ - **Type**: Code / Schema / Data / Full
146
+ - **Commits**: [hash(es)]
147
+ - **Files affected**: [count]
148
+ - **Database changes**: YES/NO
149
+
150
+ ### Trigger
151
+ - **Issue**: [What went wrong]
152
+ - **Severity**: P0/P1/P2
153
+ - **Discovered**: [When/how]
154
+ ```
155
+
156
+ ### 1.2 Code Change Assessment
157
+ ```bash
158
+ # View commits to rollback
159
+ git log --oneline -10
160
+
161
+ # View specific commit changes
162
+ git show [commit-hash] --stat
163
+
164
+ # View diff of commit
165
+ git show [commit-hash]
166
+
167
+ # Find all files changed in range
168
+ git diff --name-only [old-hash]..[new-hash]
169
+ ```
170
+
171
+ ### 1.3 Database Change Assessment
172
+ ```bash
173
+ # List recent migrations
174
+ # Use mcp__supabase__[ENV]__list_migrations
175
+
176
+ # Check what migration added/changed
177
+ # Review migration SQL
178
+ ```
179
+
180
+ ### 1.4 Impact Matrix
181
+ ```markdown
182
+ ### Rollback Impact Assessment
183
+
184
+ | Area | Current State | After Rollback | Risk |
185
+ |------|--------------|----------------|------|
186
+ | Code version | [hash] | [target-hash] | LOW |
187
+ | DB schema | [version] | [target-version] | HIGH |
188
+ | Data state | [description] | [impact] | CRITICAL |
189
+ | Dependencies | [list] | [changes] | MEDIUM |
190
+
191
+ ### Affected Features
192
+ - [Feature 1]: [impact]
193
+ - [Feature 2]: [impact]
194
+
195
+ ### User Impact
196
+ - Active users: [estimate]
197
+ - Data at risk: [Y/N]
198
+ - Downtime expected: [duration]
199
+ ```
200
+
201
+ ---
202
+
203
+ ## PHASE 2: STATE PRESERVATION
204
+
205
+ ### 2.1 Capture Current State
206
+ ```bash
207
+ # Git state
208
+ git log --oneline -5 > /tmp/rollback-git-state.txt
209
+ git status >> /tmp/rollback-git-state.txt
210
+
211
+ # Current branch and HEAD
212
+ echo "Branch: $(git branch --show-current)" >> /tmp/rollback-git-state.txt
213
+ echo "HEAD: $(git rev-parse HEAD)" >> /tmp/rollback-git-state.txt
214
+
215
+ # List of modified files
216
+ git diff --name-only HEAD~5 >> /tmp/rollback-git-state.txt
217
+ ```
218
+
219
+ ### 2.2 Database Backup (If DB Rollback)
220
+ ```sql
221
+ -- Create backup table before destructive changes
222
+ CREATE TABLE [table]_backup_[date] AS SELECT * FROM [table];
223
+
224
+ -- Or export critical data
225
+ -- Use pg_dump or Supabase backup features
226
+ ```
227
+
228
+ ### 2.3 State Snapshot Document
229
+ ```markdown
230
+ ## PRE-ROLLBACK STATE SNAPSHOT
231
+
232
+ ### Git State
233
+ - **Current HEAD**: [hash]
234
+ - **Branch**: [name]
235
+ - **Last 5 commits**: [list]
236
+
237
+ ### Database State
238
+ - **Migration version**: [version]
239
+ - **Tables affected**: [list]
240
+ - **Row counts**: [table: count]
241
+
242
+ ### Application State
243
+ - **Build status**: WORKING/BROKEN
244
+ - **Last successful deploy**: [hash/date]
245
+ - **Active incidents**: [list]
246
+
247
+ ### Backup Locations
248
+ - Git: [remote/reflog]
249
+ - Database: [backup table/export]
250
+ - Config: [backup location]
251
+ ```
252
+
253
+ ---
254
+
255
+ ## PHASE 3: CODE ROLLBACK
256
+
257
+ ### 3.1 Revert Single Commit
258
+ ```bash
259
+ # Create revert commit (SAFE - preserves history)
260
+ git revert [commit-hash] --no-edit
261
+
262
+ # Preview what will be reverted
263
+ git revert [commit-hash] --no-commit
264
+ git diff --cached
265
+
266
+ # If looks wrong, abort
267
+ git revert --abort
268
+ ```
269
+
270
+ ### 3.2 Revert Multiple Commits
271
+ ```bash
272
+ # Revert range of commits (newest to oldest)
273
+ git revert [oldest-hash]..[newest-hash] --no-edit
274
+
275
+ # Or revert each individually
276
+ git revert [hash-1] --no-edit
277
+ git revert [hash-2] --no-edit
278
+ ```
279
+
280
+ ### 3.3 Reset to Specific Commit (CAUTION)
281
+ ```bash
282
+ # Soft reset - keeps changes staged
283
+ git reset --soft [target-hash]
284
+
285
+ # Mixed reset - keeps changes unstaged
286
+ git reset [target-hash]
287
+
288
+ # Hard reset - DISCARDS all changes (DANGEROUS)
289
+ git reset --hard [target-hash]
290
+ # WARNING: This discards uncommitted work!
291
+ ```
292
+
293
+ ### 3.4 Push Rollback
294
+ ```bash
295
+ # After revert commits (SAFE)
296
+ git push origin [branch]
297
+
298
+ # After hard reset (REQUIRES FORCE - DANGEROUS)
299
+ # WARNING: Only do this if explicitly approved!
300
+ git push origin [branch] --force-with-lease
301
+ ```
302
+
303
+ ---
304
+
305
+ ## PHASE 4: DEPENDENCY ROLLBACK
306
+
307
+ ### 4.1 Restore Previous package.json
308
+ ```bash
309
+ # Get package.json from specific commit
310
+ git checkout [commit-hash] -- package.json package-lock.json
311
+
312
+ # Reinstall dependencies
313
+ rm -rf node_modules
314
+ npm install
315
+
316
+ # Verify lock file
317
+ npm ci
318
+ ```
319
+
320
+ ### 4.2 Rollback Specific Package
321
+ ```bash
322
+ # Install specific version
323
+ npm install [package]@[version]
324
+
325
+ # Check what version was used before
326
+ git show [commit-hash]:package.json | grep [package]
327
+ ```
328
+
329
+ ---
330
+
331
+ ## PHASE 5: DATABASE ROLLBACK
332
+
333
+ ### 5.1 Schema Rollback (Migration Revert)
334
+ ```sql
335
+ -- CAUTION: Schema rollbacks can cause data loss!
336
+
337
+ -- Drop new column (loses data in that column)
338
+ ALTER TABLE [table] DROP COLUMN [column];
339
+
340
+ -- Drop new table (loses all data in table)
341
+ DROP TABLE [table];
342
+
343
+ -- Revert column type change
344
+ ALTER TABLE [table] ALTER COLUMN [column] TYPE [old_type];
345
+ ```
346
+
347
+ ### 5.2 Apply Rollback Migration
348
+ Apply to environments in order: DEV first, then OLD PROD, then NEW PROD
349
+
350
+ ```sql
351
+ -- Always wrap in transaction
352
+ BEGIN;
353
+
354
+ -- Your rollback SQL here
355
+ -- ...
356
+
357
+ -- Verify before commit
358
+ SELECT * FROM [table] LIMIT 5;
359
+
360
+ COMMIT;
361
+ -- Or ROLLBACK; if something is wrong
362
+ ```
363
+
364
+ ### 5.3 Data Rollback (If Backup Exists)
365
+ ```sql
366
+ -- CRITICAL: Data loss is permanent without backup!
367
+
368
+ -- Restore from backup table
369
+ INSERT INTO [table] SELECT * FROM [table]_backup_[date]
370
+ ON CONFLICT (id) DO UPDATE SET
371
+ column1 = EXCLUDED.column1,
372
+ column2 = EXCLUDED.column2;
373
+
374
+ -- Or full restore (DESTRUCTIVE)
375
+ TRUNCATE TABLE [table];
376
+ INSERT INTO [table] SELECT * FROM [table]_backup_[date];
377
+ ```
378
+
379
+ ### 5.4 RLS Policy Rollback
380
+ ```sql
381
+ -- Drop new policies
382
+ DROP POLICY IF EXISTS "[policy_name]" ON [table];
383
+
384
+ -- Restore old policies
385
+ CREATE POLICY "[old_policy_name]" ON [table]
386
+ FOR [SELECT/INSERT/UPDATE/DELETE]
387
+ TO [role]
388
+ USING ([condition]);
389
+ ```
390
+
391
+ ---
392
+
393
+ ## PHASE 6: VERIFICATION
394
+
395
+ ### 6.1 Code Verification
396
+ ```bash
397
+ # Type check
398
+ npx tsc --noEmit
399
+
400
+ # Build
401
+ npm run build
402
+
403
+ # Pattern scanner
404
+ ./scripts/pattern-scanner.sh
405
+
406
+ # VR-COUPLING: Backend-frontend sync (CRITICAL - Added Jan 2026)
407
+ ./scripts/check-coupling.sh
408
+ # Expected: Exit 0 - all backend features exposed in UI
409
+
410
+ # Tests
411
+ npm test
412
+ ```
413
+
414
+ ### 6.2 Database Verification
415
+ ```sql
416
+ -- Verify schema state
417
+ SELECT column_name, data_type
418
+ FROM information_schema.columns
419
+ WHERE table_name = '[table]';
420
+
421
+ -- Verify RLS
422
+ SELECT polname FROM pg_policies WHERE tablename = '[table]';
423
+
424
+ -- Verify row counts
425
+ SELECT COUNT(*) FROM [table];
426
+
427
+ -- Verify data integrity
428
+ SELECT * FROM [table] WHERE [expected_condition] LIMIT 5;
429
+ ```
430
+
431
+ ### 6.3 Application Verification
432
+ ```bash
433
+ # Start dev server
434
+ npm run dev
435
+
436
+ # Check critical routes respond
437
+ curl -I http://localhost:3000/
438
+ curl -I http://localhost:3000/api/health
439
+ ```
440
+
441
+ ### 6.4 Verification Matrix
442
+ ```markdown
443
+ ### Post-Rollback Verification
444
+
445
+ | Check | Command | Expected | Actual | Status |
446
+ |-------|---------|----------|--------|--------|
447
+ | Type check | npx tsc --noEmit | 0 errors | [N] | PASS/FAIL |
448
+ | Build | npm run build | Exit 0 | [exit code] | PASS/FAIL |
449
+ | Patterns | pattern-scanner.sh | Exit 0 | [exit code] | PASS/FAIL |
450
+ | VR-COUPLING | check-coupling.sh | Exit 0 | [exit code] | PASS/FAIL |
451
+ | Tests | npm test | All pass | [result] | PASS/FAIL |
452
+ | DB Schema | SQL query | [expected] | [actual] | PASS/FAIL |
453
+ | App starts | npm run dev | No errors | [result] | PASS/FAIL |
454
+
455
+ **ALL VERIFICATIONS: PASS/FAIL**
456
+ ```
457
+
458
+ ---
459
+
460
+ ## PHASE 7: DEPLOY ROLLBACK
461
+
462
+ ### 7.1 Push to Production
463
+ ```bash
464
+ # After all verifications pass
465
+ git push origin main
466
+
467
+ # Monitor deployment
468
+ # Watch Vercel/deployment platform
469
+ ```
470
+
471
+ ### 7.2 Post-Deploy Verification
472
+ ```bash
473
+ # Check production site
474
+ curl -I https://[production-url]/
475
+
476
+ # Check API health
477
+ curl https://[production-url]/api/health
478
+
479
+ # Monitor logs for errors
480
+ # Use mcp__supabase__NEW_PROD__get_logs for each service
481
+ ```
482
+
483
+ ---
484
+
485
+ ## ROLLBACK REPORT FORMAT
486
+
487
+ ```markdown
488
+ ## MASSU ROLLBACK REPORT
489
+
490
+ ### Summary
491
+ - **Date**: [timestamp]
492
+ - **Type**: Code / Schema / Data / Full
493
+ - **Severity**: P0/P1/P2
494
+ - **Duration**: [time]
495
+
496
+ ### Trigger
497
+ - **Issue**: [description]
498
+ - **Impact**: [who/what affected]
499
+ - **Decision by**: [person]
500
+
501
+ ### What Was Rolled Back
502
+ - **Commits**: [list of hashes]
503
+ - **Files**: [count] files
504
+ - **DB changes**: [description or N/A]
505
+
506
+ ### Rollback Method
507
+ - [ ] Git revert (safe)
508
+ - [ ] Git reset (destructive)
509
+ - [ ] Migration revert
510
+ - [ ] Data restore
511
+
512
+ ### Pre-Rollback State
513
+ - HEAD: [hash]
514
+ - DB version: [version]
515
+ - Last working: [hash]
516
+
517
+ ### Post-Rollback State
518
+ - HEAD: [hash]
519
+ - DB version: [version]
520
+ - Status: STABLE
521
+
522
+ ### Verification
523
+ | Check | Result |
524
+ |-------|--------|
525
+ | Type check | PASS |
526
+ | Build | PASS |
527
+ | Tests | PASS |
528
+ | DB integrity | PASS |
529
+ | Production | WORKING |
530
+
531
+ ### Root Cause (Preliminary)
532
+ [Brief description of what caused the issue]
533
+
534
+ ### Follow-up Required
535
+ - [ ] Investigate root cause
536
+ - [ ] Add tests for regression
537
+ - [ ] Update documentation
538
+ - [ ] Post-mortem meeting
539
+
540
+ **ROLLBACK STATUS: COMPLETE / PARTIAL / FAILED**
541
+ ```
542
+
543
+ ---
544
+
545
+ ## SESSION STATE UPDATE
546
+
547
+ After rollback, update `session-state/CURRENT.md`:
548
+
549
+ ```markdown
550
+ ## ROLLBACK SESSION
551
+
552
+ ### Trigger
553
+ - **Issue**: [description]
554
+ - **Severity**: P0/P1/P2
555
+
556
+ ### Rollback
557
+ - **Type**: Code / Schema / Data
558
+ - **From**: [hash/version]
559
+ - **To**: [hash/version]
560
+
561
+ ### Status
562
+ - Rollback applied: YES
563
+ - Verified working: YES/NO
564
+ - Production stable: YES/NO
565
+
566
+ ### Follow-up
567
+ [Required actions]
568
+ ```
569
+
570
+ ---
571
+
572
+ ## EMERGENCY QUICK REFERENCE
573
+
574
+ ### Immediate Code Rollback
575
+ ```bash
576
+ # Find last working commit
577
+ git log --oneline -20
578
+
579
+ # Revert to that commit (SAFE)
580
+ git revert HEAD~N..HEAD --no-edit
581
+ git push origin main
582
+ ```
583
+
584
+ ### Immediate DB Rollback (DANGER)
585
+ ```sql
586
+ -- Only if backup exists!
587
+ -- Restore from backup table
588
+ INSERT INTO [table] SELECT * FROM [table]_backup_[date]
589
+ ON CONFLICT (id) DO UPDATE SET ...;
590
+ ```
591
+
592
+ ### If Everything Is Broken
593
+ 1. Check Vercel for last successful deployment
594
+ 2. Find corresponding git commit
595
+ 3. Revert to that commit
596
+ 4. Push and monitor deployment
597
+ 5. Fix database separately if needed
598
+
599
+ ---
600
+
601
+ ## START NOW
602
+
603
+ 1. Phase 1: Assess - What needs rollback, what's the impact
604
+ 2. Phase 2: Preserve - Document and backup current state
605
+ 3. Phase 3: Code Rollback - If code changes involved
606
+ 4. Phase 4: Dependencies - If package changes involved
607
+ 5. Phase 5: Database - If schema/data changes involved (CAREFUL)
608
+ 6. Phase 6: Verify - All checks must pass
609
+ 7. Phase 7: Deploy - Push to production
610
+ 8. Document - Produce rollback report
611
+ 9. Follow-up - Schedule root cause analysis
612
+
613
+ **Remember: Measure twice, rollback once. Data loss is forever.**
@@ -6,8 +6,6 @@ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
6
6
 
7
7
  # Scaffold New Hook
8
8
 
9
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
10
-
11
9
  Creates a complete Claude Code hook following the 3-tier profile system.
12
10
 
13
11
  ## What Gets Created
@@ -60,7 +58,7 @@ exit 0
60
58
  "hooks": [
61
59
  {
62
60
  "type": "command",
63
- "command": "PROFILE=${LIMN_HOOK_PROFILE:-strict}; [ \"$PROFILE\" = \"minimal\" ] && exit 0; bash \"$CLAUDE_PROJECT_DIR/scripts/hooks/hook-name.sh\""
61
+ "command": "PROFILE=${MASSU_HOOK_PROFILE:-strict}; [ \"$PROFILE\" = \"minimal\" ] && exit 0; bash \"$CLAUDE_PROJECT_DIR/scripts/hooks/hook-name.sh\""
64
62
  }
65
63
  ]
66
64
  }
@@ -79,7 +77,7 @@ exit 0
79
77
  - **stdin piping**: Hook receives tool input via stdin — `TOOL_INPUT=$(cat)` must be first
80
78
  - **Exit codes**: Exit 0 = success/allow, non-zero = hook failure (not tool blocking)
81
79
  - **hook-gate.sh sourcing**: MUST use `2>/dev/null || true` suffix (hook-gate may not exist in CI)
82
- - **Inline PROFILE check**: settings.json entry needs `PROFILE=${LIMN_HOOK_PROFILE:-strict}` prefix for minimal profile bypass
80
+ - **Inline PROFILE check**: settings.json entry needs `PROFILE=${MASSU_HOOK_PROFILE:-strict}` prefix for minimal profile bypass
83
81
  - **jq dependency**: Use `jq` for JSON parsing (installed on dev machine), never grep for JSON fields
84
82
  - **Performance**: Hooks run on every tool invocation — keep under 10ms for standard tier
85
83
 
@@ -6,8 +6,6 @@ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
6
6
 
7
7
  # Scaffold New Page
8
8
 
9
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
10
-
11
9
  Creates a complete Next.js App Router page following all project patterns.
12
10
 
13
11
  ## What Gets Created
@@ -93,7 +91,8 @@ export default function Error({ error, reset }: { error: Error; reset: () => voi
93
91
  - **ALWAYS use `page-container`** class on root div — never `container mx-auto`
94
92
  - **Suspense boundaries** are REQUIRED for pages using `use(params)` or `useSearchParams()`
95
93
  - **protectedProcedure** for ALL tRPC queries that need auth
96
- - **Breadcrumbs**: Add to PageHeader if page is nested (e.g., `/dashboard/settings/[id]`)
94
+ - **No `sm:page-container`** only exception is mobile chat layouts
95
+ - **Breadcrumbs**: Add to PageHeader if page is nested (e.g., `/crm/contacts/[id]`)
97
96
 
98
97
  ## Process
99
98
 
@@ -6,8 +6,6 @@ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
6
6
 
7
7
  # Scaffold New tRPC Router
8
8
 
9
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
10
-
11
9
  Creates a complete tRPC router following all project database and auth patterns.
12
10
 
13
11
  ## What Gets Created
@@ -109,6 +107,7 @@ export const appRouter = createTRPCRouter({
109
107
  - **No `include:`** — hybrid DB ignores include statements; use 3-step query
110
108
  - **user_profiles NOT users** — `ctx.db.user_profiles` (auth.users not exposed)
111
109
  - **BigInt**: convert to `Number()` on return, NEVER use `BigInt()` in INSERT
110
+ - **Decimal**: use `serializeUnifiedProduct()` for unified_products (8 Decimal cols)
112
111
  - **New tables**: add to `src/lib/db.ts` DatabaseClient BEFORE using in routers
113
112
  - **Split-commit**: NEVER add import to root.ts before router file exists
114
113