cp-toolkit 2.2.2 → 2.2.4

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 (71) hide show
  1. package/package.json +1 -1
  2. package/src/commands/add.js +23 -16
  3. package/src/commands/doctor.js +15 -10
  4. package/src/commands/init.js +410 -64
  5. package/templates/AGENTS.md +47 -0
  6. package/templates/ARCHITECTURE.md +42 -0
  7. package/templates/agents/backend-specialist.md +1 -0
  8. package/templates/agents/code-archaeologist.md +116 -106
  9. package/templates/agents/database-architect.md +1 -0
  10. package/templates/agents/debugger.md +1 -0
  11. package/templates/agents/devops-engineer.md +1 -0
  12. package/templates/agents/documentation-writer.md +1 -0
  13. package/templates/agents/explorer-agent.md +83 -73
  14. package/templates/agents/frontend-specialist.md +1 -0
  15. package/templates/agents/game-developer.md +1 -0
  16. package/templates/agents/mobile-developer.md +1 -0
  17. package/templates/agents/orchestrator.md +426 -416
  18. package/templates/agents/penetration-tester.md +1 -0
  19. package/templates/agents/performance-optimizer.md +1 -0
  20. package/templates/agents/product-manager.md +122 -112
  21. package/templates/agents/product-owner.md +105 -95
  22. package/templates/agents/project-planner.md +416 -406
  23. package/templates/agents/qa-automation-engineer.md +113 -103
  24. package/templates/agents/security-auditor.md +1 -0
  25. package/templates/agents/seo-specialist.md +1 -0
  26. package/templates/agents/test-engineer.md +1 -0
  27. package/templates/skills/core/behavioral-modes/SKILL.md +244 -242
  28. package/templates/skills/core/brainstorming/SKILL.md +166 -163
  29. package/templates/skills/core/mcp-builder/SKILL.md +178 -176
  30. package/templates/skills/core/parallel-agents/SKILL.md +187 -175
  31. package/templates/skills/core/plan-writing/SKILL.md +154 -152
  32. package/templates/skills/optional/api-patterns/SKILL.md +83 -81
  33. package/templates/skills/optional/app-builder/SKILL.md +78 -75
  34. package/templates/skills/optional/app-builder/templates/SKILL.md +41 -39
  35. package/templates/skills/optional/architecture/SKILL.md +58 -55
  36. package/templates/skills/optional/bash-linux/SKILL.md +201 -199
  37. package/templates/skills/optional/code-review-checklist/SKILL.md +110 -109
  38. package/templates/skills/optional/database-design/SKILL.md +54 -52
  39. package/templates/skills/optional/deployment-procedures/SKILL.md +243 -241
  40. package/templates/skills/optional/documentation-templates/SKILL.md +196 -194
  41. package/templates/skills/optional/frontend-design/SKILL.md +421 -418
  42. package/templates/skills/optional/game-development/2d-games/SKILL.md +120 -119
  43. package/templates/skills/optional/game-development/3d-games/SKILL.md +136 -135
  44. package/templates/skills/optional/game-development/SKILL.md +169 -167
  45. package/templates/skills/optional/game-development/game-art/SKILL.md +187 -185
  46. package/templates/skills/optional/game-development/game-audio/SKILL.md +192 -190
  47. package/templates/skills/optional/game-development/game-design/SKILL.md +131 -129
  48. package/templates/skills/optional/game-development/mobile-games/SKILL.md +110 -108
  49. package/templates/skills/optional/game-development/multiplayer/SKILL.md +133 -132
  50. package/templates/skills/optional/game-development/pc-games/SKILL.md +146 -144
  51. package/templates/skills/optional/game-development/vr-ar/SKILL.md +124 -123
  52. package/templates/skills/optional/game-development/web-games/SKILL.md +152 -150
  53. package/templates/skills/optional/geo-fundamentals/SKILL.md +158 -156
  54. package/templates/skills/optional/i18n-localization/SKILL.md +156 -154
  55. package/templates/skills/optional/lint-and-validate/SKILL.md +48 -45
  56. package/templates/skills/optional/mobile-design/SKILL.md +397 -394
  57. package/templates/skills/optional/nextjs-react-expert/SKILL.md +271 -267
  58. package/templates/skills/optional/nodejs-best-practices/SKILL.md +335 -333
  59. package/templates/skills/optional/performance-profiling/SKILL.md +145 -143
  60. package/templates/skills/optional/powershell-windows/SKILL.md +169 -167
  61. package/templates/skills/optional/python-patterns/SKILL.md +443 -441
  62. package/templates/skills/optional/red-team-tactics/SKILL.md +201 -199
  63. package/templates/skills/optional/seo-fundamentals/SKILL.md +130 -129
  64. package/templates/skills/optional/server-management/SKILL.md +163 -161
  65. package/templates/skills/optional/systematic-debugging/SKILL.md +111 -109
  66. package/templates/skills/optional/tailwind-patterns/SKILL.md +271 -269
  67. package/templates/skills/optional/tdd-workflow/SKILL.md +150 -149
  68. package/templates/skills/optional/testing-patterns/SKILL.md +179 -178
  69. package/templates/skills/optional/vulnerability-scanner/SKILL.md +278 -276
  70. package/templates/skills/optional/web-design-guidelines/SKILL.md +60 -57
  71. package/templates/skills/optional/webapp-testing/SKILL.md +188 -187
