@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,423 @@
1
+ ---
2
+ name: massu-new-pattern
3
+ description: "When user discovers a new pattern, says 'add this pattern', 'new pattern', or needs to formalize a recurring solution into the patterns library with approval"
4
+ allowed-tools: Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
+ disable-model-invocation: true
6
+ ---
7
+ name: massu-new-pattern
8
+
9
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-14, CR-5, CR-12 enforced.
10
+
11
+ # Massu New Pattern: Pattern Creation Protocol
12
+
13
+ ## Objective
14
+
15
+ Create new patterns when existing patterns don't cover a required functionality, with proper approval workflow and documentation to ensure patterns are:
16
+ 1. Well thought out with clear rationale
17
+ 2. Explicitly approved by the user
18
+ 3. Saved to CLAUDE.md/pattern files BEFORE implementation
19
+ 4. Include WRONG vs CORRECT examples
20
+
21
+ ---
22
+
23
+ ## NON-NEGOTIABLE RULES
24
+
25
+ - **Never implement without pattern** - Custom approaches must be documented first
26
+ - **User approval required** - No pattern is saved without explicit user approval
27
+ - **WRONG/CORRECT required** - Every pattern must show what NOT to do and what TO do
28
+ - **Error consequence required** - Every pattern must explain what breaks if violated
29
+ - **Save BEFORE implement** - Pattern must be in CLAUDE.md before any code uses it
30
+
31
+ ---
32
+
33
+ ## ZERO-GAP AUDIT LOOP
34
+
35
+ **Pattern creation does NOT complete until a SINGLE COMPLETE VALIDATION finds ZERO gaps.**
36
+
37
+ ```
38
+ Loop:
39
+ 1. Draft pattern with WRONG/CORRECT examples
40
+ 2. Present to user for review
41
+ 3. If user has feedback: incorporate ALL feedback
42
+ 4. Present updated pattern again
43
+ 5. Only when user explicitly approves: save to CLAUDE.md/patterns/*.md
44
+ 6. Verify pattern is saved (grep proof)
45
+ 7. If ANY step is incomplete: do NOT mark complete
46
+ ```
47
+
48
+ **A pattern not saved to CLAUDE.md does not exist. File existence is the only proof.**
49
+
50
+ ---
51
+
52
+ ## WHEN TO USE THIS COMMAND
53
+
54
+ Use `/massu-new-pattern` when:
55
+ 1. You need functionality with NO existing pattern in CLAUDE.md or patterns/*.md
56
+ 2. Existing patterns don't fit the specific use case
57
+ 3. You've verified no suitable pattern exists
58
+
59
+ ---
60
+
61
+ ## PHASE 1: VERIFY NO EXISTING PATTERN
62
+
63
+ ### 1.1 Search All Pattern Sources
64
+
65
+ ```bash
66
+ # Search CLAUDE.md
67
+ grep -n "[functionality]" .claude/CLAUDE.md
68
+
69
+ # Search pattern files
70
+ grep -rn "[functionality]" .claude/patterns/
71
+
72
+ # Search quick reference
73
+ grep -n "[functionality]" .claude/reference/patterns-quickref.md
74
+ ```
75
+
76
+ ### 1.2 Document Search Results
77
+
78
+ ```markdown
79
+ ### PATTERN SEARCH: [Functionality Name]
80
+
81
+ **Searched:**
82
+ - [ ] CLAUDE.md
83
+ - [ ] patterns/database-patterns.md
84
+ - [ ] patterns/ui-patterns.md
85
+ - [ ] patterns/auth-patterns.md
86
+ - [ ] patterns/build-patterns.md
87
+ - [ ] reference/patterns-quickref.md
88
+
89
+ **Results:**
90
+ | Source | Related Pattern | Why Not Suitable |
91
+ |--------|-----------------|------------------|
92
+ | [file] | [pattern] | [reason] |
93
+ | None found | - | New pattern required |
94
+
95
+ **Conclusion:** New pattern required because [reason]
96
+ ```
97
+
98
+ ---
99
+
100
+ ## PHASE 2: DEFINE THE NEW PATTERN
101
+
102
+ ### 2.1 Pattern Definition Template
103
+
104
+ ```markdown
105
+ ## NEW PATTERN PROPOSAL
106
+
107
+ ### Basic Information
108
+
109
+ | Field | Value |
110
+ |-------|-------|
111
+ | **Pattern Name** | [Short, descriptive name] |
112
+ | **Pattern ID** | [DOMAIN]-[NUMBER] (e.g., UI-015, DB-008) |
113
+ | **Domain** | [Database/UI/Auth/Build] |
114
+ | **Purpose** | [What problem it solves] |
115
+ | **When to Use** | [Specific scenarios] |
116
+ | **Error if Violated** | [What breaks] |
117
+
118
+ ### The Pattern
119
+
120
+ **WRONG (Never Do This):**
121
+ ```[language]
122
+ // This is wrong because [reason]
123
+ [incorrect code example]
124
+ ```
125
+
126
+ **CORRECT (Always Do This):**
127
+ ```[language]
128
+ // This is correct because [reason]
129
+ [correct code example]
130
+ ```
131
+
132
+ ### Rationale
133
+
134
+ **Why this approach:**
135
+ 1. [Reason 1]
136
+ 2. [Reason 2]
137
+ 3. [Reason 3]
138
+
139
+ **What it prevents:**
140
+ 1. [Problem 1]
141
+ 2. [Problem 2]
142
+
143
+ ### Verification
144
+
145
+ How to check compliance:
146
+ ```bash
147
+ # Command to find violations
148
+ grep -rn "[violation pattern]" src/
149
+
150
+ # Command to verify correct usage
151
+ grep -rn "[correct pattern]" src/
152
+ ```
153
+ ```
154
+
155
+ ### 2.2 Examples for Different Domains
156
+
157
+ #### Database Pattern Example:
158
+ ```markdown
159
+ ### Pattern Name: Null-Safe Array Aggregation
160
+ ### Pattern ID: DB-012
161
+ ### Domain: Database
162
+ ### Purpose: Safely handle array aggregation when relations may be empty
163
+
164
+ **WRONG:**
165
+ ```typescript
166
+ // Returns [null] when no items exist
167
+ const items = await db.items.findMany({
168
+ where: { parent_id: parentId }
169
+ });
170
+ return items.map(i => i.name); // Could be [null]
171
+ ```
172
+
173
+ **CORRECT:**
174
+ ```typescript
175
+ // Returns [] when no items exist
176
+ const items = await db.items.findMany({
177
+ where: { parent_id: parentId }
178
+ });
179
+ return (items ?? []).map(i => i.name); // Always an array
180
+ ```
181
+ ```
182
+
183
+ #### UI Pattern Example:
184
+ ```markdown
185
+ ### Pattern Name: Confirmation Dialog for Destructive Actions
186
+ ### Pattern ID: UI-016
187
+ ### Domain: UI
188
+ ### Purpose: Require explicit confirmation before irreversible actions
189
+
190
+ **WRONG:**
191
+ ```tsx
192
+ // Direct delete without confirmation
193
+ <Button onClick={() => deleteMutation.mutate({ id })}>
194
+ Delete
195
+ </Button>
196
+ ```
197
+
198
+ **CORRECT:**
199
+ ```tsx
200
+ // With confirmation dialog
201
+ <AlertDialog>
202
+ <AlertDialogTrigger asChild>
203
+ <Button variant="destructive">Delete</Button>
204
+ </AlertDialogTrigger>
205
+ <AlertDialogContent>
206
+ <AlertDialogHeader>
207
+ <AlertDialogTitle>Are you sure?</AlertDialogTitle>
208
+ <AlertDialogDescription>
209
+ This action cannot be undone.
210
+ </AlertDialogDescription>
211
+ </AlertDialogHeader>
212
+ <AlertDialogFooter>
213
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
214
+ <AlertDialogAction onClick={() => deleteMutation.mutate({ id })}>
215
+ Delete
216
+ </AlertDialogAction>
217
+ </AlertDialogFooter>
218
+ </AlertDialogContent>
219
+ </AlertDialog>
220
+ ```
221
+ ```
222
+
223
+ ---
224
+
225
+ ## PHASE 3: USER APPROVAL
226
+
227
+ ### 3.1 Present Pattern for Review
228
+
229
+ Display the full pattern definition to the user and explicitly ask:
230
+
231
+ ```markdown
232
+ ## NEW PATTERN APPROVAL REQUEST
233
+
234
+ I've defined a new pattern that doesn't exist in our documentation:
235
+
236
+ [Full pattern definition from Phase 2]
237
+
238
+ **Questions:**
239
+ 1. Does this pattern make sense for our codebase?
240
+ 2. Are the WRONG/CORRECT examples clear?
241
+ 3. Should this be a CRITICAL rule (blocks deployment) or RECOMMENDED?
242
+ 4. Any modifications needed?
243
+
244
+ **Please approve or request changes before I save this pattern.**
245
+ ```
246
+
247
+ ### 3.2 Handle Feedback
248
+
249
+ - If approved: Proceed to Phase 4
250
+ - If modifications requested: Update pattern definition, re-present
251
+ - If rejected: Document rejection reason, find alternative approach
252
+
253
+ ---
254
+
255
+ ## PHASE 4: SAVE PATTERN
256
+
257
+ ### 4.1 Determine Save Location
258
+
259
+ | Pattern Type | Primary Location | Also Add To |
260
+ |--------------|------------------|-------------|
261
+ | Database | `patterns/database-patterns.md` | `CLAUDE.md` if CRITICAL |
262
+ | UI | `patterns/ui-patterns.md` | `CLAUDE.md` if CRITICAL |
263
+ | Auth | `patterns/auth-patterns.md` | `CLAUDE.md` if CRITICAL |
264
+ | Build | `patterns/build-patterns.md` | `CLAUDE.md` if CRITICAL |
265
+ | Any | `reference/patterns-quickref.md` | Quick reference |
266
+
267
+ ### 4.2 Save to Pattern File
268
+
269
+ Add to the appropriate section in the pattern file:
270
+
271
+ ```markdown
272
+ ## [Pattern Name]
273
+
274
+ | Rule | Pattern | Error if Violated |
275
+ |------|---------|-------------------|
276
+ | [Short rule] | `[correct code]` | [What breaks] |
277
+
278
+ **WRONG:**
279
+ ```[language]
280
+ [incorrect code]
281
+ ```
282
+
283
+ **CORRECT:**
284
+ ```[language]
285
+ [correct code]
286
+ ```
287
+ ```
288
+
289
+ ### 4.3 Add to Quick Reference
290
+
291
+ Add to `reference/patterns-quickref.md`:
292
+
293
+ ```markdown
294
+ | [Pattern Name] | `[correct pattern]` | [error] |
295
+ ```
296
+
297
+ ### 4.4 Add to CLAUDE.md if CRITICAL
298
+
299
+ If pattern is CRITICAL (violation blocks deployment), add to CLAUDE.md:
300
+
301
+ ```markdown
302
+ ### [Domain] Rules
303
+
304
+ | Rule | Pattern | Error if Violated |
305
+ |------|---------|-------------------|
306
+ | [Pattern Name] | `[correct code]` | [What breaks] |
307
+ ```
308
+
309
+ ---
310
+
311
+ ## PHASE 5: VERIFICATION
312
+
313
+ ### 5.1 Verify Pattern Saved
314
+
315
+ ```bash
316
+ # Verify in pattern file
317
+ grep -n "[Pattern Name]" .claude/patterns/[domain]-patterns.md
318
+
319
+ # Verify in quick reference
320
+ grep -n "[Pattern Name]" .claude/reference/patterns-quickref.md
321
+
322
+ # Verify in CLAUDE.md (if CRITICAL)
323
+ grep -n "[Pattern Name]" .claude/CLAUDE.md
324
+ ```
325
+
326
+ ### 5.2 Document Pattern Addition
327
+
328
+ ```markdown
329
+ ### NEW PATTERN SAVED
330
+
331
+ | Field | Value |
332
+ |-------|-------|
333
+ | Pattern Name | [name] |
334
+ | Pattern ID | [ID] |
335
+ | Approved By | User (this session) |
336
+ | Saved To | [list of files] |
337
+ | Date | [timestamp] |
338
+
339
+ **Pattern is now available for use in implementations.**
340
+ ```
341
+
342
+ ---
343
+
344
+ ## PHASE 6: UPDATE SESSION STATE
345
+
346
+ After saving pattern, update `session-state/CURRENT.md`:
347
+
348
+ ```markdown
349
+ ## NEW PATTERN CREATED
350
+
351
+ ### Pattern
352
+ - **Name**: [pattern name]
353
+ - **ID**: [pattern ID]
354
+ - **Domain**: [domain]
355
+
356
+ ### Saved To
357
+ - [x] patterns/[domain]-patterns.md
358
+ - [x] reference/patterns-quickref.md
359
+ - [ ] CLAUDE.md (if CRITICAL)
360
+
361
+ ### Reason
362
+ [Why this pattern was needed]
363
+
364
+ ### User Approval
365
+ - Approved: [timestamp]
366
+ - Modifications: [any changes requested]
367
+ ```
368
+
369
+ ---
370
+
371
+ ## NEW PATTERN REPORT FORMAT
372
+
373
+ ```markdown
374
+ ## MASSU NEW PATTERN REPORT
375
+
376
+ ### Summary
377
+ - **Date**: [timestamp]
378
+ - **Pattern Name**: [name]
379
+ - **Pattern ID**: [ID]
380
+ - **Domain**: [domain]
381
+
382
+ ### Justification
383
+ - **Need**: [why pattern was needed]
384
+ - **Existing Patterns Checked**: [list]
385
+ - **Why Not Suitable**: [reasons]
386
+
387
+ ### Pattern Definition
388
+ [Full pattern definition]
389
+
390
+ ### Approval
391
+ - **User Approved**: YES
392
+ - **Modifications**: [any]
393
+ - **Approval Time**: [timestamp]
394
+
395
+ ### Saved Locations
396
+ - [x] [location 1]
397
+ - [x] [location 2]
398
+
399
+ ### Verification
400
+ ```bash
401
+ # Pattern exists in documentation
402
+ [verification commands and output]
403
+ ```
404
+
405
+ **NEW PATTERN COMPLETE - READY FOR USE**
406
+ ```
407
+
408
+ ---
409
+
410
+ ## START NOW
411
+
412
+ 1. Verify no existing pattern covers the need
413
+ 2. Document why existing patterns don't work
414
+ 3. Define the new pattern with WRONG/CORRECT examples
415
+ 4. Present to user for explicit approval
416
+ 5. Save to appropriate pattern files
417
+ 6. Add to quick reference
418
+ 7. Add to CLAUDE.md if CRITICAL
419
+ 8. Verify pattern is saved
420
+ 9. Update session state
421
+ 10. Produce new pattern report
422
+
423
+ **Remember: Document first, implement second. No undocumented patterns.**