@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,208 @@
1
+ # Pattern Quick Reference
2
+
3
+ **Purpose**: Condensed pattern reference. Full patterns with code examples in `patterns/*.md`.
4
+
5
+ **When to Read**: Quick lookup during implementation. For full details, read the linked pattern file.
6
+
7
+ ---
8
+
9
+ ## Database Patterns
10
+
11
+ | Pattern | Rule | Full Details |
12
+ |---------|------|--------------|
13
+ | ctx.db | Use `ctx.db` for ALL ops, NEVER `ctx.prisma` | [database-patterns.md](../patterns/database-patterns.md) |
14
+ | user_profiles | Use `ctx.db.user_profiles`, NEVER `ctx.db.users` (auth.users not exposed) | [database-patterns.md](../patterns/database-patterns.md) |
15
+ | 3-Step Queries | (1) Base query, (2) Relation query with IN, (3) Map combine | [database-patterns.md](../patterns/database-patterns.md) |
16
+ | No include: | Hybrid DB ignores `include:` statements | [database-patterns.md](../patterns/database-patterns.md) |
17
+ | emptyToNull | Use for UPDATE forms with clearable fields | [database-patterns.md](../patterns/database-patterns.md) |
18
+ | BigInt | NEVER use BigInt() in INSERT; convert to Number() on return | [database-patterns.md](../patterns/database-patterns.md) |
19
+ | Decimal | Use serialization helpers for tables with Decimal columns | [database-patterns.md](../patterns/database-patterns.md) |
20
+ | RLS + Grants | Tables need BOTH policies AND grants for service_role | [database-patterns.md](../patterns/database-patterns.md) |
21
+
22
+ ---
23
+
24
+ ## Auth Patterns
25
+
26
+ | Pattern | Rule | Full Details |
27
+ |---------|------|--------------|
28
+ | getCurrentUser | Use tRPC `api.userProfile.getCurrentUser.useQuery()` | [auth-patterns.md](../patterns/auth-patterns.md) |
29
+ | API Route Auth | Use `getUser()` from `@/lib/auth/server` | [auth-patterns.md](../patterns/auth-patterns.md) |
30
+ | protectedProcedure | ALL mutations MUST use `protectedProcedure`, never `publicProcedure` | [auth-patterns.md](../patterns/auth-patterns.md) |
31
+
32
+ ---
33
+
34
+ ## Form Patterns
35
+
36
+ | Pattern | Rule | Full Details |
37
+ |---------|------|--------------|
38
+ | Phone Input | Use `PhoneInputField` NOT `TextField type="phone"` | [form-patterns.md](../patterns/form-patterns.md) |
39
+ | TextField types | Use semantic types: `firstName`, `lastName`, `email`, `company`, `url` | [form-patterns.md](../patterns/form-patterns.md) |
40
+ | setValue/watch | ALL TextField/PhoneInputField need `setValue` and `watch` props | [form-patterns.md](../patterns/form-patterns.md) |
41
+
42
+ ---
43
+
44
+ ## UI Patterns
45
+
46
+ | Pattern | Rule | Full Details |
47
+ |---------|------|--------------|
48
+ | Logo Usage | `resolvedTheme === 'dark' ? Dark_Mode.png : Light_Mode.png` | [ui-patterns.md](../patterns/ui-patterns.md) |
49
+ | Suspense Boundaries | ALL pages with `use(params)` or `useSearchParams()` need Suspense | [ui-patterns.md](../patterns/ui-patterns.md) |
50
+ | Null Guards | `(status \|\| "pending").replace()` for nullable string methods | [ui-patterns.md](../patterns/ui-patterns.md) |
51
+ | Select.Item | NEVER use `value=""` - causes React crash; use `__none__` placeholder | [ui-patterns.md](../patterns/ui-patterns.md) |
52
+ | Mobile Chat | Use `sm:page-container` NOT `page-container` for full-height mobile | [ui-patterns.md](../patterns/ui-patterns.md) |
53
+ | NO Modals | ALL overlays use `Sheet` (slide-out panel), NEVER `Dialog`. Only `AlertDialog` for destructive confirms | [CLAUDE.md](../CLAUDE.md) |
54
+ | No user-scalable=no | Never disable zoom -- breaks WCAG accessibility | Scanner enforced |
55
+ | VR-VISUAL | `bash scripts/ui-review.sh [route]` -- LLM-as-judge visual quality review | [vr-verification-reference.md](vr-verification-reference.md) |
56
+
57
+ ---
58
+
59
+ ## Build Patterns
60
+
61
+ | Pattern | Rule | Full Details |
62
+ |---------|------|--------------|
63
+ | JSDOM | NEVER import jsdom statically; use `await import('jsdom')` | [build-patterns.md](../patterns/build-patterns.md) |
64
+ | Client/Server Boundary | Client components CANNOT import `@/lib/db` or barrel exports with server code | [build-patterns.md](../patterns/build-patterns.md) |
65
+ | next-intl | REQUIRES: (1) plugin in next.config.js, (2) request.ts, (3) NextIntlClientProvider | [build-patterns.md](../patterns/build-patterns.md) |
66
+ | React Query v5 | NEVER use `onSuccess` in useQuery options; destructure and use `data` directly | See below |
67
+
68
+ ---
69
+
70
+ ## Security Patterns
71
+
72
+ | Pattern | Rule | Full Details |
73
+ |---------|------|--------------|
74
+ | SuperJSON Keys | NEVER use `prototype`, `__proto__`, `constructor` as object KEYS | [CLAUDE.md](../CLAUDE.md) |
75
+ | Service Worker | NEVER auto-reload on controllerchange; ALWAYS use `{ once: true }` | [CLAUDE.md](../CLAUDE.md) |
76
+ | Credential-first | `getCredentials()` from provider FIRST, `process.env` fallback for dev ONLY | [patterns/security-patterns.md](../patterns/security-patterns.md) |
77
+
78
+ ### Credential Access Pattern (CR-5)
79
+
80
+ **WRONG (env-first anti-pattern):**
81
+ ```typescript
82
+ const apiKey = process.env.SERVICE_API_KEY;
83
+ if (!apiKey) throw new Error('Missing API key');
84
+ ```
85
+
86
+ **CORRECT (credential-provider-first):**
87
+ ```typescript
88
+ import { getServiceCredentials } from '@/lib/credentials/provider';
89
+
90
+ let apiKey: string | undefined;
91
+ // CR-5: Credential provider first
92
+ try {
93
+ const creds = await getServiceCredentials();
94
+ if (creds.apiKey) apiKey = creds.apiKey;
95
+ } catch {
96
+ log.debug('[Service] Credential provider unavailable, falling back to env var');
97
+ }
98
+ // Dev-only fallback
99
+ if (!apiKey) apiKey = process.env.SERVICE_API_KEY;
100
+ ```
101
+
102
+ **Typed helpers exist** for services in `src/lib/credentials/provider.ts` -- always prefer the typed helper over raw `getCredentials('service')`.
103
+
104
+ ---
105
+
106
+ ## Realtime Patterns
107
+
108
+ | Pattern | Rule | Full Details |
109
+ |---------|------|--------------|
110
+ | Double Bracket QueryKey | `queryKey: [['router', 'procedure']]` NOT single brackets | [realtime-patterns.md](../patterns/realtime-patterns.md) |
111
+
112
+ ---
113
+
114
+ ## Formatting Patterns
115
+
116
+ | Pattern | Rule | Full Details |
117
+ |---------|------|--------------|
118
+ | formatFileSize | Use `formatFileSize` from `@/lib/formatting/fields`, NEVER inline definitions | See below |
119
+ | formatBytes | DEPRECATED - use `formatFileSize` instead | See below |
120
+
121
+ ### formatFileSize Pattern
122
+
123
+ **WRONG (inline definition - causes duplication):**
124
+ ```typescript
125
+ // WRONG - creates duplicate implementations
126
+ function formatFileSize(bytes: number): string {
127
+ if (bytes === 0) return '0 B';
128
+ const k = 1024;
129
+ const sizes = ['B', 'KB', 'MB', 'GB'];
130
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
131
+ return `${parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;
132
+ }
133
+ ```
134
+
135
+ **CORRECT (import from canonical location):**
136
+ ```typescript
137
+ // CORRECT - single source of truth
138
+ import { formatFileSize } from '@/lib/formatting/fields';
139
+
140
+ // Use directly
141
+ <span>{formatFileSize(file.size)}</span>
142
+ ```
143
+
144
+ ---
145
+
146
+ ## React Query v5 Patterns
147
+
148
+ | Pattern | Rule | Full Details |
149
+ |---------|------|--------------|
150
+ | No onSuccess | NEVER use `onSuccess`/`onError`/`onSettled` in useQuery options | See below |
151
+ | Data Access | Destructure `data` from query result and use directly | See below |
152
+
153
+ ### React Query v5 Pattern (tRPC useQuery)
154
+
155
+ **WRONG (React Query v4 style - causes TypeScript error):**
156
+ ```typescript
157
+ // WRONG - onSuccess removed in React Query v5
158
+ const [userId, setUserId] = useState<string | null>(null);
159
+
160
+ api.userProfile.getCurrentUser.useQuery(undefined, {
161
+ onSuccess: (data) => {
162
+ if (data?.id) {
163
+ setUserId(data.id);
164
+ }
165
+ },
166
+ });
167
+ ```
168
+
169
+ **CORRECT (React Query v5 style):**
170
+ ```typescript
171
+ // CORRECT - destructure data directly
172
+ const { data: currentUser } = api.userProfile.getCurrentUser.useQuery();
173
+ const currentUserId = currentUser?.id ?? null;
174
+ ```
175
+
176
+ **For side effects on success, use useEffect:**
177
+ ```typescript
178
+ const { data } = api.someRouter.someQuery.useQuery({ ... });
179
+
180
+ useEffect(() => {
181
+ if (data) {
182
+ // Side effect when data changes
183
+ doSomething(data);
184
+ }
185
+ }, [data]);
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Design System Patterns
191
+
192
+ | Pattern | Rule | Full Details |
193
+ |---------|------|--------------|
194
+ | Token Reference | Read `specs/token-reference.md` before CSS work | [specs/token-reference.md](../specs/token-reference.md) |
195
+ | Component Specs | Read `specs/components/` before creating/modifying UI | [specs/components/](../specs/components/) |
196
+ | Foundation Specs | Read `specs/foundations/` for color/spacing/typography | [specs/foundations/](../specs/foundations/) |
197
+ | Token Audit | Run `scripts/audit-design-tokens.sh` after CSS changes | Token audit script |
198
+ | No Hardcoded Colors | Use CSS variables from `:root`/`.dark`, never hex in rules | VR-TOKEN |
199
+
200
+ ---
201
+
202
+ ## Simplify & Batch Patterns
203
+
204
+ | Pattern | Rule | Full Details |
205
+ |---------|------|--------------|
206
+ | /massu-simplify | Run after changes, before /massu-commit -- parallel efficiency + reuse + pattern review | massu-simplify command |
207
+ | /massu-batch | Code-only migrations via parallel worktree agents -- NEVER for database work | massu-batch command |
208
+ | Built-in /simplify | Available for quick single-agent simplification (less thorough than /massu-simplify) | Built-in Claude Code skill |
@@ -0,0 +1,135 @@
1
+ # Code Quality & Communication Standards
2
+
3
+ **Part of Prime Directive** | [Back to Main](../CLAUDE.md)
4
+
5
+ ---
6
+
7
+ ## Code Quality Standards
8
+
9
+ ### TypeScript
10
+
11
+ - **0 errors** required for production
12
+ - Warnings are acceptable if documented
13
+ - No `any` types without justification
14
+ - No `@ts-ignore` without explanation
15
+ - Type safety is non-negotiable
16
+
17
+ ### Testing
18
+
19
+ - Fix failing tests, don't skip them
20
+ - >90% pass rate minimum
21
+ - Flaky tests must be investigated
22
+ - E2E tests must pass for critical flows
23
+
24
+ ### Code Structure
25
+
26
+ - No commented-out code blocks >10 lines
27
+ - No console.log in production (except error handling)
28
+ - No TODO in critical paths without tracking
29
+ - No hardcoded credentials ever
30
+
31
+ ### Database Schema Awareness
32
+
33
+ **CRITICAL**: Always verify field names exist in schema before using them.
34
+
35
+ ```typescript
36
+ // [X] WRONG: Assuming fields exist
37
+ const name = `${contact.first_name} ${contact.last_name}`;
38
+
39
+ // [x] CORRECT: Check schema first
40
+ // Schema has: { id, name, email, phone, company_id, position }
41
+ const name = contact.name || contact.email;
42
+ ```
43
+
44
+ **Prevention**:
45
+ 1. Check Prisma schema file before accessing fields
46
+ 2. Use TypeScript types from Prisma
47
+ 3. Test with actual data from database
48
+
49
+ ---
50
+
51
+ ## Communication Standards
52
+
53
+ ### Be Honest
54
+
55
+ - Admit mistakes immediately
56
+ - Don't hide problems
57
+ - Don't sugarcoat issues
58
+ - Don't make excuses
59
+
60
+ ### Be Precise
61
+
62
+ - Show exact commands run
63
+ - Show exact output received
64
+ - Show exact errors encountered
65
+ - Provide concrete evidence
66
+
67
+ ### Be Conservative
68
+
69
+ - Under-promise, over-deliver
70
+ - Flag potential issues early
71
+ - Assume worst case scenarios
72
+ - Verify optimistic assumptions
73
+
74
+ ---
75
+
76
+ ## When Making Claims
77
+
78
+ ### [X] NEVER SAY:
79
+ - "This should work"
80
+ - "Probably production ready"
81
+ - "Looks good to me"
82
+ - "I think it's fixed"
83
+ - "The tests pass so it's ready"
84
+
85
+ ### [x] ALWAYS SAY:
86
+ - "I verified X by running Y, here are the results"
87
+ - "The build succeeded in X minutes: [output]"
88
+ - "I found N errors, here's the plan to fix them"
89
+ - "Not production ready: [specific issues]"
90
+ - "Production ready: [proof of verification]"
91
+
92
+ ---
93
+
94
+ ## Verification Checklist
95
+
96
+ Before claiming **ANY** task is complete:
97
+
98
+ - [ ] Does it work? (tested manually or automatically)
99
+ - [ ] Does it build? (no errors)
100
+ - [ ] Does it type-check? (no errors)
101
+ - [ ] Is it secure? (no secrets, no vulnerabilities)
102
+ - [ ] Is it documented? (updated relevant docs)
103
+ - [ ] Can it be verified? (repeatable test)
104
+
105
+ **All checkboxes must be [x] before claiming complete.**
106
+
107
+ ---
108
+
109
+ ## When in Doubt
110
+
111
+ ### Ask Questions
112
+
113
+ - "Should I verify this works before claiming it's fixed?"
114
+ **Answer: YES, ALWAYS**
115
+
116
+ - "Is it okay to skip this check to save time?"
117
+ **Answer: NO, NEVER**
118
+
119
+ - "Can I claim production ready without running the build?"
120
+ **Answer: NO, ABSOLUTELY NOT**
121
+
122
+ - "Should I investigate this timeout?"
123
+ **Answer: YES, IMMEDIATELY**
124
+
125
+ ### Default to Quality
126
+
127
+ - **When choosing between fast and correct**: Choose correct
128
+ - **When choosing between easy and proper**: Choose proper
129
+ - **When choosing between done and verified**: Choose verified
130
+ - **When choosing between working and production-ready**: Choose production-ready
131
+
132
+ ---
133
+
134
+ **Status**: MANDATORY
135
+ **Reference**: [Main CLAUDE.md](../CLAUDE.md)
@@ -0,0 +1,17 @@
1
+ # Subagent Reference
2
+
3
+ **Subagents**: Use the Task tool for spawning agents. **One task per agent** (Principle #20). Use for exploration to keep main context clean.
4
+
5
+ | Agent | Focus | Trigger |
6
+ |-------|-------|---------|
7
+ | security-reviewer | Vulns, auth, validation | massu-loop 1.5 |
8
+ | architecture-reviewer | Patterns, coupling, scale | massu-loop 1.5 |
9
+ | ux-reviewer | UX, a11y, states | massu-loop 1.5 |
10
+ | plan-auditor | Coverage, gaps, VR-* | massu-loop 2, checkpoint |
11
+ | blast-radius-analyzer | Impact of value changes | massu-create-plan |
12
+ | pattern-reviewer | Pattern compliance | massu-commit |
13
+ | schema-sync-verifier | Multi-env schema match | After migrations |
14
+ | migration-writer | SQL generation | massu-migrate |
15
+ | output-scorer | Quality scoring | Ad-hoc |
16
+ | help-sync | Docs vs code parity | massu-docs |
17
+ | competitive-scorer | Compare competing implementations | golden-path --competitive |