@@ -1,267 +1,271 @@
1
- ---
2
- name: nextjs-react-expert
3
- description: React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.
4
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash
5
- ---
6
-
7
- # Next.js & React Performance Expert
8
-
9
- > **From Vercel Engineering** - 57 optimization rules prioritized by impact
10
- > **Philosophy:** Eliminate waterfalls first, optimize bundles second, then micro-optimize.
11
-
12
- ---
13
-
14
- ## 🎯 Selective Reading Rule (MANDATORY)
15
-
16
- **Read ONLY sections relevant to your task!** Check the content map below and load what you need.
17
-
18
- > 🔴 **For performance reviews: Start with CRITICAL sections (1-2), then move to HIGH/MEDIUM.**
19
-
20
- ---
21
-
22
- ## 📑 Content Map
23
-
24
- | File | Impact | Rules | When to Read |
25
- |------|--------|-------|--------------|
26
- | `1-async-eliminating-waterfalls.md` | 🔴 **CRITICAL** | 5 rules | Slow page loads, sequential API calls, data fetching waterfalls |
27
- | `2-bundle-bundle-size-optimization.md` | 🔴 **CRITICAL** | 5 rules | Large bundle size, slow Time to Interactive, First Load issues |
28
- | `3-server-server-side-performance.md` | 🟠 **HIGH** | 7 rules | Slow SSR, API route optimization, server-side waterfalls |
29
- | `4-client-client-side-data-fetching.md` | 🟡 **MEDIUM-HIGH** | 4 rules | Client data management, SWR patterns, deduplication |
30
- | `5-rerender-re-render-optimization.md` | 🟡 **MEDIUM** | 12 rules | Excessive re-renders, React performance, memoization |
31
- | `6-rendering-rendering-performance.md` | 🟡 **MEDIUM** | 9 rules | Rendering bottlenecks, virtualization, image optimization |
32
- | `7-js-javascript-performance.md` | **LOW-MEDIUM** | 12 rules | Micro-optimizations, caching, loop performance |
33
- | `8-advanced-advanced-patterns.md` | 🔵 **VARIABLE** | 3 rules | Advanced React patterns, useLatest, init-once |
34
-
35
- **Total: 57 rules across 8 categories**
36
-
37
- ---
38
-
39
- ## 🚀 Quick Decision Tree
40
-
41
- **What's your performance issue?**
42
-
43
- ```
44
- 🐌 Slow page loads / Long Time to Interactive
45
- Read Section 1: Eliminating Waterfalls
46
- → Read Section 2: Bundle Size Optimization
47
-
48
- 📦 Large bundle size (> 200KB)
49
- → Read Section 2: Bundle Size Optimization
50
- Check: Dynamic imports, barrel imports, tree-shaking
51
-
52
- 🖥️ Slow Server-Side Rendering
53
- → Read Section 3: Server-Side Performance
54
- → Check: Parallel data fetching, streaming
55
-
56
- 🔄 Too many re-renders / UI lag
57
- → Read Section 5: Re-render Optimization
58
- → Check: React.memo, useMemo, useCallback
59
-
60
- 🎨 Rendering performance issues
61
- → Read Section 6: Rendering Performance
62
- → Check: Virtualization, layout thrashing
63
-
64
- 🌐 Client-side data fetching problems
65
- → Read Section 4: Client-Side Data Fetching
66
- → Check: SWR deduplication, localStorage
67
-
68
- Need advanced patterns
69
- → Read Section 8: Advanced Patterns
70
- ```
71
-
72
- ---
73
-
74
- ## 📊 Impact Priority Guide
75
-
76
- **Use this order when doing comprehensive optimization:**
77
-
78
- ```
79
- 1️⃣ CRITICAL (Biggest Gains - Do First):
80
- ├─ Section 1: Eliminating Waterfalls
81
- │ └─ Each waterfall adds full network latency (100-500ms+)
82
- └─ Section 2: Bundle Size Optimization
83
- └─ Affects Time to Interactive and Largest Contentful Paint
84
-
85
- 2️⃣ HIGH (Significant Impact - Do Second):
86
- └─ Section 3: Server-Side Performance
87
- └─ Eliminates server-side waterfalls, faster response times
88
-
89
- 3️⃣ MEDIUM (Moderate Gains - Do Third):
90
- ├─ Section 4: Client-Side Data Fetching
91
- ├─ Section 5: Re-render Optimization
92
- └─ Section 6: Rendering Performance
93
-
94
- 4️⃣ LOW (Polish - Do Last):
95
- ├─ Section 7: JavaScript Performance
96
- └─ Section 8: Advanced Patterns
97
- ```
98
-
99
- ---
100
-
101
- ## 🔗 Related Skills
102
-
103
- | Need | Skill |
104
- |------|-------|
105
- | API design patterns | `@[skills/api-patterns]` |
106
- | Database optimization | `@[skills/database-design]` |
107
- | Testing strategies | `@[skills/testing-patterns]` |
108
- | UI/UX design principles | `@[skills/frontend-design]` |
109
- | TypeScript patterns | `@[skills/typescript-expert]` |
110
- | Deployment & DevOps | `@[skills/deployment-procedures]` |
111
-
112
- ---
113
-
114
- ## Performance Review Checklist
115
-
116
- Before shipping to production:
117
-
118
- **Critical (Must Fix):**
119
- - [ ] No sequential data fetching (waterfalls eliminated)
120
- - [ ] Bundle size < 200KB for main bundle
121
- - [ ] No barrel imports in app code
122
- - [ ] Dynamic imports used for large components
123
- - [ ] Parallel data fetching where possible
124
-
125
- **High Priority:**
126
- - [ ] Server components used where appropriate
127
- - [ ] API routes optimized (no N+1 queries)
128
- - [ ] Suspense boundaries for data fetching
129
- - [ ] Static generation used where possible
130
-
131
- **Medium Priority:**
132
- - [ ] Expensive computations memoized
133
- - [ ] List rendering virtualized (if > 100 items)
134
- - [ ] Images optimized with next/image
135
- - [ ] No unnecessary re-renders
136
-
137
- **Low Priority (Polish):**
138
- - [ ] Hot path loops optimized
139
- - [ ] RegExp patterns hoisted
140
- - [ ] Property access cached in loops
141
-
142
- ---
143
-
144
- ## Anti-Patterns (Common Mistakes)
145
-
146
- **DON'T:**
147
- - ❌ Use sequential `await` for independent operations
148
- -Import entire libraries when you need one function
149
- - ❌ Use barrel exports (`index.ts` re-exports) in app code
150
- - ❌ Skip dynamic imports for large components/libraries
151
- - ❌ Fetch data in useEffect without deduplication
152
- - ❌ Forget to memoize expensive computations
153
- - ❌ Use client components when server components work
154
-
155
- **DO:**
156
- - Fetch data in parallel with `Promise.all()`
157
- - Use dynamic imports: `const Comp = dynamic(() => import('./Heavy'))`
158
- - ✅ Import directly: `import { specific } from 'library/specific'`
159
- - ✅ Use Suspense boundaries for better UX
160
- - ✅ Leverage React Server Components
161
- - ✅ Measure performance before optimizing
162
- - ✅ Use Next.js built-in optimizations (next/image, next/font)
163
-
164
- ---
165
-
166
- ## 🎯 How to Use This Skill
167
-
168
- ### For New Features:
169
- 1. Check **Section 1 & 2** while building (prevent waterfalls, keep bundle small)
170
- 2. Use server components by default (Section 3)
171
- 3. Apply memoization for expensive operations (Section 5)
172
-
173
- ### For Performance Reviews:
174
- 1. Start with **Section 1** (waterfalls = biggest impact)
175
- 2. Then **Section 2** (bundle size)
176
- 3. Then **Section 3** (server-side)
177
- 4. Finally other sections as needed
178
-
179
- ### For Debugging Slow Performance:
180
- 1. Identify the symptom (slow load, lag, etc.)
181
- 2. Use Quick Decision Tree above
182
- 3. Read relevant section
183
- 4. Apply fixes in priority order
184
-
185
- ---
186
-
187
- ## 📚 Learning Path
188
-
189
- **Beginner (Focus on Critical):**
190
- → Section 1: Eliminating Waterfalls
191
- Section 2: Bundle Size Optimization
192
-
193
- **Intermediate (Add High Priority):**
194
- → Section 3: Server-Side Performance
195
- → Section 5: Re-render Optimization
196
-
197
- **Advanced (Full Optimization):**
198
- All sections + Section 8: Advanced Patterns
199
-
200
- ---
201
-
202
- ## 🔍 Validation Script
203
-
204
- | Script | Purpose | Command |
205
- |--------|---------|---------|
206
- | `scripts/react_performance_checker.py` | Automated performance audit | `python scripts/react_performance_checker.py <project_path>` |
207
-
208
- ---
209
-
210
- ## 📖 Section Details
211
-
212
- ### Section 1: Eliminating Waterfalls (CRITICAL)
213
- **Impact:** Each waterfall adds 100-500ms+ latency
214
- **Key Concepts:** Parallel fetching, Promise.all(), Suspense boundaries, preloading
215
-
216
- ### Section 2: Bundle Size Optimization (CRITICAL)
217
- **Impact:** Directly affects Time to Interactive, Largest Contentful Paint
218
- **Key Concepts:** Dynamic imports, tree-shaking, barrel import avoidance
219
-
220
- ### Section 3: Server-Side Performance (HIGH)
221
- **Impact:** Faster server responses, better SEO
222
- **Key Concepts:** Parallel server fetching, streaming, API route optimization
223
-
224
- ### Section 4: Client-Side Data Fetching (MEDIUM-HIGH)
225
- **Impact:** Reduces redundant requests, better UX
226
- **Key Concepts:** SWR deduplication, localStorage caching, event listeners
227
-
228
- ### Section 5: Re-render Optimization (MEDIUM)
229
- **Impact:** Smoother UI, less wasted computation
230
- **Key Concepts:** React.memo, useMemo, useCallback, component structure
231
-
232
- ### Section 6: Rendering Performance (MEDIUM)
233
- **Impact:** Better rendering efficiency
234
- **Key Concepts:** Virtualization, image optimization, layout thrashing
235
-
236
- ### Section 7: JavaScript Performance (LOW-MEDIUM)
237
- **Impact:** Incremental improvements in hot paths
238
- **Key Concepts:** Loop optimization, caching, RegExp hoisting
239
-
240
- ### Section 8: Advanced Patterns (VARIABLE)
241
- **Impact:** Specific use cases
242
- **Key Concepts:** useLatest hook, init-once patterns, event handler refs
243
-
244
- ---
245
-
246
- ## 🎓 Best Practices Summary
247
-
248
- **Golden Rules:**
249
- 1. **Measure first** - Use React DevTools Profiler, Chrome DevTools
250
- 2. **Biggest impact first** - Waterfalls → Bundle → Server → Micro
251
- 3. **Don't over-optimize** - Focus on real bottlenecks
252
- 4. **Use platform features** - Next.js has optimizations built-in
253
- 5. **Think about users** - Real-world conditions matter
254
-
255
- **Performance Mindset:**
256
- - Every `await` in sequence = potential waterfall
257
- - Every `import` = potential bundle bloat
258
- - Every re-render = wasted computation (if unnecessary)
259
- - Server components = less JavaScript to ship
260
- - Measure, don't guess
261
-
262
- ---
263
-
264
- **Source:** Vercel Engineering
265
- **Date:** January 2026
266
- **Version:** 1.0.0
267
- **Total Rules:** 57 across 8 categories
1
+ ---
2
+ name: nextjs-react-expert
3
+ description: React and Next.js performance optimization from Vercel Engineering. Use
4
+ when building React components, optimizing performance, eliminating waterfalls,
5
+ reducing bundle size, reviewing code for performance issues, or implementing server/client-side
6
+ optimizations.
7
+ allowed-tools: Read, Write, Edit, Glob, Grep, Bash
8
+ version: '1.0'
9
+ ---
10
+
11
+ # Next.js & React Performance Expert
12
+
13
+ > **From Vercel Engineering** - 57 optimization rules prioritized by impact
14
+ > **Philosophy:** Eliminate waterfalls first, optimize bundles second, then micro-optimize.
15
+
16
+ ---
17
+
18
+ ## 🎯 Selective Reading Rule (MANDATORY)
19
+
20
+ **Read ONLY sections relevant to your task!** Check the content map below and load what you need.
21
+
22
+ > 🔴 **For performance reviews: Start with CRITICAL sections (1-2), then move to HIGH/MEDIUM.**
23
+
24
+ ---
25
+
26
+ ## 📑 Content Map
27
+
28
+ | File | Impact | Rules | When to Read |
29
+ |------|--------|-------|--------------|
30
+ | `1-async-eliminating-waterfalls.md` | 🔴 **CRITICAL** | 5 rules | Slow page loads, sequential API calls, data fetching waterfalls |
31
+ | `2-bundle-bundle-size-optimization.md` | 🔴 **CRITICAL** | 5 rules | Large bundle size, slow Time to Interactive, First Load issues |
32
+ | `3-server-server-side-performance.md` | 🟠 **HIGH** | 7 rules | Slow SSR, API route optimization, server-side waterfalls |
33
+ | `4-client-client-side-data-fetching.md` | 🟡 **MEDIUM-HIGH** | 4 rules | Client data management, SWR patterns, deduplication |
34
+ | `5-rerender-re-render-optimization.md` | 🟡 **MEDIUM** | 12 rules | Excessive re-renders, React performance, memoization |
35
+ | `6-rendering-rendering-performance.md` | 🟡 **MEDIUM** | 9 rules | Rendering bottlenecks, virtualization, image optimization |
36
+ | `7-js-javascript-performance.md` | ⚪ **LOW-MEDIUM** | 12 rules | Micro-optimizations, caching, loop performance |
37
+ | `8-advanced-advanced-patterns.md` | 🔵 **VARIABLE** | 3 rules | Advanced React patterns, useLatest, init-once |
38
+
39
+ **Total: 57 rules across 8 categories**
40
+
41
+ ---
42
+
43
+ ## 🚀 Quick Decision Tree
44
+
45
+ **What's your performance issue?**
46
+
47
+ ```
48
+ 🐌 Slow page loads / Long Time to Interactive
49
+ → Read Section 1: Eliminating Waterfalls
50
+ Read Section 2: Bundle Size Optimization
51
+
52
+ 📦 Large bundle size (> 200KB)
53
+ → Read Section 2: Bundle Size Optimization
54
+ → Check: Dynamic imports, barrel imports, tree-shaking
55
+
56
+ 🖥️ Slow Server-Side Rendering
57
+ → Read Section 3: Server-Side Performance
58
+ → Check: Parallel data fetching, streaming
59
+
60
+ 🔄 Too many re-renders / UI lag
61
+ → Read Section 5: Re-render Optimization
62
+ → Check: React.memo, useMemo, useCallback
63
+
64
+ 🎨 Rendering performance issues
65
+ → Read Section 6: Rendering Performance
66
+ → Check: Virtualization, layout thrashing
67
+
68
+ 🌐 Client-side data fetching problems
69
+ → Read Section 4: Client-Side Data Fetching
70
+ → Check: SWR deduplication, localStorage
71
+
72
+ ✨ Need advanced patterns
73
+ → Read Section 8: Advanced Patterns
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 📊 Impact Priority Guide
79
+
80
+ **Use this order when doing comprehensive optimization:**
81
+
82
+ ```
83
+ 1️⃣ CRITICAL (Biggest Gains - Do First):
84
+ ├─ Section 1: Eliminating Waterfalls
85
+ │ └─ Each waterfall adds full network latency (100-500ms+)
86
+ └─ Section 2: Bundle Size Optimization
87
+ └─ Affects Time to Interactive and Largest Contentful Paint
88
+
89
+ 2️⃣ HIGH (Significant Impact - Do Second):
90
+ └─ Section 3: Server-Side Performance
91
+ └─ Eliminates server-side waterfalls, faster response times
92
+
93
+ 3️⃣ MEDIUM (Moderate Gains - Do Third):
94
+ ├─ Section 4: Client-Side Data Fetching
95
+ ├─ Section 5: Re-render Optimization
96
+ └─ Section 6: Rendering Performance
97
+
98
+ 4️⃣ LOW (Polish - Do Last):
99
+ ├─ Section 7: JavaScript Performance
100
+ └─ Section 8: Advanced Patterns
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 🔗 Related Skills
106
+
107
+ | Need | Skill |
108
+ |------|-------|
109
+ | API design patterns | `@[skills/api-patterns]` |
110
+ | Database optimization | `@[skills/database-design]` |
111
+ | Testing strategies | `@[skills/testing-patterns]` |
112
+ | UI/UX design principles | `@[skills/frontend-design]` |
113
+ | TypeScript patterns | `@[skills/typescript-expert]` |
114
+ | Deployment & DevOps | `@[skills/deployment-procedures]` |
115
+
116
+ ---
117
+
118
+ ## Performance Review Checklist
119
+
120
+ Before shipping to production:
121
+
122
+ **Critical (Must Fix):**
123
+ - [ ] No sequential data fetching (waterfalls eliminated)
124
+ - [ ] Bundle size < 200KB for main bundle
125
+ - [ ] No barrel imports in app code
126
+ - [ ] Dynamic imports used for large components
127
+ - [ ] Parallel data fetching where possible
128
+
129
+ **High Priority:**
130
+ - [ ] Server components used where appropriate
131
+ - [ ] API routes optimized (no N+1 queries)
132
+ - [ ] Suspense boundaries for data fetching
133
+ - [ ] Static generation used where possible
134
+
135
+ **Medium Priority:**
136
+ - [ ] Expensive computations memoized
137
+ - [ ] List rendering virtualized (if > 100 items)
138
+ - [ ] Images optimized with next/image
139
+ - [ ] No unnecessary re-renders
140
+
141
+ **Low Priority (Polish):**
142
+ - [ ] Hot path loops optimized
143
+ - [ ] RegExp patterns hoisted
144
+ - [ ] Property access cached in loops
145
+
146
+ ---
147
+
148
+ ##Anti-Patterns (Common Mistakes)
149
+
150
+ **DON'T:**
151
+ - ❌ Use sequential `await` for independent operations
152
+ - ❌ Import entire libraries when you need one function
153
+ - ❌ Use barrel exports (`index.ts` re-exports) in app code
154
+ - ❌ Skip dynamic imports for large components/libraries
155
+ - ❌ Fetch data in useEffect without deduplication
156
+ - Forget to memoize expensive computations
157
+ - Use client components when server components work
158
+
159
+ **DO:**
160
+ - ✅ Fetch data in parallel with `Promise.all()`
161
+ - ✅ Use dynamic imports: `const Comp = dynamic(() => import('./Heavy'))`
162
+ - ✅ Import directly: `import { specific } from 'library/specific'`
163
+ - ✅ Use Suspense boundaries for better UX
164
+ - ✅ Leverage React Server Components
165
+ - ✅ Measure performance before optimizing
166
+ - Use Next.js built-in optimizations (next/image, next/font)
167
+
168
+ ---
169
+
170
+ ## 🎯 How to Use This Skill
171
+
172
+ ### For New Features:
173
+ 1. Check **Section 1 & 2** while building (prevent waterfalls, keep bundle small)
174
+ 2. Use server components by default (Section 3)
175
+ 3. Apply memoization for expensive operations (Section 5)
176
+
177
+ ### For Performance Reviews:
178
+ 1. Start with **Section 1** (waterfalls = biggest impact)
179
+ 2. Then **Section 2** (bundle size)
180
+ 3. Then **Section 3** (server-side)
181
+ 4. Finally other sections as needed
182
+
183
+ ### For Debugging Slow Performance:
184
+ 1. Identify the symptom (slow load, lag, etc.)
185
+ 2. Use Quick Decision Tree above
186
+ 3. Read relevant section
187
+ 4. Apply fixes in priority order
188
+
189
+ ---
190
+
191
+ ## 📚 Learning Path
192
+
193
+ **Beginner (Focus on Critical):**
194
+ → Section 1: Eliminating Waterfalls
195
+ → Section 2: Bundle Size Optimization
196
+
197
+ **Intermediate (Add High Priority):**
198
+ → Section 3: Server-Side Performance
199
+ → Section 5: Re-render Optimization
200
+
201
+ **Advanced (Full Optimization):**
202
+ All sections + Section 8: Advanced Patterns
203
+
204
+ ---
205
+
206
+ ## 🔍 Validation Script
207
+
208
+ | Script | Purpose | Command |
209
+ |--------|---------|---------|
210
+ | `scripts/react_performance_checker.py` | Automated performance audit | `python scripts/react_performance_checker.py <project_path>` |
211
+
212
+ ---
213
+
214
+ ## 📖 Section Details
215
+
216
+ ### Section 1: Eliminating Waterfalls (CRITICAL)
217
+ **Impact:** Each waterfall adds 100-500ms+ latency
218
+ **Key Concepts:** Parallel fetching, Promise.all(), Suspense boundaries, preloading
219
+
220
+ ### Section 2: Bundle Size Optimization (CRITICAL)
221
+ **Impact:** Directly affects Time to Interactive, Largest Contentful Paint
222
+ **Key Concepts:** Dynamic imports, tree-shaking, barrel import avoidance
223
+
224
+ ### Section 3: Server-Side Performance (HIGH)
225
+ **Impact:** Faster server responses, better SEO
226
+ **Key Concepts:** Parallel server fetching, streaming, API route optimization
227
+
228
+ ### Section 4: Client-Side Data Fetching (MEDIUM-HIGH)
229
+ **Impact:** Reduces redundant requests, better UX
230
+ **Key Concepts:** SWR deduplication, localStorage caching, event listeners
231
+
232
+ ### Section 5: Re-render Optimization (MEDIUM)
233
+ **Impact:** Smoother UI, less wasted computation
234
+ **Key Concepts:** React.memo, useMemo, useCallback, component structure
235
+
236
+ ### Section 6: Rendering Performance (MEDIUM)
237
+ **Impact:** Better rendering efficiency
238
+ **Key Concepts:** Virtualization, image optimization, layout thrashing
239
+
240
+ ### Section 7: JavaScript Performance (LOW-MEDIUM)
241
+ **Impact:** Incremental improvements in hot paths
242
+ **Key Concepts:** Loop optimization, caching, RegExp hoisting
243
+
244
+ ### Section 8: Advanced Patterns (VARIABLE)
245
+ **Impact:** Specific use cases
246
+ **Key Concepts:** useLatest hook, init-once patterns, event handler refs
247
+
248
+ ---
249
+
250
+ ## 🎓 Best Practices Summary
251
+
252
+ **Golden Rules:**
253
+ 1. **Measure first** - Use React DevTools Profiler, Chrome DevTools
254
+ 2. **Biggest impact first** - Waterfalls → Bundle → Server → Micro
255
+ 3. **Don't over-optimize** - Focus on real bottlenecks
256
+ 4. **Use platform features** - Next.js has optimizations built-in
257
+ 5. **Think about users** - Real-world conditions matter
258
+
259
+ **Performance Mindset:**
260
+ - Every `await` in sequence = potential waterfall
261
+ - Every `import` = potential bundle bloat
262
+ - Every re-render = wasted computation (if unnecessary)
263
+ - Server components = less JavaScript to ship
264
+ - Measure, don't guess
265
+
266
+ ---
267
+
268
+ **Source:** Vercel Engineering
269
+ **Date:** January 2026
270
+ **Version:** 1.0.0
271
+ **Total Rules:** 57 across 8 categories