@massu/core 0.5.0 → 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 (118) 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 +146 -95
  97. package/package.json +6 -2
  98. package/patterns/build-patterns.md +302 -0
  99. package/patterns/component-patterns.md +246 -0
  100. package/patterns/display-patterns.md +185 -0
  101. package/patterns/form-patterns.md +890 -0
  102. package/patterns/integration-testing-checklist.md +445 -0
  103. package/patterns/security-patterns.md +219 -0
  104. package/patterns/testing-patterns.md +569 -0
  105. package/patterns/tool-routing.md +81 -0
  106. package/patterns/ui-patterns.md +371 -0
  107. package/protocols/plan-implementation.md +267 -0
  108. package/protocols/recovery.md +225 -0
  109. package/protocols/verification.md +404 -0
  110. package/reference/command-taxonomy.md +178 -0
  111. package/reference/cr-rules-reference.md +76 -0
  112. package/reference/hook-execution-order.md +148 -0
  113. package/reference/lessons-learned.md +175 -0
  114. package/reference/patterns-quickref.md +208 -0
  115. package/reference/standards.md +135 -0
  116. package/reference/subagents-reference.md +17 -0
  117. package/reference/vr-verification-reference.md +867 -0
  118. package/src/commands/install-commands.ts +149 -53
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: massu-simplify
3
- description: Enhanced code simplification with parallel efficiency, reuse, and pattern compliance analysis
3
+ description: "When user says 'simplify', 'review my code', 'clean this up', or has finished implementation and wants quality review before commit"
4
4
  allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
5
  ---
6
6
  name: massu-simplify
7
7
 
8
8
  # Massu Simplify: Enhanced Code Quality Analysis
9
9
 
10
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9 enforced.
10
+ **Shared rules**: Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9 enforced.
11
11
 
12
12
  ---
13
13
 
@@ -30,14 +30,14 @@ Code changes → /massu-simplify → /massu-commit → /massu-push
30
30
 
31
31
  | Category | Example | Caught By Existing Tools? |
32
32
  |----------|---------|--------------------------|
33
- | Unnecessary async | `async` on functions with no `await` | NO |
34
- | Redundant type assertions | `as T` when type is already inferred | NO |
35
- | Code duplication | Inline `parseTier()` when `packages/core/src/` exports it | Partially (pattern-scanner) |
36
- | Inefficient collections | `Array.find()` in a loop instead of building a Map | NO |
37
- | Config hardcoding | Literal values instead of `getConfig()` | NO |
38
- | Missing type exports | Types defined but not exported from barrel | NO |
39
- | Unnecessary Map/Set | Using Map/Set where a plain object suffices | NO |
40
- | Dead parameters | Function parameters that are never read | NO |
33
+ | Inefficient queries | `findMany().length` instead of SQL COUNT | NO |
34
+ | Unnecessary state | `useState` for derived values | NO |
35
+ | Code duplication | Inline `formatFileSize()` when `@/lib/formatting/fields` exists | Partially (pattern-scanner) |
36
+ | Over-fetching | `findMany()` without `select:` or `take:` | Partially (IN clause only) |
37
+ | Re-render waste | Missing `useMemo`/`useCallback` for expensive operations | NO |
38
+ | Existing utility ignorance | Rewriting a utility that already exists in shared code | NO |
39
+ | Memory leaks | Missing cleanup in `useEffect` | NO |
40
+ | Derived state anti-pattern | `useEffect` `setState` for values derivable from props/queries | NO |
41
41
 
42
42
  ---
43
43
 
@@ -63,7 +63,7 @@ Filter to only `.ts`, `.tsx`, `.js`, `.jsx` files. Exclude `node_modules/`, `.ne
63
63
  ### Step 2: Fast Gate — Pattern Scanner
64
64
 
65
65
  ```bash
