@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.
- package/README.md +40 -0
- package/agents/massu-architecture-reviewer.md +104 -0
- package/agents/massu-blast-radius-analyzer.md +84 -0
- package/agents/massu-competitive-scorer.md +126 -0
- package/agents/massu-help-sync.md +73 -0
- package/agents/massu-migration-writer.md +94 -0
- package/agents/massu-output-scorer.md +87 -0
- package/agents/massu-pattern-reviewer.md +84 -0
- package/agents/massu-plan-auditor.md +170 -0
- package/agents/massu-schema-sync-verifier.md +70 -0
- package/agents/massu-security-reviewer.md +98 -0
- package/agents/massu-ux-reviewer.md +106 -0
- package/commands/_shared-preamble.md +53 -23
- package/commands/_shared-references/auto-learning-protocol.md +71 -0
- package/commands/_shared-references/blast-radius-protocol.md +76 -0
- package/commands/_shared-references/security-pre-screen.md +64 -0
- package/commands/_shared-references/test-first-protocol.md +87 -0
- package/commands/_shared-references/verification-table.md +52 -0
- package/commands/massu-article-review.md +343 -0
- package/commands/massu-autoresearch/references/eval-runner.md +84 -0
- package/commands/massu-autoresearch/references/safety-rails.md +125 -0
- package/commands/massu-autoresearch/references/scoring-protocol.md +151 -0
- package/commands/massu-autoresearch.md +258 -0
- package/commands/massu-batch.md +44 -12
- package/commands/massu-bearings.md +42 -8
- package/commands/massu-checkpoint.md +588 -0
- package/commands/massu-ci-fix.md +2 -2
- package/commands/massu-command-health.md +132 -0
- package/commands/massu-command-improve.md +232 -0
- package/commands/massu-commit.md +205 -44
- package/commands/massu-create-plan.md +239 -57
- package/commands/massu-data/references/common-queries.md +79 -0
- package/commands/massu-data/references/table-guide.md +50 -0
- package/commands/massu-data.md +66 -0
- package/commands/massu-dead-code.md +29 -34
- package/commands/massu-debug/references/auto-learning.md +61 -0
- package/commands/massu-debug/references/codegraph-tracing.md +80 -0
- package/commands/massu-debug/references/common-shortcuts.md +98 -0
- package/commands/massu-debug/references/investigation-phases.md +294 -0
- package/commands/massu-debug/references/report-format.md +107 -0
- package/commands/massu-debug.md +105 -386
- package/commands/massu-docs.md +1 -1
- package/commands/massu-full-audit.md +61 -0
- package/commands/massu-gap-enhancement-analyzer.md +276 -16
- package/commands/massu-golden-path/references/approval-points.md +216 -0
- package/commands/massu-golden-path/references/competitive-mode.md +273 -0
- package/commands/massu-golden-path/references/error-handling.md +121 -0
- package/commands/massu-golden-path/references/phase-0-requirements.md +53 -0
- package/commands/massu-golden-path/references/phase-1-plan-creation.md +168 -0
- package/commands/massu-golden-path/references/phase-2-implementation.md +397 -0
- package/commands/massu-golden-path/references/phase-2.5-gap-analyzer.md +156 -0
- package/commands/massu-golden-path/references/phase-3-simplify.md +40 -0
- package/commands/massu-golden-path/references/phase-4-commit.md +94 -0
- package/commands/massu-golden-path/references/phase-5-push.md +116 -0
- package/commands/massu-golden-path/references/phase-5.5-production-verify.md +170 -0
- package/commands/massu-golden-path/references/phase-6-completion.md +113 -0
- package/commands/massu-golden-path/references/qa-evaluator-spec.md +137 -0
- package/commands/massu-golden-path/references/sprint-contract-protocol.md +117 -0
- package/commands/massu-golden-path/references/vr-visual-calibration.md +73 -0
- package/commands/massu-golden-path.md +114 -848
- package/commands/massu-guide.md +72 -69
- package/commands/massu-hooks.md +27 -12
- package/commands/massu-hotfix.md +221 -144
- package/commands/massu-incident.md +49 -20
- package/commands/massu-infra-audit.md +187 -0
- package/commands/massu-learning-audit.md +211 -0
- package/commands/massu-loop/references/auto-learning.md +49 -0
- package/commands/massu-loop/references/checkpoint-audit.md +40 -0
- package/commands/massu-loop/references/guardrails.md +17 -0
- package/commands/massu-loop/references/iteration-structure.md +115 -0
- package/commands/massu-loop/references/loop-controller.md +188 -0
- package/commands/massu-loop/references/plan-extraction.md +78 -0
- package/commands/massu-loop/references/vr-plan-spec.md +140 -0
- package/commands/massu-loop-playwright.md +9 -9
- package/commands/massu-loop.md +115 -670
- package/commands/massu-new-pattern.md +423 -0
- package/commands/massu-perf.md +422 -0
- package/commands/massu-plan-audit.md +1 -1
- package/commands/massu-plan.md +389 -122
- package/commands/massu-production-verify.md +433 -0
- package/commands/massu-push.md +62 -378
- package/commands/massu-recap.md +29 -3
- package/commands/massu-rollback.md +613 -0
- package/commands/massu-scaffold-hook.md +2 -4
- package/commands/massu-scaffold-page.md +2 -3
- package/commands/massu-scaffold-router.md +1 -2
- package/commands/massu-security.md +619 -0
- package/commands/massu-simplify.md +115 -85
- package/commands/massu-squirrels.md +2 -2
- package/commands/massu-tdd.md +38 -22
- package/commands/massu-test.md +3 -3
- package/commands/massu-type-mismatch-audit.md +469 -0
- package/commands/massu-ui-audit.md +587 -0
- package/commands/massu-verify-playwright.md +287 -32
- package/commands/massu-verify.md +150 -46
- package/dist/cli.js +146 -95
- package/package.json +6 -2
- package/patterns/build-patterns.md +302 -0
- package/patterns/component-patterns.md +246 -0
- package/patterns/display-patterns.md +185 -0
- package/patterns/form-patterns.md +890 -0
- package/patterns/integration-testing-checklist.md +445 -0
- package/patterns/security-patterns.md +219 -0
- package/patterns/testing-patterns.md +569 -0
- package/patterns/tool-routing.md +81 -0
- package/patterns/ui-patterns.md +371 -0
- package/protocols/plan-implementation.md +267 -0
- package/protocols/recovery.md +225 -0
- package/protocols/verification.md +404 -0
- package/reference/command-taxonomy.md +178 -0
- package/reference/cr-rules-reference.md +76 -0
- package/reference/hook-execution-order.md +148 -0
- package/reference/lessons-learned.md +175 -0
- package/reference/patterns-quickref.md +208 -0
- package/reference/standards.md +135 -0
- package/reference/subagents-reference.md +17 -0
- package/reference/vr-verification-reference.md +867 -0
- package/src/commands/install-commands.ts +149 -53
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: massu-create-plan
|
|
3
|
-
description:
|
|
3
|
+
description: "When user wants to plan a feature, fix, or change before implementing -- 'create a plan', 'plan this', or describes requirements that need scoping"
|
|
4
4
|
allowed-tools: Bash(*), Read(*), Grep(*), Glob(*)
|
|
5
5
|
---
|
|
6
6
|
name: massu-create-plan
|
|
7
7
|
|
|
8
|
-
> **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-
|
|
8
|
+
> **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-12 enforced.
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# Massu Create Plan: Reality-Based Plan Generation
|
|
11
11
|
|
|
12
12
|
## CRITICAL: THIS IS A PLAN-CREATION COMMAND, NOT AN IMPLEMENTATION COMMAND
|
|
13
13
|
|
|
@@ -46,6 +46,7 @@ name: massu-create-plan
|
|
|
46
46
|
| `/massu-create-plan` | Create plan document | **NO - FORBIDDEN** |
|
|
47
47
|
| `/massu-plan` | Audit existing plan | **NO - FORBIDDEN** |
|
|
48
48
|
| `/massu-loop` | Implement plan with verification | **YES** |
|
|
49
|
+
| `/massu-simplify` | Post-change quality analysis | **YES** (fixes code) |
|
|
49
50
|
| `/massu-commit` | Commit after implementation | After implementation only |
|
|
50
51
|
|
|
51
52
|
**If you find yourself about to edit a source file, STOP. You are violating this protocol.**
|
|
@@ -80,33 +81,87 @@ Create a comprehensive, feasible implementation plan by checking REAL file struc
|
|
|
80
81
|
|
|
81
82
|
## NON-NEGOTIABLE RULES
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
1. Read before referencing - never reference a file without reading it
|
|
85
|
+
2. Pattern compliance - every plan item must align with CLAUDE.md patterns
|
|
86
|
+
3. Enumerated items - every deliverable must be numbered and verifiable
|
|
87
|
+
4. Feasibility pre-check - plan items must be possible with current codebase state
|
|
88
|
+
5. No guessing - if uncertain, read the file or search the codebase
|
|
88
89
|
|
|
89
90
|
---
|
|
90
91
|
|
|
91
|
-
## PHASE 0: REQUIREMENTS INTERVIEW
|
|
92
|
+
## PHASE 0: REQUIREMENTS INTERVIEW
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
INTERVIEW the user before researching.
|
|
94
|
+
### 0.1 Requirements Coverage Map (Initialize at Session Start)
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
- Scope boundaries (what's IN vs OUT of scope)
|
|
98
|
-
- User expectations for behavior
|
|
99
|
-
- Priority trade-offs (speed vs completeness)
|
|
100
|
-
- Any constraints not mentioned
|
|
96
|
+
Track which requirement dimensions have been explored. Initialize ALL as `pending`:
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
| # | Dimension | Status | Resolved By |
|
|
99
|
+
|---|-----------|--------|-------------|
|
|
100
|
+
| D1 | Problem & Scope | pending | User request + Phase 0 interview |
|
|
101
|
+
| D2 | Users & Personas | pending | Phase 0 interview |
|
|
102
|
+
| D3 | Architecture | pending | Phase 2 (Architecture Reality Check) |
|
|
103
|
+
| D4 | Module Design | pending | Phase 3 (Codebase Reality Check) |
|
|
104
|
+
| D5 | UX / API Surface | pending | Phase 3 + Phase 0 interview |
|
|
105
|
+
| D6 | Auth & Permissions | pending | Phase 4 (Pattern Compliance) |
|
|
106
|
+
| D7 | Error Handling | pending | Phase 4 (Pattern Compliance) |
|
|
107
|
+
| D8 | Security | pending | Phase 4.8 (Security Pre-Screen) |
|
|
108
|
+
| D9 | Edge Cases | pending | Phase 4.7 (Question Filtering) |
|
|
109
|
+
| D10 | Performance | pending | Phase 4 (Pattern Compliance) |
|
|
110
|
+
|
|
111
|
+
Mark each dimension `done` or `n/a` as the corresponding phase completes. Dimensions still `pending` after Phase 4.8 trigger a warning before plan generation.
|
|
112
|
+
|
|
113
|
+
### 0.2 Ambiguity Detection
|
|
114
|
+
|
|
115
|
+
Score the user's request against these 7 signals (1 point each):
|
|
116
|
+
|
|
117
|
+
| # | Signal | Example |
|
|
118
|
+
|---|--------|---------|
|
|
119
|
+
| A1 | Vague scope -- no clear boundary | "improve the MCP tools" |
|
|
120
|
+
| A2 | No success criteria -- no measurable outcome | "make it better" |
|
|
121
|
+
| A3 | Implicit requirements -- unstated but necessary | "add caching" (where? what data?) |
|
|
122
|
+
| A4 | Multi-domain -- spans 3+ domains | tools + hooks + config + tests |
|
|
123
|
+
| A5 | Contradictions -- conflicting constraints | "fast AND comprehensive" |
|
|
124
|
+
| A6 | No persona -- unclear who benefits | "add a dashboard" (admin? user?) |
|
|
125
|
+
| A7 | New integration -- external service not yet in codebase | "connect to Datadog" |
|
|
126
|
+
|
|
127
|
+
**Score >= 2**: Enter interview loop (Phase 0.3).
|
|
128
|
+
**Score 0-1**: Fast-track to Phase 0.5/1. Mark D1 as `done` from user request. Mark D2 as `done` if persona is obvious from context, otherwise `n/a`.
|
|
129
|
+
|
|
130
|
+
### 0.3 Interview Loop (When Triggered)
|
|
131
|
+
|
|
132
|
+
Ask one question at a time via AskUserQuestion. For each question:
|
|
133
|
+
|
|
134
|
+
1. **Show compact coverage status** before asking (inline: `Coverage: D1:done D2:pending D3:pending ...`)
|
|
135
|
+
2. **Provide 2-4 curated options** -- never open-ended "what do you want?"
|
|
136
|
+
3. **Push back on contradictions** -- if the user picks conflicting options, flag it: "Option A conflicts with your earlier choice of X. Which takes priority?"
|
|
137
|
+
4. **Push back on over-engineering** -- if scope expands beyond what's needed, flag it: "That adds [X] complexity. The simpler path is [Y]. Proceed with full scope or simplified?"
|
|
138
|
+
5. **Self-terminate** when all user-dependent dimensions (D1, D2, D5) are covered
|
|
139
|
+
6. **Escape hatch** -- if the user says "skip", "enough", or "just do it", stop immediately and mark remaining user dimensions as `n/a`
|
|
140
|
+
|
|
141
|
+
After the loop, mark D1, D2, D5 as `done` (or `n/a` if skipped). D3-D4, D6-D10 are resolved by later phases automatically.
|
|
142
|
+
|
|
143
|
+
### 0.4 Verbal Instruction Capture (MANDATORY after interview)
|
|
144
|
+
|
|
145
|
+
**After the interview loop completes (or is skipped), review the ENTIRE conversation for ANY user statements about:**
|
|
146
|
+
- Placement or location ("put it in the tools module", "alongside the memory tools")
|
|
147
|
+
- Module or route ("this goes in the config section", "on the dashboard page")
|
|
148
|
+
- Naming ("call it X", "the tool should be named Y")
|
|
149
|
+
- Architecture ("use a separate module", "make it a hook")
|
|
150
|
+
- Component choices ("use a Card layout", "DataTable with filters")
|
|
151
|
+
|
|
152
|
+
**Each such statement MUST become an explicit numbered plan item (P-XXX)** with:
|
|
153
|
+
- Exact module/file where it applies
|
|
154
|
+
- Exact file path for the implementation
|
|
155
|
+
- Insertion point within the file
|
|
156
|
+
- The user's exact words quoted as the specification
|
|
157
|
+
|
|
158
|
+
**Why**: Verbal instructions given during conversation are frequently lost during plan generation. If the user said "put the new tool in the memory module", that MUST appear as a plan item referencing the exact file, not a generic "add tool" item.
|
|
104
159
|
|
|
105
160
|
---
|
|
106
161
|
|
|
107
162
|
## PHASE 0.5: TEMPLATE SELECTION
|
|
108
163
|
|
|
109
|
-
Based on the user's request, check if a common pattern template applies. Templates are STARTING POINTS
|
|
164
|
+
Based on the user's request, check if a common pattern template applies. Templates are STARTING POINTS -- subsequent phases still verify feasibility and adjust details.
|
|
110
165
|
|
|
111
166
|
### Template Detection
|
|
112
167
|
|
|
@@ -128,20 +183,20 @@ If the request is for a new dashboard page:
|
|
|
128
183
|
## Pre-filled Plan Structure (Dashboard Page)
|
|
129
184
|
|
|
130
185
|
### Phase 1: Database
|
|
131
|
-
- P1-001: Migration
|
|
132
|
-
- P1-002: Type sync
|
|
186
|
+
- P1-001: Migration -- Create table with RLS, policies, indexes, triggers
|
|
187
|
+
- P1-002: Type sync -- Add type aliases to `website/src/lib/supabase/types.ts`
|
|
133
188
|
|
|
134
189
|
### Phase 2: Data Layer
|
|
135
|
-
- P2-001: Data access functions
|
|
136
|
-
- P2-002: Server actions
|
|
190
|
+
- P2-001: Data access functions -- `website/src/lib/supabase/[FILL].ts`
|
|
191
|
+
- P2-002: Server actions -- `website/src/app/dashboard/[FILL]/actions.ts`
|
|
137
192
|
|
|
138
193
|
### Phase 3: UI
|
|
139
|
-
- P3-001: Page component
|
|
140
|
-
- P3-002: Client components
|
|
141
|
-
- P3-003: Loading state
|
|
194
|
+
- P3-001: Page component -- `website/src/app/dashboard/[FILL]/page.tsx`
|
|
195
|
+
- P3-002: Client components -- `website/src/app/dashboard/[FILL]/[FILL]-client.tsx`
|
|
196
|
+
- P3-003: Loading state -- `website/src/app/dashboard/[FILL]/loading.tsx`
|
|
142
197
|
|
|
143
198
|
### Phase 4: Navigation & Docs
|
|
144
|
-
- P4-001: Update dashboard nav
|
|
199
|
+
- P4-001: Update dashboard nav -- `website/src/components/dashboard/DashboardNav.tsx`
|
|
145
200
|
- P4-002: Update docs if needed
|
|
146
201
|
```
|
|
147
202
|
|
|
@@ -153,14 +208,14 @@ If the request is for a new API endpoint:
|
|
|
153
208
|
## Pre-filled Plan Structure (API Endpoint)
|
|
154
209
|
|
|
155
210
|
### Phase 1: Route
|
|
156
|
-
- P1-001: Route file
|
|
157
|
-
- P1-002: Auth middleware
|
|
158
|
-
- P1-003: Input validation
|
|
211
|
+
- P1-001: Route file -- `website/src/app/api/[FILL]/route.ts`
|
|
212
|
+
- P1-002: Auth middleware -- `createServerSupabaseClient` or `authenticateApiKey`
|
|
213
|
+
- P1-003: Input validation -- Zod schema for request body/params
|
|
159
214
|
|
|
160
215
|
### Phase 2: Logic
|
|
161
216
|
- P2-001: Business logic implementation
|
|
162
|
-
- P2-002: Rate limiting
|
|
163
|
-
- P2-003: Error handling
|
|
217
|
+
- P2-002: Rate limiting -- `rateLimit()` integration
|
|
218
|
+
- P2-003: Error handling -- Consistent error response format
|
|
164
219
|
|
|
165
220
|
### Phase 3: Tests & Docs
|
|
166
221
|
- P3-001: API tests
|
|
@@ -175,20 +230,20 @@ If the request is for a new MCP tool:
|
|
|
175
230
|
## Pre-filled Plan Structure (MCP Tool Module)
|
|
176
231
|
|
|
177
232
|
### Phase 1: Module
|
|
178
|
-
- P1-001: Tool module
|
|
179
|
-
- `get[FILL]ToolDefinitions()`
|
|
180
|
-
- `is[FILL]Tool(name)`
|
|
181
|
-
- `handle[FILL]ToolCall(name, args, memDb)`
|
|
233
|
+
- P1-001: Tool module -- `packages/core/src/[FILL].ts`
|
|
234
|
+
- `get[FILL]ToolDefinitions()` -- Returns tool definitions
|
|
235
|
+
- `is[FILL]Tool(name)` -- Returns boolean for tool name matching
|
|
236
|
+
- `handle[FILL]ToolCall(name, args, memDb)` -- Handles tool execution
|
|
182
237
|
|
|
183
238
|
### Phase 2: Registration
|
|
184
|
-
- P2-001: Wire into tools.ts
|
|
239
|
+
- P2-001: Wire into tools.ts -- Import + definitions + handler routing
|
|
185
240
|
|
|
186
241
|
### Phase 3: Tests
|
|
187
|
-
- P3-001: Test file
|
|
242
|
+
- P3-001: Test file -- `packages/core/src/__tests__/[FILL].test.ts`
|
|
188
243
|
- Test definitions, matching, handler
|
|
189
244
|
|
|
190
245
|
### Phase 4: Config (if needed)
|
|
191
|
-
- P4-001: Config interface
|
|
246
|
+
- P4-001: Config interface -- Add to `config.ts` + `massu.config.yaml`
|
|
192
247
|
```
|
|
193
248
|
|
|
194
249
|
### TEMPLATE D: New Edge Function
|
|
@@ -199,17 +254,17 @@ If the request is for a Supabase edge function:
|
|
|
199
254
|
## Pre-filled Plan Structure (Edge Function)
|
|
200
255
|
|
|
201
256
|
### Phase 1: Function
|
|
202
|
-
- P1-001: Function file
|
|
203
|
-
- P1-002: CORS setup
|
|
204
|
-
- P1-003: Auth
|
|
257
|
+
- P1-001: Function file -- `website/supabase/functions/[FILL]/index.ts`
|
|
258
|
+
- P1-002: CORS setup -- Standard CORS headers for the function
|
|
259
|
+
- P1-003: Auth -- Verify JWT or API key
|
|
205
260
|
|
|
206
261
|
### Phase 2: Logic
|
|
207
|
-
- P2-001: Input validation
|
|
208
|
-
- P2-002: Business logic
|
|
209
|
-
- P2-003: Error handling
|
|
262
|
+
- P2-001: Input validation -- Parse and validate request body
|
|
263
|
+
- P2-002: Business logic -- Core function implementation
|
|
264
|
+
- P2-003: Error handling -- Structured error responses
|
|
210
265
|
|
|
211
266
|
### Phase 3: Config
|
|
212
|
-
- P3-001: Cron config (if scheduled)
|
|
267
|
+
- P3-001: Cron config (if scheduled) -- Add to `supabase/config.toml`
|
|
213
268
|
```
|
|
214
269
|
|
|
215
270
|
### TEMPLATE E: Feature Tier Addition
|
|
@@ -220,22 +275,22 @@ If the request is for adding features to a pricing tier:
|
|
|
220
275
|
## Pre-filled Plan Structure (Feature Tier Addition)
|
|
221
276
|
|
|
222
277
|
### Phase 1: Database
|
|
223
|
-
- P1-001: Migration
|
|
224
|
-
- P1-002: Type sync
|
|
278
|
+
- P1-001: Migration -- New tables/columns for tier features
|
|
279
|
+
- P1-002: Type sync -- Update type aliases
|
|
225
280
|
|
|
226
281
|
### Phase 2: Backend
|
|
227
|
-
- P2-001: Data layer
|
|
228
|
-
- P2-002: Server actions
|
|
282
|
+
- P2-001: Data layer -- Access functions with tier checks
|
|
283
|
+
- P2-002: Server actions -- CRUD with tier-based permissions
|
|
229
284
|
|
|
230
285
|
### Phase 3: UI
|
|
231
|
-
- P3-001: Feature pages
|
|
232
|
-
- P3-002: Navigation update
|
|
286
|
+
- P3-001: Feature pages -- Dashboard pages for new features
|
|
287
|
+
- P3-002: Navigation update -- Add to tier-appropriate nav
|
|
233
288
|
|
|
234
289
|
### Phase 4: Marketing & Docs
|
|
235
|
-
- P4-001: Pricing update
|
|
236
|
-
- P4-002: Feature comparison
|
|
237
|
-
- P4-003: FAQ update
|
|
238
|
-
- P4-004: Documentation
|
|
290
|
+
- P4-001: Pricing update -- `website/src/data/pricing.ts`
|
|
291
|
+
- P4-002: Feature comparison -- `FeatureComparison.tsx`
|
|
292
|
+
- P4-003: FAQ update -- `PricingFAQ.tsx`
|
|
293
|
+
- P4-004: Documentation -- Feature docs pages
|
|
239
294
|
```
|
|
240
295
|
|
|
241
296
|
### If No Template Matches
|
|
@@ -495,6 +550,25 @@ grep -rn '[old_value]' massu.config.yaml
|
|
|
495
550
|
- [ ] Example in massu.config.yaml
|
|
496
551
|
```
|
|
497
552
|
|
|
553
|
+
### 4.2 Similar Feature Analysis
|
|
554
|
+
|
|
555
|
+
Read the most similar module and its tests. Document: input validation approach, tool registration pattern, error handling, config access, test structure.
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
## PHASE 4.5: BACKEND-FRONTEND COUPLING CHECK
|
|
560
|
+
|
|
561
|
+
**MANDATORY**: If the plan includes backend/tool changes, it MUST include corresponding integration or test changes.
|
|
562
|
+
|
|
563
|
+
| Backend Change | Required Corresponding Change |
|
|
564
|
+
|----------------|-------------------------------|
|
|
565
|
+
| New tool definitions | Wire into tools.ts + test coverage |
|
|
566
|
+
| New config fields | Config interface update + YAML example |
|
|
567
|
+
| Changed type structure | All consumers updated |
|
|
568
|
+
| New exports | Import added where needed |
|
|
569
|
+
|
|
570
|
+
Before finalizing: for EVERY new tool, type, or procedure added, verify there is a corresponding registration and test item. If NO, ADD IT NOW.
|
|
571
|
+
|
|
498
572
|
---
|
|
499
573
|
|
|
500
574
|
## PHASE 4.7: QUESTION FILTERING (Before Writing Plan)
|
|
@@ -520,6 +594,32 @@ Questions that require the user:
|
|
|
520
594
|
|
|
521
595
|
**If all questions are self-answerable, skip the user prompt entirely and proceed to plan generation.**
|
|
522
596
|
|
|
597
|
+
Update coverage map: mark D9 (Edge Cases) as `done`.
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
## PHASE 4.8: SECURITY PRE-SCREEN (Shift-Left Gate)
|
|
602
|
+
|
|
603
|
+
Score the plan against these 6 security dimensions:
|
|
604
|
+
|
|
605
|
+
| # | Dimension | Check |
|
|
606
|
+
|---|-----------|-------|
|
|
607
|
+
| S1 | Input validation | All external inputs have Zod/validation |
|
|
608
|
+
| S2 | Auth boundaries | Protected operations require auth |
|
|
609
|
+
| S3 | Data exposure | No sensitive data in logs/responses |
|
|
610
|
+
| S4 | Secret handling | No hardcoded secrets (CR-5) |
|
|
611
|
+
| S5 | Injection risk | No raw string interpolation in queries |
|
|
612
|
+
| S6 | Error leakage | Error messages don't expose internals |
|
|
613
|
+
|
|
614
|
+
**Score**: Each dimension = PASS / WARN / BLOCK.
|
|
615
|
+
**Gate**: 0 BLOCKS = proceed. Any BLOCK = resolve before Phase 5.
|
|
616
|
+
|
|
617
|
+
### Skip Condition
|
|
618
|
+
|
|
619
|
+
Pure read-only cosmetic changes with NO data access changes may skip this phase. Document: `Phase 4.8 SKIPPED: [reason -- cosmetic-only, no data flow changes]`.
|
|
620
|
+
|
|
621
|
+
Update coverage map: mark D6, D7, D8, D10 as `done`.
|
|
622
|
+
|
|
523
623
|
---
|
|
524
624
|
|
|
525
625
|
## PHASE 5: PLAN GENERATION
|
|
@@ -540,6 +640,21 @@ Questions that require the user:
|
|
|
540
640
|
- Patterns reviewed: YES
|
|
541
641
|
- Similar features analyzed: YES
|
|
542
642
|
|
|
643
|
+
## Requirements Coverage
|
|
644
|
+
| Dimension | Status | Resolution |
|
|
645
|
+
|-----------|--------|------------|
|
|
646
|
+
| D1 Problem & Scope | done | User request + interview |
|
|
647
|
+
| D2 Users & Personas | done | [how resolved] |
|
|
648
|
+
| D3 Architecture | done | Phase 2 architecture check |
|
|
649
|
+
| D4 Module Design | done | Phase 3 codebase check |
|
|
650
|
+
| D5 UX / API Surface | done | [how resolved] |
|
|
651
|
+
| D6 Auth & Permissions | done | Phase 4 pattern compliance |
|
|
652
|
+
| D7 Error Handling | done | Phase 4 pattern compliance |
|
|
653
|
+
| D8 Security | done | Phase 4.8 pre-screen |
|
|
654
|
+
| D9 Edge Cases | done | Phase 4.7 question filtering |
|
|
655
|
+
| D10 Performance | done | Phase 4 pattern compliance |
|
|
656
|
+
**Coverage Gate**: X/10 dimensions resolved (deferred: Y)
|
|
657
|
+
|
|
543
658
|
---
|
|
544
659
|
|
|
545
660
|
## Phase 1: Core Implementation
|
|
@@ -638,6 +753,8 @@ Questions that require the user:
|
|
|
638
753
|
| Tests | P2-XXX | P2-001, P2-002 |
|
|
639
754
|
| Config & Docs | P3-XXX | P3-001, P3-002 |
|
|
640
755
|
|
|
756
|
+
**Every item MUST have a unique ID for tracking.**
|
|
757
|
+
|
|
641
758
|
---
|
|
642
759
|
|
|
643
760
|
## PHASE 6: FEASIBILITY VALIDATION
|
|
@@ -681,6 +798,17 @@ Questions that require the user:
|
|
|
681
798
|
| **Pattern reference** | Which existing module to follow |
|
|
682
799
|
| **Verification command** | Specific grep/ls that proves the item was implemented |
|
|
683
800
|
|
|
801
|
+
Specificity by type: MODULE (path + exports + pattern), TOOL_WIRE (tools.ts changes: import + definition + handler), TEST (file path + covers + assertions), CONFIG (interface changes + YAML example), HOOK (file path + stdin/stdout format + esbuild compat).
|
|
802
|
+
|
|
803
|
+
If ANY item lacks specificity: research the target format, write the exact implementation, then update the plan.
|
|
804
|
+
|
|
805
|
+
### 6.3 If Feasibility Fails
|
|
806
|
+
|
|
807
|
+
1. Identify blockers
|
|
808
|
+
2. Add prerequisites
|
|
809
|
+
3. Revise plan
|
|
810
|
+
4. Re-validate
|
|
811
|
+
|
|
684
812
|
---
|
|
685
813
|
|
|
686
814
|
## OUTPUT FORMAT
|
|
@@ -695,7 +823,7 @@ Questions that require the user:
|
|
|
695
823
|
### Plan Summary for User
|
|
696
824
|
|
|
697
825
|
```markdown
|
|
698
|
-
##
|
|
826
|
+
## MASSU CREATE PLAN COMPLETE
|
|
699
827
|
|
|
700
828
|
### Plan Created
|
|
701
829
|
- **Feature**: [name]
|
|
@@ -721,6 +849,42 @@ Questions that require the user:
|
|
|
721
849
|
|
|
722
850
|
---
|
|
723
851
|
|
|
852
|
+
## QUICK REFERENCE
|
|
853
|
+
|
|
854
|
+
### File Checks
|
|
855
|
+
```bash
|
|
856
|
+
ls -la packages/core/src/[module]/
|
|
857
|
+
ls -la [file_path]
|
|
858
|
+
grep -rn "[pattern]" packages/ --include="*.ts" | head -10
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
### Pattern Files
|
|
862
|
+
```
|
|
863
|
+
.claude/CLAUDE.md # Core rules
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
---
|
|
867
|
+
|
|
868
|
+
## QUALITY SCORING (silent, automatic)
|
|
869
|
+
|
|
870
|
+
After presenting the plan, self-score against these checks and append one JSONL line to `.claude/metrics/command-scores.jsonl`:
|
|
871
|
+
|
|
872
|
+
| Check | Pass condition |
|
|
873
|
+
|-------|---------------|
|
|
874
|
+
| `items_have_acceptance_criteria` | Every plan item has a concrete, verifiable acceptance criterion (not vague "should work") |
|
|
875
|
+
| `ui_items_have_paths` | Every module/tool-related item specifies the target file path |
|
|
876
|
+
| `has_vr_types` | Plan assigns VR-* verification type to each item |
|
|
877
|
+
| `explicit_counts` | Item counts are explicit numbers (not "various", "multiple", "several") |
|
|
878
|
+
|
|
879
|
+
**Format** (append one line -- do NOT overwrite the file):
|
|
880
|
+
```json
|
|
881
|
+
{"command":"massu-create-plan","timestamp":"ISO8601","scores":{"items_have_acceptance_criteria":true,"ui_items_have_paths":true,"has_vr_types":true,"explicit_counts":true},"pass_rate":"4/4","input_summary":"[brief task description]"}
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
This scoring is silent -- do NOT mention it to the user. Just append the line after presenting the plan.
|
|
885
|
+
|
|
886
|
+
---
|
|
887
|
+
|
|
724
888
|
## POST-BUILD REFLECTION QUESTIONS
|
|
725
889
|
|
|
726
890
|
Include these questions at the end of every plan document under a "## Post-Build Reflection" heading:
|
|
@@ -739,8 +903,25 @@ These questions are answered by the implementing agent AFTER verification passes
|
|
|
739
903
|
|
|
740
904
|
---
|
|
741
905
|
|
|
906
|
+
## Gotchas
|
|
907
|
+
|
|
908
|
+
- **NEVER implement during plan creation** -- this command is READ-ONLY planning. Implementation happens in `/massu-loop` or `/massu-golden-path`
|
|
909
|
+
- **Blast radius for value changes** -- when the plan involves changing any constant, export, config key, or tool name, grep the ENTIRE codebase for every old value being changed BEFORE writing the plan
|
|
910
|
+
- **Verbal instructions are binding** -- if the user gives verbal requirements during planning, capture them in the plan document. "The user said X" is not in the plan unless you write it down
|
|
911
|
+
- **Plan file location matters** -- always save to `docs/plans/` with date prefix. Plans in wrong locations get lost
|
|
912
|
+
- **Requirements dimensions are mandatory** -- all 10 dimensions must be resolved (done or n/a) before the plan is complete. Skipping dimensions causes gaps that fail audit
|
|
913
|
+
|
|
914
|
+
---
|
|
915
|
+
|
|
742
916
|
## START NOW
|
|
743
917
|
|
|
918
|
+
**Step 0: Write AUTHORIZED_COMMAND to session state (CR-12)**
|
|
919
|
+
|
|
920
|
+
Before any other work, update `session-state/CURRENT.md` to include:
|
|
921
|
+
```
|
|
922
|
+
AUTHORIZED_COMMAND: massu-create-plan
|
|
923
|
+
```
|
|
924
|
+
|
|
744
925
|
1. **Capture** the feature request
|
|
745
926
|
2. **Read** similar features in codebase
|
|
746
927
|
3. **Verify** architecture and file structure
|
|
@@ -748,5 +929,6 @@ These questions are answered by the implementing agent AFTER verification passes
|
|
|
748
929
|
5. **Write** plan with verified facts
|
|
749
930
|
6. **Validate** feasibility
|
|
750
931
|
7. **Output** plan document
|
|
932
|
+
8. **Score and append to command-scores.jsonl** (silent)
|
|
751
933
|
|
|
752
934
|
**Remember: Read first, plan second. No assumptions, only evidence.**
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Common Queries
|
|
2
|
+
|
|
3
|
+
Pre-built query templates for frequent data analysis tasks.
|
|
4
|
+
|
|
5
|
+
## Entity Counts
|
|
6
|
+
|
|
7
|
+
```sql
|
|
8
|
+
SELECT 'contacts' as entity, COUNT(*) as count FROM unified_contacts
|
|
9
|
+
UNION ALL SELECT 'products', COUNT(*) FROM unified_products
|
|
10
|
+
UNION ALL SELECT 'orders', COUNT(*) FROM orders
|
|
11
|
+
UNION ALL SELECT 'proposals', COUNT(*) FROM proposals
|
|
12
|
+
UNION ALL SELECT 'documents', COUNT(*) FROM unified_documents
|
|
13
|
+
UNION ALL SELECT 'users', COUNT(*) FROM user_profiles
|
|
14
|
+
ORDER BY count DESC;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Recent Activity (Last 7 Days)
|
|
18
|
+
|
|
19
|
+
```sql
|
|
20
|
+
SELECT 'contacts_created' as metric, COUNT(*) as count
|
|
21
|
+
FROM unified_contacts WHERE created_at > NOW() - INTERVAL '7 days'
|
|
22
|
+
UNION ALL
|
|
23
|
+
SELECT 'orders_created', COUNT(*)
|
|
24
|
+
FROM orders WHERE created_at > NOW() - INTERVAL '7 days'
|
|
25
|
+
UNION ALL
|
|
26
|
+
SELECT 'proposals_created', COUNT(*)
|
|
27
|
+
FROM proposals WHERE created_at > NOW() - INTERVAL '7 days'
|
|
28
|
+
UNION ALL
|
|
29
|
+
SELECT 'documents_uploaded', COUNT(*)
|
|
30
|
+
FROM unified_documents WHERE created_at > NOW() - INTERVAL '7 days';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Contact Lifecycle Funnel
|
|
34
|
+
|
|
35
|
+
```sql
|
|
36
|
+
SELECT lifecycle_stage, COUNT(*) as count,
|
|
37
|
+
ROUND(COUNT(*)::numeric / SUM(COUNT(*)) OVER () * 100, 1) as pct
|
|
38
|
+
FROM unified_contacts
|
|
39
|
+
WHERE lifecycle_stage IS NOT NULL
|
|
40
|
+
GROUP BY lifecycle_stage
|
|
41
|
+
ORDER BY CASE lifecycle_stage
|
|
42
|
+
WHEN 'lead' THEN 1
|
|
43
|
+
WHEN 'prospect' THEN 2
|
|
44
|
+
WHEN 'customer' THEN 3
|
|
45
|
+
WHEN 'repeat' THEN 4
|
|
46
|
+
ELSE 5
|
|
47
|
+
END;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Order Status Distribution
|
|
51
|
+
|
|
52
|
+
```sql
|
|
53
|
+
SELECT status, COUNT(*) as count,
|
|
54
|
+
SUM(COALESCE(total_amount, 0))::float as total_value
|
|
55
|
+
FROM orders
|
|
56
|
+
GROUP BY status
|
|
57
|
+
ORDER BY count DESC;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Top Products by Order Frequency
|
|
61
|
+
|
|
62
|
+
```sql
|
|
63
|
+
SELECT up.product_number as sku, up.name, COUNT(oli.id) as order_count
|
|
64
|
+
FROM order_line_items oli
|
|
65
|
+
JOIN unified_products up ON up.id = oli.unified_product_id
|
|
66
|
+
GROUP BY up.id, up.product_number, up.name
|
|
67
|
+
ORDER BY order_count DESC
|
|
68
|
+
LIMIT 20;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Storage Bucket Usage
|
|
72
|
+
|
|
73
|
+
```sql
|
|
74
|
+
SELECT bucket_id, COUNT(*) as file_count,
|
|
75
|
+
SUM(COALESCE((metadata->>'size')::bigint, 0))::float as total_bytes
|
|
76
|
+
FROM storage.objects
|
|
77
|
+
GROUP BY bucket_id
|
|
78
|
+
ORDER BY total_bytes DESC;
|
|
79
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Key Tables & Relationships
|
|
2
|
+
|
|
3
|
+
Quick reference for the most-queried tables in the system.
|
|
4
|
+
|
|
5
|
+
## Core Entities
|
|
6
|
+
|
|
7
|
+
| Table | Primary Key | Description | Key Columns |
|
|
8
|
+
|-------|-------------|-------------|-------------|
|
|
9
|
+
| `unified_contacts` | `id` (uuid) | All contacts (individuals + companies) | `full_name`, `email`, `lifecycle_stage`, `contact_kind` |
|
|
10
|
+
| `unified_products` | `id` (uuid) | Product catalog | `name`, `product_number` (SKU), `furniture_type`, `list_price`, `cost` |
|
|
11
|
+
| `orders` | `id` (uuid) | Sales orders | `order_number`, `status`, `total_amount`, `contact_id` |
|
|
12
|
+
| `proposals` | `id` (uuid) | Sales proposals | `proposal_number`, `status`, `total_amount`, `contact_id` |
|
|
13
|
+
| `unified_documents` | `id` (uuid) | All documents (polymorphic) | `title`, `document_type`, `primary_entity_type`, `primary_entity_id` |
|
|
14
|
+
| `user_profiles` | `id` (uuid) | Internal users | `full_name`, `email`, `user_type`, `role` |
|
|
15
|
+
|
|
16
|
+
## Relationships
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
unified_contacts ─┬─< orders (contact_id)
|
|
20
|
+
├─< proposals (contact_id)
|
|
21
|
+
└─< unified_documents (primary_entity_id WHERE primary_entity_type = 'contact')
|
|
22
|
+
|
|
23
|
+
unified_products ─┬─< order_line_items (unified_product_id)
|
|
24
|
+
├─< proposal_items (unified_product_id)
|
|
25
|
+
├─< furniture_dimensions (unified_product_id)
|
|
26
|
+
├─< product_images (unified_product_id)
|
|
27
|
+
└─< unified_documents (primary_entity_id WHERE primary_entity_type = 'product')
|
|
28
|
+
|
|
29
|
+
orders ─────────── order_line_items (order_id)
|
|
30
|
+
proposals ──────── proposal_sections ─── proposal_items
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Known Column Gotchas
|
|
34
|
+
|
|
35
|
+
| Table | WRONG Column | CORRECT Column |
|
|
36
|
+
|-------|--------------|----------------|
|
|
37
|
+
| `design_*` tables | `project_id` | `design_project_id` |
|
|
38
|
+
| `unified_products` | `category` | `furniture_type` |
|
|
39
|
+
| `unified_products` | `retail_price` | `list_price` |
|
|
40
|
+
| `unified_products` | `unit_cost` | `cost` |
|
|
41
|
+
| `unified_products` | `sku` | `product_number` (sku is NULL) |
|
|
42
|
+
|
|
43
|
+
## ALWAYS Verify Schema First
|
|
44
|
+
|
|
45
|
+
```sql
|
|
46
|
+
SELECT column_name, data_type
|
|
47
|
+
FROM information_schema.columns
|
|
48
|
+
WHERE table_name = 'YOUR_TABLE'
|
|
49
|
+
ORDER BY ordinal_position;
|
|
50
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: massu-data
|
|
3
|
+
description: "When user asks about data trends, metrics, analytics, funnel analysis, cohort comparison, entity counts, storage usage, or 'what happened' questions about the database"
|
|
4
|
+
allowed-tools: Bash(*), Read(*), Grep(*), Glob(*), mcp__supabase__DEV__*, mcp__supabase__NEW_PROD__*, mcp__supabase__OLD_PROD__*
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Data Analysis
|
|
8
|
+
|
|
9
|
+
Structured data analysis and query library for Massu databases.
|
|
10
|
+
|
|
11
|
+
## Skill Contents
|
|
12
|
+
|
|
13
|
+
This skill is a folder. The following files are available for reference:
|
|
14
|
+
|
|
15
|
+
| File | Purpose | Read When |
|
|
16
|
+
|------|---------|-----------|
|
|
17
|
+
| `references/common-queries.md` | Pre-built Supabase queries | Looking for a query template |
|
|
18
|
+
| `references/table-guide.md` | Key tables and relationships | Understanding data model |
|
|
19
|
+
| `scripts/entity-counts.sql` | Quick entity count dashboard | Need a system overview |
|
|
20
|
+
| `scripts/funnel-query.sql` | Contact lifecycle funnel | Analyzing conversion |
|
|
21
|
+
| `scripts/cohort-compare.sql` | Compare two date ranges | Trend analysis |
|
|
22
|
+
| `scripts/storage-usage.sql` | Storage bucket analysis | Checking disk usage |
|
|
23
|
+
|
|
24
|
+
## Process
|
|
25
|
+
|
|
26
|
+
1. **Understand the question** — What data does the user need?
|
|
27
|
+
2. **Identify target database** — DEV (testing), NEW PROD (live data), OLD PROD (historical)
|
|
28
|
+
3. **Check for pre-built query** — Review `scripts/` for a matching SQL template
|
|
29
|
+
4. **Verify schema** — Run VR-SCHEMA-PRE before any custom query
|
|
30
|
+
5. **Execute query** — Use MCP `execute_sql` tool
|
|
31
|
+
6. **Present results** — Format as table with clear labels
|
|
32
|
+
|
|
33
|
+
## Database Selection
|
|
34
|
+
|
|
35
|
+
| User Says | Database |
|
|
36
|
+
|-----------|----------|
|
|
37
|
+
| "production", "live", "real data" | NEW PROD |
|
|
38
|
+
| "dev", "test", "local" | DEV |
|
|
39
|
+
| "old prod", "historical" | OLD PROD |
|
|
40
|
+
| No qualifier | NEW PROD (default) |
|
|
41
|
+
|
|
42
|
+
## Key Tables
|
|
43
|
+
|
|
44
|
+
| Domain | Primary Table | Related Tables |
|
|
45
|
+
|--------|---------------|----------------|
|
|
46
|
+
| Contacts | `unified_contacts` | `contact_activities`, `contact_tags` |
|
|
47
|
+
| Products | `unified_products` | `furniture_dimensions`, `product_images` |
|
|
48
|
+
| Orders | `orders` | `order_items`, `order_line_items` |
|
|
49
|
+
| Proposals | `proposals` | `proposal_sections`, `proposal_items` |
|
|
50
|
+
| Documents | `unified_documents` | `document_versions`, `document_comments` |
|
|
51
|
+
| Users | `user_profiles` | `portal_access`, `user_roles` |
|
|
52
|
+
|
|
53
|
+
## Gotchas
|
|
54
|
+
|
|
55
|
+
- **NEVER use `ctx.db.users`** — use `user_profiles` (auth.users not exposed)
|
|
56
|
+
- **NEVER guess column names** — always VR-SCHEMA-PRE first
|
|
57
|
+
- **BigInt columns** — convert with `::text` in SQL or `Number()` in JS
|
|
58
|
+
- **Decimal columns** — unified_products has 8 Decimal columns, use `::float` for display
|
|
59
|
+
- **RLS policies** — MCP queries run as service_role, bypassing RLS. Be aware of what data you're exposing.
|
|
60
|
+
|
|
61
|
+
## START NOW
|
|
62
|
+
|
|
63
|
+
Ask the user what data they need, then:
|
|
64
|
+
1. Check `scripts/` for a pre-built query
|
|
65
|
+
2. If custom query needed, verify schema first
|
|
66
|
+
3. Execute and present results
|