@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.
- 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 +1451 -1047
- package/dist/hooks/post-tool-use.js +75 -6
- package/dist/hooks/user-prompt.js +16 -0
- 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/init.ts +27 -0
- package/src/commands/install-commands.ts +149 -53
- package/src/hooks/post-tool-use.ts +17 -0
- package/src/hooks/user-prompt.ts +21 -0
- package/src/memory-file-ingest.ts +127 -0
- package/src/memory-tools.ts +34 -1
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: massu-perf
|
|
3
|
+
description: "When user says 'performance audit', 'slow queries', 'bundle too large', 'page is slow', or needs to identify performance bottlenecks in queries, bundle size, or render cycles"
|
|
4
|
+
allowed-tools: Bash(*), Read(*), Grep(*), Glob(*)
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
---
|
|
7
|
+
name: massu-perf
|
|
8
|
+
|
|
9
|
+
> **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-14, CR-5, CR-12 enforced.
|
|
10
|
+
|
|
11
|
+
# Massu Perf: Performance Audit Protocol
|
|
12
|
+
|
|
13
|
+
## Objective
|
|
14
|
+
|
|
15
|
+
Identify and fix performance bottlenecks in database queries, bundle size, rendering, and API calls with **measurable evidence**.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## NON-NEGOTIABLE RULES
|
|
20
|
+
|
|
21
|
+
- **Measure before optimizing** - Prove the bottleneck exists
|
|
22
|
+
- **Measure after optimizing** - Prove the fix worked
|
|
23
|
+
- **No premature optimization** - Focus on actual issues
|
|
24
|
+
- **Follow patterns** - Use CLAUDE.md approved approaches
|
|
25
|
+
- **Document benchmarks** - Show before/after metrics
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ZERO-GAP AUDIT LOOP
|
|
30
|
+
|
|
31
|
+
**Performance optimization does NOT complete until a SINGLE COMPLETE AUDIT finds ZERO issues.**
|
|
32
|
+
|
|
33
|
+
### The Rule
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
PERFORMANCE AUDIT LOOP:
|
|
37
|
+
1. Identify bottlenecks with measurements
|
|
38
|
+
2. Apply optimizations
|
|
39
|
+
3. Run ALL verification checks (patterns, types, build, benchmarks)
|
|
40
|
+
4. Count issues found
|
|
41
|
+
5. IF issues > 0:
|
|
42
|
+
- Fix ALL issues
|
|
43
|
+
- Re-run ENTIRE verification from Step 3
|
|
44
|
+
6. IF issues == 0:
|
|
45
|
+
- OPTIMIZATION VERIFIED
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Completion Requirement
|
|
49
|
+
|
|
50
|
+
| Scenario | Action |
|
|
51
|
+
|----------|--------|
|
|
52
|
+
| Optimization breaks build | Fix it, re-verify ENTIRELY |
|
|
53
|
+
| Re-verify finds regression | Fix it, re-verify ENTIRELY |
|
|
54
|
+
| Re-verify finds 0 issues | **NOW** optimization complete |
|
|
55
|
+
|
|
56
|
+
**Partial verification is NOT valid. ALL checks must pass in a SINGLE run.**
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## DOMAIN-SPECIFIC PATTERN LOADING
|
|
61
|
+
|
|
62
|
+
| Domain | Pattern File |
|
|
63
|
+
|--------|--------------|
|
|
64
|
+
| Database queries | `.claude/patterns/database-patterns.md` |
|
|
65
|
+
| UI rendering | `.claude/patterns/ui-patterns.md` |
|
|
66
|
+
| Build optimization | `.claude/patterns/build-patterns.md` |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## AUDIT SECTION 1: DATABASE PERFORMANCE
|
|
71
|
+
|
|
72
|
+
### 1.1 Query Analysis
|
|
73
|
+
```sql
|
|
74
|
+
-- Find slow queries (requires pg_stat_statements extension)
|
|
75
|
+
SELECT query, calls, total_time, mean_time
|
|
76
|
+
FROM pg_stat_statements
|
|
77
|
+
ORDER BY mean_time DESC
|
|
78
|
+
LIMIT 20;
|
|
79
|
+
|
|
80
|
+
-- Find queries without indexes
|
|
81
|
+
SELECT schemaname, tablename, seq_scan, idx_scan
|
|
82
|
+
FROM pg_stat_user_tables
|
|
83
|
+
WHERE seq_scan > idx_scan
|
|
84
|
+
ORDER BY seq_scan DESC;
|
|
85
|
+
|
|
86
|
+
-- Find large tables
|
|
87
|
+
SELECT relname, n_live_tup, pg_size_pretty(pg_total_relation_size(relid))
|
|
88
|
+
FROM pg_stat_user_tables
|
|
89
|
+
ORDER BY n_live_tup DESC
|
|
90
|
+
LIMIT 20;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 1.2 Index Analysis
|
|
94
|
+
```sql
|
|
95
|
+
-- Missing indexes (high seq_scan)
|
|
96
|
+
SELECT relname, seq_scan, idx_scan,
|
|
97
|
+
CASE WHEN seq_scan + idx_scan > 0
|
|
98
|
+
THEN round(100.0 * idx_scan / (seq_scan + idx_scan), 2)
|
|
99
|
+
ELSE 0 END AS idx_usage_pct
|
|
100
|
+
FROM pg_stat_user_tables
|
|
101
|
+
WHERE seq_scan > 1000
|
|
102
|
+
ORDER BY seq_scan DESC;
|
|
103
|
+
|
|
104
|
+
-- Existing indexes
|
|
105
|
+
SELECT indexname, tablename, indexdef
|
|
106
|
+
FROM pg_indexes
|
|
107
|
+
WHERE schemaname = 'public'
|
|
108
|
+
ORDER BY tablename;
|
|
109
|
+
|
|
110
|
+
-- Unused indexes (candidates for removal)
|
|
111
|
+
SELECT schemaname, tablename, indexrelname, idx_scan
|
|
112
|
+
FROM pg_stat_user_indexes
|
|
113
|
+
WHERE idx_scan = 0 AND schemaname = 'public';
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 1.3 Query Pattern Check
|
|
117
|
+
```bash
|
|
118
|
+
# Find N+1 query patterns (loops with queries inside)
|
|
119
|
+
grep -rn "for.*await.*db\|forEach.*await.*db" src/
|
|
120
|
+
|
|
121
|
+
# Find missing WHERE clauses (full table scans)
|
|
122
|
+
grep -rn "findMany()\|findMany({})" src/
|
|
123
|
+
|
|
124
|
+
# Find large LIMIT values
|
|
125
|
+
grep -rn "take:\s*[0-9]\{3,\}" src/
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 1.4 Database Performance Matrix
|
|
129
|
+
```markdown
|
|
130
|
+
### Database Performance Audit
|
|
131
|
+
|
|
132
|
+
| Query/Table | Avg Time | Calls | Index Used | Status |
|
|
133
|
+
|-------------|----------|-------|------------|--------|
|
|
134
|
+
| [query] | Xms | N | YES/NO | OK/SLOW |
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## AUDIT SECTION 2: BUNDLE SIZE
|
|
140
|
+
|
|
141
|
+
### 2.1 Bundle Analysis
|
|
142
|
+
```bash
|
|
143
|
+
# Analyze bundle size
|
|
144
|
+
npm run build 2>&1 | grep -A 50 "Route\|Size"
|
|
145
|
+
|
|
146
|
+
# Check for large dependencies
|
|
147
|
+
npm ls --depth=0 | head -30
|
|
148
|
+
|
|
149
|
+
# Find heavy imports
|
|
150
|
+
grep -rn "import.*from" src/ | grep -v node_modules | cut -d: -f2 | sort | uniq -c | sort -rn | head -20
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 2.2 Dynamic Import Check
|
|
154
|
+
```bash
|
|
155
|
+
# Find dynamic imports (good)
|
|
156
|
+
grep -rn "await import\|React.lazy\|dynamic(" src/ | grep -v node_modules | wc -l
|
|
157
|
+
|
|
158
|
+
# Find static heavy imports that should be dynamic
|
|
159
|
+
grep -rn "import.*jsdom\|import.*moment\|import.*lodash" src/ | grep -v "await import"
|
|
160
|
+
# These should use dynamic imports
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 2.3 Tree Shaking Issues
|
|
164
|
+
```bash
|
|
165
|
+
# Find namespace imports (blocks tree shaking)
|
|
166
|
+
grep -rn "import \* as" src/ | grep -v node_modules
|
|
167
|
+
|
|
168
|
+
# Find barrel imports from large packages
|
|
169
|
+
grep -rn "from '@mui\|from 'lodash'\|from 'date-fns'" src/ | grep -v node_modules
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 2.4 Bundle Size Matrix
|
|
173
|
+
```markdown
|
|
174
|
+
### Bundle Size Audit
|
|
175
|
+
|
|
176
|
+
| Route/Page | Size | First Load | Status |
|
|
177
|
+
|------------|------|------------|--------|
|
|
178
|
+
| / | X kB | X kB | OK/LARGE |
|
|
179
|
+
| /dashboard | X kB | X kB | OK/LARGE |
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## AUDIT SECTION 3: RENDERING PERFORMANCE
|
|
185
|
+
|
|
186
|
+
### 3.1 Re-render Analysis
|
|
187
|
+
```bash
|
|
188
|
+
# Find missing useMemo
|
|
189
|
+
grep -rn "const.*=.*filter\|const.*=.*map\|const.*=.*reduce" src/components/ | grep -v "useMemo" | head -20
|
|
190
|
+
|
|
191
|
+
# Find missing useCallback
|
|
192
|
+
grep -rn "const.*=.*=>" src/components/ | grep "onClick\|onChange\|onSubmit" | grep -v "useCallback" | head -20
|
|
193
|
+
|
|
194
|
+
# Find inline object/array creation (causes re-renders)
|
|
195
|
+
grep -rn "style={\s*{" src/ | grep -v node_modules | head -10
|
|
196
|
+
grep -rn "className={\s*\[" src/ | grep -v node_modules | head -10
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 3.2 Component Optimization
|
|
200
|
+
```bash
|
|
201
|
+
# Find large components (complexity indicator)
|
|
202
|
+
find src/components -name "*.tsx" -exec wc -l {} \; | sort -rn | head -20
|
|
203
|
+
|
|
204
|
+
# Find components without memo
|
|
205
|
+
grep -rn "export default function\|export function" src/components/ | grep -v "memo(" | head -20
|
|
206
|
+
|
|
207
|
+
# Find expensive computations in render
|
|
208
|
+
grep -rn "\.filter(\|\.map(\|\.reduce(" src/components/ | grep -v node_modules | wc -l
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 3.3 List Optimization
|
|
212
|
+
```bash
|
|
213
|
+
# Find lists without keys
|
|
214
|
+
grep -rn "\.map(" src/components/ | grep -v "key=" | head -20
|
|
215
|
+
|
|
216
|
+
# Find virtualization usage (good for long lists)
|
|
217
|
+
grep -rn "VirtualList\|useVirtualizer\|react-window\|react-virtual" src/
|
|
218
|
+
|
|
219
|
+
# Find potentially long lists
|
|
220
|
+
grep -rn "\.map(" src/components/ | head -30
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 3.4 Rendering Matrix
|
|
224
|
+
```markdown
|
|
225
|
+
### Rendering Performance Audit
|
|
226
|
+
|
|
227
|
+
| Component | Lines | useMemo | useCallback | memo | Status |
|
|
228
|
+
|-----------|-------|---------|-------------|------|--------|
|
|
229
|
+
| [comp] | N | YES/NO | YES/NO | YES/NO | OK/REVIEW |
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## AUDIT SECTION 4: API PERFORMANCE
|
|
235
|
+
|
|
236
|
+
### 4.1 API Call Analysis
|
|
237
|
+
```bash
|
|
238
|
+
# Find all API calls
|
|
239
|
+
grep -rn "useQuery\|useMutation\|api\." src/components/ src/app/ | grep -v node_modules | wc -l
|
|
240
|
+
|
|
241
|
+
# Find refetch on mount (potential over-fetching)
|
|
242
|
+
grep -rn "refetchOnMount\|refetchOnWindowFocus" src/ | grep -v "false"
|
|
243
|
+
|
|
244
|
+
# Find stale time configuration
|
|
245
|
+
grep -rn "staleTime\|cacheTime\|gcTime" src/
|
|
246
|
+
|
|
247
|
+
# Find parallel queries (good)
|
|
248
|
+
grep -rn "useQueries" src/ | grep -v node_modules
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### 4.2 Query Deduplication
|
|
252
|
+
```bash
|
|
253
|
+
# Find same query called multiple times
|
|
254
|
+
grep -rn "useQuery\|api\.[a-z]*\.[a-z]*" src/ | grep -v node_modules | sort | uniq -c | sort -rn | head -10
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 4.3 API Performance Matrix
|
|
258
|
+
```markdown
|
|
259
|
+
### API Performance Audit
|
|
260
|
+
|
|
261
|
+
| Endpoint | Calls/Page | Cached | Stale Time | Status |
|
|
262
|
+
|----------|------------|--------|------------|--------|
|
|
263
|
+
| [endpoint] | N | YES/NO | Xs | OK/REVIEW |
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## AUDIT SECTION 5: NETWORK OPTIMIZATION
|
|
269
|
+
|
|
270
|
+
### 5.1 Request Analysis
|
|
271
|
+
```bash
|
|
272
|
+
# Find fetch calls
|
|
273
|
+
grep -rn "fetch(\|axios\." src/ | grep -v node_modules | grep -v "trpc"
|
|
274
|
+
|
|
275
|
+
# Find image optimization
|
|
276
|
+
grep -rn "<Image\|<img" src/ | grep -v node_modules | wc -l
|
|
277
|
+
grep -rn "next/image" src/ | grep -v node_modules | wc -l
|
|
278
|
+
|
|
279
|
+
# Find preloading
|
|
280
|
+
grep -rn "prefetch\|preload" src/ | grep -v node_modules
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### 5.2 Caching Strategy
|
|
284
|
+
```bash
|
|
285
|
+
# Check cache headers configuration
|
|
286
|
+
grep -rn "Cache-Control\|revalidate\|s-maxage" src/ next.config.*
|
|
287
|
+
|
|
288
|
+
# Check static generation
|
|
289
|
+
grep -rn "getStaticProps\|getStaticPaths\|generateStaticParams" src/
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## OPTIMIZATION PATTERNS
|
|
295
|
+
|
|
296
|
+
### Database Optimization
|
|
297
|
+
```typescript
|
|
298
|
+
// BAD: N+1 query
|
|
299
|
+
for (const order of orders) {
|
|
300
|
+
const customer = await db.user_profiles.findUnique({ where: { id: order.customer_id } });
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// GOOD: Batch query
|
|
304
|
+
const customerIds = [...new Set(orders.map(o => o.customer_id).filter(Boolean))];
|
|
305
|
+
const customers = await db.user_profiles.findMany({ where: { id: { in: customerIds } } });
|
|
306
|
+
const customerMap = new Map(customers.map(c => [c.id, c]));
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Component Optimization
|
|
310
|
+
```typescript
|
|
311
|
+
// BAD: Re-creates on every render
|
|
312
|
+
const filteredItems = items.filter(i => i.active);
|
|
313
|
+
|
|
314
|
+
// GOOD: Memoized
|
|
315
|
+
const filteredItems = useMemo(() => items.filter(i => i.active), [items]);
|
|
316
|
+
|
|
317
|
+
// BAD: New function on every render
|
|
318
|
+
<Button onClick={() => handleClick(id)} />
|
|
319
|
+
|
|
320
|
+
// GOOD: Stable reference
|
|
321
|
+
const handleButtonClick = useCallback(() => handleClick(id), [id]);
|
|
322
|
+
<Button onClick={handleButtonClick} />
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Import Optimization
|
|
326
|
+
```typescript
|
|
327
|
+
// BAD: Static heavy import
|
|
328
|
+
import { JSDOM } from 'jsdom';
|
|
329
|
+
|
|
330
|
+
// GOOD: Dynamic import
|
|
331
|
+
const { JSDOM } = await import('jsdom');
|
|
332
|
+
|
|
333
|
+
// BAD: Namespace import
|
|
334
|
+
import * as lodash from 'lodash';
|
|
335
|
+
|
|
336
|
+
// GOOD: Named import (tree shakeable)
|
|
337
|
+
import { debounce, throttle } from 'lodash';
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## PERFORMANCE REPORT FORMAT
|
|
343
|
+
|
|
344
|
+
```markdown
|
|
345
|
+
## MASSU PERF AUDIT REPORT
|
|
346
|
+
|
|
347
|
+
### Summary
|
|
348
|
+
- **Date**: [timestamp]
|
|
349
|
+
- **Scope**: Full performance audit
|
|
350
|
+
- **Critical Issues**: [N]
|
|
351
|
+
- **Optimizations Identified**: [N]
|
|
352
|
+
|
|
353
|
+
### Database Performance
|
|
354
|
+
| Issue | Impact | Fix | Priority |
|
|
355
|
+
|-------|--------|-----|----------|
|
|
356
|
+
| [issue] | [impact] | [fix] | P0/P1/P2 |
|
|
357
|
+
|
|
358
|
+
### Bundle Size
|
|
359
|
+
| Route | Current | Target | Action |
|
|
360
|
+
|-------|---------|--------|--------|
|
|
361
|
+
| [route] | X kB | Y kB | [action] |
|
|
362
|
+
|
|
363
|
+
### Rendering
|
|
364
|
+
| Component | Issue | Fix | Priority |
|
|
365
|
+
|-----------|-------|-----|----------|
|
|
366
|
+
| [comp] | Missing memo | Add React.memo | P2 |
|
|
367
|
+
|
|
368
|
+
### API
|
|
369
|
+
| Endpoint | Issue | Fix | Priority |
|
|
370
|
+
|----------|-------|-----|----------|
|
|
371
|
+
| [endpoint] | Over-fetching | Add staleTime | P1 |
|
|
372
|
+
|
|
373
|
+
### Recommendations
|
|
374
|
+
1. [Recommendation 1]
|
|
375
|
+
2. [Recommendation 2]
|
|
376
|
+
|
|
377
|
+
**Performance Score: [X/100]**
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## SESSION STATE UPDATE
|
|
383
|
+
|
|
384
|
+
After audit, update `session-state/CURRENT.md`:
|
|
385
|
+
|
|
386
|
+
```markdown
|
|
387
|
+
## PERF AUDIT SESSION
|
|
388
|
+
|
|
389
|
+
### Audit
|
|
390
|
+
- **Date**: [timestamp]
|
|
391
|
+
- **Scope**: [DB/Bundle/Rendering/API/All]
|
|
392
|
+
|
|
393
|
+
### Findings
|
|
394
|
+
- Database: [N] issues
|
|
395
|
+
- Bundle: [N] issues
|
|
396
|
+
- Rendering: [N] issues
|
|
397
|
+
- API: [N] issues
|
|
398
|
+
|
|
399
|
+
### Optimizations Applied
|
|
400
|
+
[List or "None - audit only"]
|
|
401
|
+
|
|
402
|
+
### Metrics
|
|
403
|
+
| Metric | Before | After | Improvement |
|
|
404
|
+
|--------|--------|-------|-------------|
|
|
405
|
+
| [metric] | X | Y | Z% |
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## START NOW
|
|
411
|
+
|
|
412
|
+
1. Run Section 1: Database Performance
|
|
413
|
+
2. Run Section 2: Bundle Size Analysis
|
|
414
|
+
3. Run Section 3: Rendering Performance
|
|
415
|
+
4. Run Section 4: API Performance
|
|
416
|
+
5. Run Section 5: Network Optimization
|
|
417
|
+
6. Identify top issues by impact
|
|
418
|
+
7. Prioritize optimizations
|
|
419
|
+
8. Produce performance report
|
|
420
|
+
9. Update session state
|
|
421
|
+
|
|
422
|
+
**Remember: Measure -> Optimize -> Measure. No guessing.**
|
|
@@ -29,7 +29,7 @@ This command COMBINES /massu-create-plan + /massu-plan into ONE uninterrupted fl
|
|
|
29
29
|
### Phase A: Plan Creation
|
|
30
30
|
1. Parse $ARGUMENTS as task description
|
|
31
31
|
2. Follow massu-create-plan Phase 1-6 (requirements, DB check, codebase check, patterns, security, generation)
|
|
32
|
-
3. Write plan document to
|
|
32
|
+
3. Write plan document to `docs/plans/[date]-[name].md`
|
|
33
33
|
4. Do NOT present plan to user yet — proceed directly to Phase B
|
|
34
34
|
|
|
35
35
|
### Phase B: Audit Loop (IMMEDIATE — no pause)
|