66
- bash scripts/massu-pattern-scanner.sh
66
+ ./scripts/pattern-scanner.sh
67
67
  ```
68
68
 
69
69
  If violations found: **Fix them ALL before proceeding.** Pattern scanner violations are syntactic anti-patterns that should be resolved before semantic analysis begins.
@@ -76,39 +76,30 @@ Spawn 3 review agents **IN PARALLEL**. Each gets the list of changed files and a
76
76
  CHANGED_FILES = [list from Step 1]
77
77
 
78
78
  efficiency_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
79
- You are an EFFICIENCY REVIEWER for the Massu codebase (npm package).
79
+ You are an EFFICIENCY REVIEWER for the Massu codebase.
80
80
 
81
81
  Review ONLY these changed files: {CHANGED_FILES}
82
82
 
83
83
  Check for these specific inefficiency patterns:
84
84
 
85
- 1. UNNECESSARY ASYNC/AWAIT
86
- - async functions with no await (should be synchronous)
87
- - await on non-Promise values
88
- - Unnecessary Promise.resolve() wrapping synchronous values
89
- - Sequential awaits that could be Promise.all()
85
+ 1. QUERY INEFFICIENCY
86
+ - findMany().length or .filter().length instead of SQL COUNT/aggregate
87
+ - Loading full records when only IDs or counts are needed
88
+ - Missing take: limit on findMany (unbounded queries)
89
+ - N+1 patterns: querying in a loop instead of batch IN clause
90
+ - SELECT * (no select: clause) when only a few columns are needed
90
91
 
91
- 2. REDUNDANT TYPE ASSERTIONS
92
- - `as T` when TypeScript already infers the correct type
93
- - Double assertions (`as unknown as T`) that indicate a design problem
94
- - Non-null assertions (`!`) on values that are already narrowed
95
- - Type assertions that could be replaced with type guards
92
+ 2. REACT INEFFICIENCY
93
+ - useState for values derivable from props or query data
94
+ - useEffect setState for derived state (should compute inline or useMemo)
95
+ - Missing useMemo for expensive computations in render
96
+ - Missing useCallback for functions passed as props to children
97
+ - Unnecessary re-renders from object/array literals in JSX props
96
98
 
97
99
  3. ALGORITHMIC INEFFICIENCY
98
- - O(n^2) patterns (nested loops, repeated .find() in .map())
100
+ - O(n²) patterns (nested loops, repeated .find() in .map())
99
101
  - Repeated string concatenation in loops (use array + join)
100
102
  - Sorting or filtering the same array multiple times
101
- - Using Array.find() in a loop instead of building a Map/Set lookup
102
-
103
- 4. INEFFICIENT MAP/SET USAGE
104
- - Map<string, T> where a plain Record<string, T> suffices
105
- - Creating a Map/Set for single-use lookups
106
- - Not using Map when doing repeated key lookups on arrays
107
-
108
- 5. GENERAL INEFFICIENCY
109
- - Loading full objects when only a subset of fields is needed
110
- - Repeated computation that could be cached in a local variable
111
- - Unnecessary spread/destructure creating shallow copies for no reason
112
103
 
113
104
  For each finding, return:
114
105
  FILE: [path]
@@ -123,28 +114,28 @@ efficiency_result = Agent(subagent_type="general-purpose", model="haiku", prompt
123
114
  ")
124
115
 
125
116
  reuse_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
126
- You are a REUSE REVIEWER for the Massu codebase (npm package).
117
+ You are a REUSE REVIEWER for the Massu codebase.
127
118
 
128
119
  Review ONLY these changed files: {CHANGED_FILES}
129
120
 
130
121
  Search the codebase for existing utilities that the changed code should use instead of inline implementations. Check for:
131
122
 
132
123
  1. KNOWN UTILITIES (check if changed code duplicates these)
133
- - getConfig() for config-driven values (never hardcode)
134
- - parseTier() for tier string parsing
135
- - formatDuration() for time/duration formatting
136
- - validateSchema() for schema validation
124
+ - Search the project for existing utility functions (formatters, validators, sanitizers)
125
+ - Check shared/common directories for reusable helpers
126
+ - Look for canonical imports in existing code (e.g., `import { x } from '@/lib/...'`)
127
+ - Identify any inline implementations that duplicate existing utilities
128
+ - Check for deprecated aliases that should use the canonical import
137
129
 
138
130
  2. COMPONENT DUPLICATION
139
- - Search packages/core/src/ for existing modules
140
- that do the same thing as newly created modules
141
- - Check if a new utility duplicates an existing pattern
131
+ - Search src/components/shared/ and src/components/ui/ for existing components
132
+ that do the same thing as newly created components
133
+ - Check if a new modal/dialog/drawer duplicates an existing pattern
142
134
 
143
135
  3. PATTERN DUPLICATION
144
- - Same data transformation pattern written in multiple new files
145
- - Same validation logic duplicated
136
+ - Same data fetching pattern written in multiple new files
137
+ - Same form validation logic duplicated
146
138
  - Same error handling pattern repeated
147
- - Same config access pattern inlined instead of using getConfig()
148
139
 
149
140
  For each finding, return:
150
141
  FILE: [path]
@@ -159,45 +150,41 @@ reuse_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
159
150
  ")
160
151
 
161
152
  pattern_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
162
- You are a PATTERN COMPLIANCE REVIEWER for the Massu codebase (npm package).
153
+ You are a PATTERN COMPLIANCE REVIEWER for the Massu codebase.
163
154
 
164
155
  Review ONLY these changed files: {CHANGED_FILES}
165
156
 
166
- Check for SEMANTIC pattern violations that the pattern-scanner (grep-based) cannot catch:
167
-
168
- 1. ESM IMPORT COMPLIANCE
169
- - Using require() instead of ESM import (except in config files)
170
- - Missing file extensions in relative imports where required
171
- - Default exports where named exports should be used
172
- - Circular import chains between modules
173
-
174
- 2. CONFIG-DRIVEN PATTERN VIOLATIONS
175
- - Hardcoded values that should come from getConfig()
176
- - Magic numbers/strings without named constants
177
- - Environment-specific logic not gated by config
178
- - Missing fallback defaults for config lookups
179
-
180
- 3. TYPESCRIPT STRICT MODE VIOLATIONS
181
- - Implicit any types (missing type annotations on public APIs)
182
- - Using any when a proper type exists
183
- - Missing return type annotations on exported functions
184
- - Non-exhaustive switch/case on union types (missing default or case)
185
-
186
- 4. TYPE EXPORT PATTERN VIOLATIONS
187
- - Types defined in a module but not exported from barrel index
188
- - Re-exporting types without using `export type` (isolatedModules)
189
- - Internal types leaked through public API surface
190
- - Missing JSDoc on exported types/interfaces
191
-
192
- 5. SECURITY PATTERN VIOLATIONS
193
- - Unsanitized user input passed to dangerous operations
194
- - Missing input validation on public-facing functions
195
- - Secrets or credentials hardcoded in source
196
-
197
- 6. ARCHITECTURAL VIOLATIONS
198
- - Cross-package imports bypassing barrel exports
199
- - Tight coupling between modules that should be independent
200
- - Side effects in module-level scope (top-level await, global mutations)
157
+ Check for SEMANTIC pattern violations that the pattern-scanner.sh (grep-based) cannot catch:
158
+
159
+ 1. REACT QUERY v5 VIOLATIONS
160
+ - Using onSuccess/onError/onSettled in useQuery options (removed in v5)
161
+ - Not destructuring data from useQuery result
162
+ - Using queryData?.find() in save handlers instead of checking record.id
163
+
164
+ 2. DATABASE PATTERN VIOLATIONS
165
+ - Using raw SQL or ORM calls instead of project-standard query helpers
166
+ - Accessing tables through wrong aliases or deprecated accessors
167
+ - Missing type coercion wrappers on return values (e.g., BigInt → Number())
168
+ - Using eager-loading patterns the ORM ignores (check project conventions)
169
+ - Missing null-coercion helpers for UPDATE forms with clearable fields
170
+
171
+ 3. UI PATTERN VIOLATIONS
172
+ - Select.Item with value='' (must use '__none__' or semantic value)
173
+ - Missing loading/error/empty states in data-fetching components
174
+ - Missing Suspense boundary for pages using use(params) or useSearchParams
175
+ - Using onClick instead of onPointerDown for stylus-compatible interactions
176
+ - Null-unsafe .replace()/.toLowerCase()/.charAt() on nullable strings
177
+
178
+ 4. SECURITY PATTERN VIOLATIONS
179
+ - orderBy accepting z.string() instead of z.enum() with known columns
180
+ - Using process.env.API_KEY before getCredentials() (CR-5 precedence)
181
+ - publicProcedure on mutations (must be protectedProcedure)
182
+ - Missing CRON_SECRET guard (if (!cronSecret) check before comparison)
183
+
184
+ 5. ARCHITECTURAL VIOLATIONS
185
+ - Scoped queries without going through link table first
186
+ - Full table loads for aggregate calculations (use SQL aggregates)
187
+ - Client components importing server-only modules (@/lib/db)
201
188
 
202
189
  For each finding, return:
203
190
  FILE: [path]
@@ -212,6 +199,40 @@ pattern_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
212
199
  ")
213
200
  ```
214
201
 
202
+ ### Step 3.5: Cross-Review Exchange (Debate Round)
203
+
204
+ **Skip condition**: If ALL three agents returned 0 findings, skip to Step 4.
205
+
206
+ If total findings > 0, spawn a single cross-reviewer agent:
207
+
208
+ ```
209
+ Agent(subagent_type="general-purpose", model="haiku", prompt="
210
+ You are a cross-reviewer for a code quality analysis. Three independent reviewers have analyzed the same codebase changes. Your job is to find interactions between their findings that no single reviewer could catch alone.
211
+
212
+ ## Reviewer Findings
213
+ EFFICIENCY: {efficiency_result}
214
+ REUSE: {reuse_result}
215
+ PATTERN: {pattern_result}
216
+
217
+ ## Your Analysis (3 dimensions)
218
+
219
+ 1. CONFLICTING RECOMMENDATIONS: Do any two reviewers suggest contradictory fixes? (e.g., one says extract a helper, another says inline the code)
220
+ 2. COMPOUNDING ISSUES: Do findings from different reviewers combine to reveal a bigger problem? (e.g., a reuse violation + a pattern violation in the same file = architectural gap)
221
+ 3. MISSED INTERACTIONS: Does fixing one reviewer's finding create a new issue for another? (e.g., extracting a function for reuse changes the pattern compliance)
222
+
223
+ For each finding, report:
224
+ CROSS_FINDING: [type: CONFLICT|COMPOUND|INTERACTION]
225
+ FILES: [affected files]
226
+ REVIEWERS: [which reviewers' findings interact]
227
+ RECOMMENDATION: [what to do]
228
+
229
+ If no cross-cutting issues found: return CROSS_FINDINGS: 0
230
+ Otherwise: return CROSS_FINDINGS: [count]
231
+ ")
232
+ ```
233
+
234
+ Add any CROSS_FINDINGS to the fix queue in Step 4, sorted above individual findings.
235
+
215
236
  ### Step 4: Collect and Apply
216
237
 
217
238
  1. Parse all 3 agent results
@@ -225,7 +246,7 @@ pattern_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
225
246
  ### Step 5: Re-verify
226
247
 
227
248
  ```bash
228
- bash scripts/massu-pattern-scanner.sh
249
+ ./scripts/pattern-scanner.sh
229
250
  ```
230
251
 
231
252
  Confirm no new violations were introduced by the fixes.
@@ -243,6 +264,7 @@ Confirm no new violations were introduced by the fixes.
243
264
  | Efficiency | N | N | 0 |
244
265
  | Reuse | N | N | 0 |
245
266
  | Pattern Compliance | N | N | 0 |
267
+ | Cross-Review | N | N | 0 |
246
268
  | Pattern Scanner | N | N | 0 |
247
269
  | **Total** | **N** | **N** | **0** |
248
270
 
@@ -275,7 +297,15 @@ SIMPLIFY_GATE: FAIL — N issues require manual resolution
275
297
  | `/massu-simplify` | After code changes, before commit | Efficiency + reuse + semantic patterns |
276
298
  | `/massu-verify` | During /massu-loop audit phase | Full VR-* verification with plan coverage |
277
299
  | `/massu-commit` | Before committing | Fast blocking gates (types, build, scanner) |
278
- | `/massu-push` | Before pushing | Full tests + regression |
279
- | `massu-pattern-scanner.sh` | Auto-runs in /massu-commit | Syntactic anti-pattern grep |
300
+ | `/massu-push` | Before pushing | Full tests + regression + schema sync |
301
+ | `pattern-scanner.sh` | Auto-runs in /massu-commit | Syntactic anti-pattern grep |
302
+
303
+ **Key distinction**: `/massu-simplify` catches SEMANTIC issues (inefficient algorithms, missed reuse opportunities, architectural anti-patterns) while `pattern-scanner.sh` catches SYNTACTIC issues (forbidden imports, known bad column names, deprecated APIs).
304
+
305
+ ## Gotchas
280
306
 
281
- **Key distinction**: `/massu-simplify` catches SEMANTIC issues (inefficient algorithms, missed reuse opportunities, architectural anti-patterns) while `massu-pattern-scanner.sh` catches SYNTACTIC issues (forbidden imports, known bad patterns, deprecated APIs).
307
+ - **Run AFTER implementation, not during** simplification reviews completed work. Running mid-implementation creates confusion about what's "done"
308
+ - **Parallel subagents may conflict** — when multiple review agents run simultaneously, they may propose conflicting changes. The main thread resolves conflicts
309
+ - **Don't simplify what you haven't read** — every file being simplified must be read first to understand context. Blind refactoring breaks things
310
+ - **Pattern scanner runs automatically** — PostToolUse hooks will flag violations. Fix them, don't suppress them
311
+ - **Reuse over rewrite** — prefer importing existing utilities over writing new implementations
@@ -7,7 +7,7 @@ name: massu-squirrels
7
7
 
8
8
  # Massu Squirrels: Idea Parking Lot Manager
9
9
 
10
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
10
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-14, CR-5, CR-12 enforced.
11
11
 
12
12
  ---
13
13
 
@@ -61,7 +61,7 @@ Manage `.claude/session-state/squirrels.md` — a parking lot for stray ideas th
61
61
  1. Read squirrels.md, number the ideas (1-based, top to bottom)
62
62
  2. Display idea #N and ask: "Promote this to a plan, a task, or a session-state item?"
63
63
  3. Based on response:
64
- - **Plan**: Create a plan stub in `.claude/plans/`
64
+ - **Plan**: Create a plan stub in the project docs plans directory
65
65
  - **Task**: Add to CURRENT.md as an open item
66
66
  - **Session-state**: Add to CURRENT.md as context
67
67
  4. Remove the idea from squirrels.md
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: massu-tdd
3
- description: Test-driven development cycle RED (failing test) -> GREEN (minimal impl) -> IMPROVE (refactor)
3
+ description: "When user wants test-driven development, says 'TDD', 'write tests first', 'red green refactor', or needs the RED-GREEN-IMPROVE cycle"
4
4
  allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
5
  ---
6
6
  name: massu-tdd
7
7
 
8
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9 enforced.
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
9
9
 
10
10
  # Massu TDD: Test-Driven Development Cycle
11
11
 
@@ -23,7 +23,7 @@ Implement features or fix bugs using strict test-first development. Write the te
23
23
  - **Minimal implementation** - in GREEN phase, write ONLY enough to pass the test
24
24
  - **Refactor ONLY when green** - never refactor with failing tests
25
25
  - **VR-proof at every step** - show test output proving RED/GREEN status
26
- - **Pattern compliance** - IMPROVE phase must apply CLAUDE.md patterns
26
+ - **Pattern compliance** - IMPROVE phase must apply project patterns
27
27
  - **FIX ALL ISSUES ENCOUNTERED (CR-9)** - if tests reveal other bugs, fix them
28
28
 
29
29
  ---
@@ -42,9 +42,12 @@ Implement features or fix bugs using strict test-first development. Write the te
42
42
  ### Step 0: SCOPE
43
43
 
44
44
  User provides feature description or bug report. Identify:
45
- - **Test file location**: `packages/core/src/__tests__/[name].test.ts`
45
+ - **Test file location**: Follow convention:
46
+ - Unit: `tests/unit/[domain]/[name].test.ts`
47
+ - Integration: `tests/integration/[domain]/[name].test.ts`
48
+ - Prevention: `scripts/tests/prevention/[name].test.ts`
46
49
  - **Target source file**: The file that will be implemented/modified
47
- - **Vitest config**: `packages/core/vitest.config.ts`
50
+ - **Vitest config**: `vitest.config.ts` (main) or `vitest.config.prevention.ts` (prevention)
48
51
 
49
52
  ### Step 1: RED (Write Failing Test)
50
53
 
@@ -52,8 +55,8 @@ Write the test file FIRST. The test defines expected behavior.
52
55
 
53
56
  ```bash
54
57
  # Write test with assertions for expected behavior
55
- # Then run it -- it MUST FAIL
56
- cd packages/core && npx vitest run src/__tests__/[test-file] --reporter=verbose
58
+ # Then run it it MUST FAIL
59
+ npx vitest run [test-file] --reporter=verbose
57
60
  ```
58
61
 
59
62
  **Verification**:
@@ -75,8 +78,8 @@ Rules:
75
78
  - Just make the test pass
76
79
 
77
80
  ```bash
78
- # Run the test again -- it MUST PASS
79
- cd packages/core && npx vitest run src/__tests__/[test-file] --reporter=verbose
81
+ # Run the test again it MUST PASS
82
+ npx vitest run [test-file] --reporter=verbose
80
83
  ```
81
84
 
82
85
  **VR-proof**: Show test output with PASS status.
@@ -84,14 +87,14 @@ cd packages/core && npx vitest run src/__tests__/[test-file] --reporter=verbose
84
87
  ### Step 3: IMPROVE (Refactor)
85
88
 
86
89
  Now improve code quality while keeping tests green:
87
- - Apply CLAUDE.md patterns (config-driven, getConfig(), ESM imports, etc.)
90
+ - Apply project patterns (database access, auth, etc.)
88
91
  - Improve naming, readability, structure
89
92
  - Add error handling
90
93
  - Extract reusable functions
91
94
 
92
95
  ```bash
93
- # Run test after refactoring -- MUST STILL PASS
94
- cd packages/core && npx vitest run src/__tests__/[test-file] --reporter=verbose
96
+ # Run test after refactoring MUST STILL PASS
97
+ npx vitest run [test-file] --reporter=verbose
95
98
  ```
96
99
 
97
100
  **VR-proof**: Show test output with PASS status.
@@ -147,6 +150,16 @@ npm test
147
150
 
148
151
  ---
149
152
 
153
+ ## HELPER SCRIPT
154
+
155
+ Use the TDD runner for cleaner output:
156
+
157
+ ```bash
158
+ ./scripts/tdd-runner.sh [test-file]
159
+ ```
160
+
161
+ ---
162
+
150
163
  ## TEST PATTERNS
151
164
 
152
165
  ### Unit Test Template
@@ -165,19 +178,22 @@ describe('[Feature]', () => {
165
178
  });
166
179
  ```
167
180
 
168
- ### MCP Tool Test Template
181
+ ### Integration Test Template (tRPC Router)
169
182
  ```typescript
170
183
  import { describe, it, expect, vi } from 'vitest';
171
184
 
172
- describe('[ToolName]', () => {
173
- it('should return correct result for valid input', () => {
174
- // Arrange: set up mock database, config
175
- // Act: call handleToolCall with tool name and args
176
- // Assert: verify content[0].text contains expected output
177
- });
178
-
179
- it('should handle missing arguments gracefully', () => {
180
- // Test error handling
185
+ vi.mock('@/lib/db', () => ({
186
+ db: {
187
+ tableName: {
188
+ findMany: vi.fn().mockResolvedValue([]),
189
+ create: vi.fn().mockImplementation((data) => ({ id: 'test-id', ...data.data })),
190
+ },
191
+ },
192
+ }));
193
+
194
+ describe('[Router]', () => {
195
+ it('should [expected behavior]', async () => {
196
+ // Test router procedure
181
197
  });
182
198
  });
183
199
  ```
@@ -5,9 +5,9 @@ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
5
  ---
6
6
  name: massu-test
7
7
 
8
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-35 enforced.
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-12 enforced.
9
9
 
10
- # CS Test: Intelligent Test Runner
10
+ # Massu Test: Intelligent Test Runner
11
11
 
12
12
  ## Objective
13
13
 
@@ -476,7 +476,7 @@ Fix ALL instances found, not just the one that was reported.
476
476
  ## COMPLETION REPORT
477
477
 
478
478
  ```markdown
479
- ## CS TEST COMPLETE
479
+ ## MASSU TEST COMPLETE
480
480
 
481
481
  ### Mode: [FULL_RUN / AFFECTED / COVERAGE / GENERATE / FIX]
482
482