@vudovn/antigravity-kit 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +311 -0
  2. package/bin/index.js +240 -0
  3. package/package.json +39 -0
  4. package/templates/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  5. package/templates/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  6. package/templates/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  7. package/templates/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  8. package/templates/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  9. package/templates/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  10. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  11. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  12. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  13. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  14. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  15. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  16. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  17. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  18. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  19. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  20. package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  21. package/templates/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  22. package/templates/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  23. package/templates/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/templates/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
  25. package/templates/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/templates/.agent/.shared/ui-ux-pro-max/scripts/core.py +245 -0
  27. package/templates/.agent/.shared/ui-ux-pro-max/scripts/search.py +69 -0
  28. package/templates/.agent/rules/01-identity.md +17 -0
  29. package/templates/.agent/rules/02-task-classification.md +36 -0
  30. package/templates/.agent/rules/03-mode-consulting.md +54 -0
  31. package/templates/.agent/rules/04-mode-build.md +54 -0
  32. package/templates/.agent/rules/05-mode-debug.md +66 -0
  33. package/templates/.agent/rules/06-mode-optimize.md +64 -0
  34. package/templates/.agent/rules/07-technical-standards.md +61 -0
  35. package/templates/.agent/rules/08-communication.md +34 -0
  36. package/templates/.agent/rules/09-checklist.md +45 -0
  37. package/templates/.agent/rules/10-special-situations.md +81 -0
  38. package/templates/.agent/skills/accessibility-expert/SKILL.md +430 -0
  39. package/templates/.agent/skills/ai-sdk-expert/SKILL.md +541 -0
  40. package/templates/.agent/skills/auth-expert/SKILL.md +105 -0
  41. package/templates/.agent/skills/cli-expert/SKILL.md +848 -0
  42. package/templates/.agent/skills/code-review/SKILL.md +424 -0
  43. package/templates/.agent/skills/css-expert/SKILL.md +401 -0
  44. package/templates/.agent/skills/database-expert/SKILL.md +324 -0
  45. package/templates/.agent/skills/devops-expert/SKILL.md +784 -0
  46. package/templates/.agent/skills/docker-expert/SKILL.md +409 -0
  47. package/templates/.agent/skills/documentation-expert/SKILL.md +493 -0
  48. package/templates/.agent/skills/git-expert/SKILL.md +522 -0
  49. package/templates/.agent/skills/github-actions-expert/SKILL.md +454 -0
  50. package/templates/.agent/skills/jest-expert/SKILL.md +957 -0
  51. package/templates/.agent/skills/mongodb-expert/SKILL.md +761 -0
  52. package/templates/.agent/skills/nestjs-expert/SKILL.md +552 -0
  53. package/templates/.agent/skills/nextjs-expert/SKILL.md +443 -0
  54. package/templates/.agent/skills/nodejs-expert/SKILL.md +192 -0
  55. package/templates/.agent/skills/oracle/SKILL.md +340 -0
  56. package/templates/.agent/skills/playwright-expert/SKILL.md +214 -0
  57. package/templates/.agent/skills/postgres-expert/SKILL.md +642 -0
  58. package/templates/.agent/skills/prisma-expert/SKILL.md +355 -0
  59. package/templates/.agent/skills/react-expert/SKILL.md +310 -0
  60. package/templates/.agent/skills/react-performance/SKILL.md +816 -0
  61. package/templates/.agent/skills/refactoring-expert/SKILL.md +394 -0
  62. package/templates/.agent/skills/research-expert/SKILL.md +231 -0
  63. package/templates/.agent/skills/rest-api-expert/SKILL.md +469 -0
  64. package/templates/.agent/skills/state-management-expert/SKILL.md +157 -0
  65. package/templates/.agent/skills/testing-expert/SKILL.md +621 -0
  66. package/templates/.agent/skills/triage-expert/SKILL.md +419 -0
  67. package/templates/.agent/skills/typescript-expert/SKILL.md +429 -0
  68. package/templates/.agent/skills/typescript-type/SKILL.md +790 -0
  69. package/templates/.agent/skills/ui-ux-pro-max/SKILL.md +228 -0
  70. package/templates/.agent/skills/vite-expert/SKILL.md +785 -0
  71. package/templates/.agent/skills/vitest-expert/SKILL.md +325 -0
  72. package/templates/.agent/skills/webpack-expert/SKILL.md +745 -0
  73. package/templates/.agent/workflows/request.md +82 -0
  74. package/templates/.agent/workflows/ui-ux-pro-max.md +231 -0
  75. package/templates/web/README.md +36 -0
  76. package/templates/web/eslint.config.mjs +18 -0
  77. package/templates/web/next.config.ts +8 -0
  78. package/templates/web/package-lock.json +6549 -0
  79. package/templates/web/package.json +27 -0
  80. package/templates/web/postcss.config.mjs +7 -0
  81. package/templates/web/public/favicon.ico +0 -0
  82. package/templates/web/public/images/antigravity-kit-logo.png +0 -0
  83. package/templates/web/public/images/claudekit.png +0 -0
  84. package/templates/web/public/images/logo.png +0 -0
  85. package/templates/web/src/app/globals.css +276 -0
  86. package/templates/web/src/app/layout.tsx +55 -0
  87. package/templates/web/src/app/page.tsx +23 -0
  88. package/templates/web/src/components/Credits.tsx +162 -0
  89. package/templates/web/src/components/Features.tsx +92 -0
  90. package/templates/web/src/components/Footer.tsx +74 -0
  91. package/templates/web/src/components/Hero.tsx +117 -0
  92. package/templates/web/src/components/HowItWorks.tsx +96 -0
  93. package/templates/web/src/components/Navbar.tsx +87 -0
  94. package/templates/web/src/components/Skills.tsx +182 -0
  95. package/templates/web/tsconfig.json +34 -0
@@ -0,0 +1,355 @@
1
+ ---
2
+ name: prisma-expert
3
+ description: Prisma ORM expert for schema design, migrations, query optimization, relations modeling, and database operations. Use PROACTIVELY for Prisma schema issues, migration problems, query performance, relation design, or database connection issues.
4
+ ---
5
+
6
+ # Prisma Expert
7
+
8
+ You are an expert in Prisma ORM with deep knowledge of schema design, migrations, query optimization, relations modeling, and database operations across PostgreSQL, MySQL, and SQLite.
9
+
10
+ ## When Invoked
11
+
12
+ ### Step 0: Recommend Specialist and Stop
13
+ If the issue is specifically about:
14
+ - **Raw SQL optimization**: Stop and recommend postgres-expert or mongodb-expert
15
+ - **Database server configuration**: Stop and recommend database-expert
16
+ - **Connection pooling at infrastructure level**: Stop and recommend devops-expert
17
+
18
+ ### Environment Detection
19
+ ```bash
20
+ # Check Prisma version
21
+ npx prisma --version 2>/dev/null || echo "Prisma not installed"
22
+
23
+ # Check database provider
24
+ grep "provider" prisma/schema.prisma 2>/dev/null | head -1
25
+
26
+ # Check for existing migrations
27
+ ls -la prisma/migrations/ 2>/dev/null | head -5
28
+
29
+ # Check Prisma Client generation status
30
+ ls -la node_modules/.prisma/client/ 2>/dev/null | head -3
31
+ ```
32
+
33
+ ### Apply Strategy
34
+ 1. Identify the Prisma-specific issue category
35
+ 2. Check for common anti-patterns in schema or queries
36
+ 3. Apply progressive fixes (minimal → better → complete)
37
+ 4. Validate with Prisma CLI and testing
38
+
39
+ ## Problem Playbooks
40
+
41
+ ### Schema Design
42
+ **Common Issues:**
43
+ - Incorrect relation definitions causing runtime errors
44
+ - Missing indexes for frequently queried fields
45
+ - Enum synchronization issues between schema and database
46
+ - Field type mismatches
47
+
48
+ **Diagnosis:**
49
+ ```bash
50
+ # Validate schema
51
+ npx prisma validate
52
+
53
+ # Check for schema drift
54
+ npx prisma migrate diff --from-schema-datamodel prisma/schema.prisma --to-schema-datasource prisma/schema.prisma
55
+
56
+ # Format schema
57
+ npx prisma format
58
+ ```
59
+
60
+ **Prioritized Fixes:**
61
+ 1. **Minimal**: Fix relation annotations, add missing `@relation` directives
62
+ 2. **Better**: Add proper indexes with `@@index`, optimize field types
63
+ 3. **Complete**: Restructure schema with proper normalization, add composite keys
64
+
65
+ **Best Practices:**
66
+ ```prisma
67
+ // Good: Explicit relations with clear naming
68
+ model User {
69
+ id String @id @default(cuid())
70
+ email String @unique
71
+ posts Post[] @relation("UserPosts")
72
+ profile Profile? @relation("UserProfile")
73
+
74
+ createdAt DateTime @default(now())
75
+ updatedAt DateTime @updatedAt
76
+
77
+ @@index([email])
78
+ @@map("users")
79
+ }
80
+
81
+ model Post {
82
+ id String @id @default(cuid())
83
+ title String
84
+ author User @relation("UserPosts", fields: [authorId], references: [id], onDelete: Cascade)
85
+ authorId String
86
+
87
+ @@index([authorId])
88
+ @@map("posts")
89
+ }
90
+ ```
91
+
92
+ **Resources:**
93
+ - https://www.prisma.io/docs/concepts/components/prisma-schema
94
+ - https://www.prisma.io/docs/concepts/components/prisma-schema/relations
95
+
96
+ ### Migrations
97
+ **Common Issues:**
98
+ - Migration conflicts in team environments
99
+ - Failed migrations leaving database in inconsistent state
100
+ - Shadow database issues during development
101
+ - Production deployment migration failures
102
+
103
+ **Diagnosis:**
104
+ ```bash
105
+ # Check migration status
106
+ npx prisma migrate status
107
+
108
+ # View pending migrations
109
+ ls -la prisma/migrations/
110
+
111
+ # Check migration history table
112
+ # (use database-specific command)
113
+ ```
114
+
115
+ **Prioritized Fixes:**
116
+ 1. **Minimal**: Reset development database with `prisma migrate reset`
117
+ 2. **Better**: Manually fix migration SQL, use `prisma migrate resolve`
118
+ 3. **Complete**: Squash migrations, create baseline for fresh setup
119
+
120
+ **Safe Migration Workflow:**
121
+ ```bash
122
+ # Development
123
+ npx prisma migrate dev --name descriptive_name
124
+
125
+ # Production (never use migrate dev!)
126
+ npx prisma migrate deploy
127
+
128
+ # If migration fails in production
129
+ npx prisma migrate resolve --applied "migration_name"
130
+ # or
131
+ npx prisma migrate resolve --rolled-back "migration_name"
132
+ ```
133
+
134
+ **Resources:**
135
+ - https://www.prisma.io/docs/concepts/components/prisma-migrate
136
+ - https://www.prisma.io/docs/guides/deployment/deploy-database-changes
137
+
138
+ ### Query Optimization
139
+ **Common Issues:**
140
+ - N+1 query problems with relations
141
+ - Over-fetching data with excessive includes
142
+ - Missing select for large models
143
+ - Slow queries without proper indexing
144
+
145
+ **Diagnosis:**
146
+ ```bash
147
+ # Enable query logging
148
+ # In schema.prisma or client initialization:
149
+ # log: ['query', 'info', 'warn', 'error']
150
+ ```
151
+
152
+ ```typescript
153
+ // Enable query events
154
+ const prisma = new PrismaClient({
155
+ log: [
156
+ { emit: 'event', level: 'query' },
157
+ ],
158
+ });
159
+
160
+ prisma.$on('query', (e) => {
161
+ console.log('Query: ' + e.query);
162
+ console.log('Duration: ' + e.duration + 'ms');
163
+ });
164
+ ```
165
+
166
+ **Prioritized Fixes:**
167
+ 1. **Minimal**: Add includes for related data to avoid N+1
168
+ 2. **Better**: Use select to fetch only needed fields
169
+ 3. **Complete**: Use raw queries for complex aggregations, implement caching
170
+
171
+ **Optimized Query Patterns:**
172
+ ```typescript
173
+ // BAD: N+1 problem
174
+ const users = await prisma.user.findMany();
175
+ for (const user of users) {
176
+ const posts = await prisma.post.findMany({ where: { authorId: user.id } });
177
+ }
178
+
179
+ // GOOD: Include relations
180
+ const users = await prisma.user.findMany({
181
+ include: { posts: true }
182
+ });
183
+
184
+ // BETTER: Select only needed fields
185
+ const users = await prisma.user.findMany({
186
+ select: {
187
+ id: true,
188
+ email: true,
189
+ posts: {
190
+ select: { id: true, title: true }
191
+ }
192
+ }
193
+ });
194
+
195
+ // BEST for complex queries: Use $queryRaw
196
+ const result = await prisma.$queryRaw`
197
+ SELECT u.id, u.email, COUNT(p.id) as post_count
198
+ FROM users u
199
+ LEFT JOIN posts p ON p.author_id = u.id
200
+ GROUP BY u.id
201
+ `;
202
+ ```
203
+
204
+ **Resources:**
205
+ - https://www.prisma.io/docs/guides/performance-and-optimization
206
+ - https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access
207
+
208
+ ### Connection Management
209
+ **Common Issues:**
210
+ - Connection pool exhaustion
211
+ - "Too many connections" errors
212
+ - Connection leaks in serverless environments
213
+ - Slow initial connections
214
+
215
+ **Diagnosis:**
216
+ ```bash
217
+ # Check current connections (PostgreSQL)
218
+ psql -c "SELECT count(*) FROM pg_stat_activity WHERE datname = 'your_db';"
219
+ ```
220
+
221
+ **Prioritized Fixes:**
222
+ 1. **Minimal**: Configure connection limit in DATABASE_URL
223
+ 2. **Better**: Implement proper connection lifecycle management
224
+ 3. **Complete**: Use connection pooler (PgBouncer) for high-traffic apps
225
+
226
+ **Connection Configuration:**
227
+ ```typescript
228
+ // For serverless (Vercel, AWS Lambda)
229
+ import { PrismaClient } from '@prisma/client';
230
+
231
+ const globalForPrisma = global as unknown as { prisma: PrismaClient };
232
+
233
+ export const prisma =
234
+ globalForPrisma.prisma ||
235
+ new PrismaClient({
236
+ log: process.env.NODE_ENV === 'development' ? ['query'] : [],
237
+ });
238
+
239
+ if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
240
+
241
+ // Graceful shutdown
242
+ process.on('beforeExit', async () => {
243
+ await prisma.$disconnect();
244
+ });
245
+ ```
246
+
247
+ ```env
248
+ # Connection URL with pool settings
249
+ DATABASE_URL="postgresql://user:pass@host:5432/db?connection_limit=5&pool_timeout=10"
250
+ ```
251
+
252
+ **Resources:**
253
+ - https://www.prisma.io/docs/guides/performance-and-optimization/connection-management
254
+ - https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-vercel
255
+
256
+ ### Transaction Patterns
257
+ **Common Issues:**
258
+ - Inconsistent data from non-atomic operations
259
+ - Deadlocks in concurrent transactions
260
+ - Long-running transactions blocking reads
261
+ - Nested transaction confusion
262
+
263
+ **Diagnosis:**
264
+ ```typescript
265
+ // Check for transaction issues
266
+ try {
267
+ const result = await prisma.$transaction([...]);
268
+ } catch (e) {
269
+ if (e.code === 'P2034') {
270
+ console.log('Transaction conflict detected');
271
+ }
272
+ }
273
+ ```
274
+
275
+ **Transaction Patterns:**
276
+ ```typescript
277
+ // Sequential operations (auto-transaction)
278
+ const [user, profile] = await prisma.$transaction([
279
+ prisma.user.create({ data: userData }),
280
+ prisma.profile.create({ data: profileData }),
281
+ ]);
282
+
283
+ // Interactive transaction with manual control
284
+ const result = await prisma.$transaction(async (tx) => {
285
+ const user = await tx.user.create({ data: userData });
286
+
287
+ // Business logic validation
288
+ if (user.email.endsWith('@blocked.com')) {
289
+ throw new Error('Email domain blocked');
290
+ }
291
+
292
+ const profile = await tx.profile.create({
293
+ data: { ...profileData, userId: user.id }
294
+ });
295
+
296
+ return { user, profile };
297
+ }, {
298
+ maxWait: 5000, // Wait for transaction slot
299
+ timeout: 10000, // Transaction timeout
300
+ isolationLevel: 'Serializable', // Strictest isolation
301
+ });
302
+
303
+ // Optimistic concurrency control
304
+ const updateWithVersion = await prisma.post.update({
305
+ where: {
306
+ id: postId,
307
+ version: currentVersion // Only update if version matches
308
+ },
309
+ data: {
310
+ content: newContent,
311
+ version: { increment: 1 }
312
+ }
313
+ });
314
+ ```
315
+
316
+ **Resources:**
317
+ - https://www.prisma.io/docs/concepts/components/prisma-client/transactions
318
+
319
+ ## Code Review Checklist
320
+
321
+ ### Schema Quality
322
+ - [ ] All models have appropriate `@id` and primary keys
323
+ - [ ] Relations use explicit `@relation` with `fields` and `references`
324
+ - [ ] Cascade behaviors defined (`onDelete`, `onUpdate`)
325
+ - [ ] Indexes added for frequently queried fields
326
+ - [ ] Enums used for fixed value sets
327
+ - [ ] `@@map` used for table naming conventions
328
+
329
+ ### Query Patterns
330
+ - [ ] No N+1 queries (relations included when needed)
331
+ - [ ] `select` used to fetch only required fields
332
+ - [ ] Pagination implemented for list queries
333
+ - [ ] Raw queries used for complex aggregations
334
+ - [ ] Proper error handling for database operations
335
+
336
+ ### Performance
337
+ - [ ] Connection pooling configured appropriately
338
+ - [ ] Indexes exist for WHERE clause fields
339
+ - [ ] Composite indexes for multi-column queries
340
+ - [ ] Query logging enabled in development
341
+ - [ ] Slow queries identified and optimized
342
+
343
+ ### Migration Safety
344
+ - [ ] Migrations tested before production deployment
345
+ - [ ] Backward-compatible schema changes (no data loss)
346
+ - [ ] Migration scripts reviewed for correctness
347
+ - [ ] Rollback strategy documented
348
+
349
+ ## Anti-Patterns to Avoid
350
+
351
+ 1. **Implicit Many-to-Many Overhead**: Always use explicit join tables for complex relationships
352
+ 2. **Over-Including**: Don't include relations you don't need
353
+ 3. **Ignoring Connection Limits**: Always configure pool size for your environment
354
+ 4. **Raw Query Abuse**: Use Prisma queries when possible, raw only for complex cases
355
+ 5. **Migration in Production Dev Mode**: Never use `migrate dev` in production
@@ -0,0 +1,310 @@
1
+ ---
2
+ name: react-expert
3
+ description: Provides React 18/19 expertise including hooks, component patterns, performance optimization, state management, and Server Components. Use this skill for React component issues, hook errors, re-rendering problems, or state management challenges.
4
+ ---
5
+
6
+ # React Expert
7
+
8
+ You are an expert in React 18/19 with deep knowledge of hooks, component patterns, performance optimization, state management, and Server Components.
9
+
10
+ ## When Invoked
11
+
12
+ ### Step 0: Recommend Specialist and Stop
13
+ If the issue is specifically about:
14
+ - **Performance profiling and optimization**: Stop and recommend react-performance-expert
15
+ - **CSS-in-JS or styling**: Stop and recommend css-styling-expert
16
+ - **Accessibility concerns**: Stop and recommend accessibility-expert
17
+ - **Testing React components**: Stop and recommend the appropriate testing expert
18
+
19
+ ### Environment Detection
20
+ ```bash
21
+ # Detect React version
22
+ npm list react --depth=0 2>/dev/null | grep react@ || node -e "console.log(require('./package.json').dependencies?.react || 'Not found')" 2>/dev/null
23
+
24
+ # Check for React DevTools and build tools
25
+ if [ -f "next.config.js" ] || [ -f "next.config.mjs" ]; then echo "Next.js detected"
26
+ elif [ -f "vite.config.js" ] || [ -f "vite.config.ts" ]; then echo "Vite detected"
27
+ elif [ -f "webpack.config.js" ]; then echo "Webpack detected"
28
+ elif grep -q "react-scripts" package.json 2>/dev/null; then echo "Create React App detected"
29
+ else echo "Unknown build tool"
30
+ fi
31
+
32
+ # Check for Strict Mode and router
33
+ grep -r "React.StrictMode\|<StrictMode" src/ 2>/dev/null || echo "No Strict Mode found"
34
+ npm list react-router-dom @tanstack/react-router --depth=0 2>/dev/null | grep -E "(react-router-dom|@tanstack/react-router)" || echo "No router detected"
35
+ ```
36
+
37
+ ### Apply Strategy
38
+ 1. Identify the React-specific issue category
39
+ 2. Check for common anti-patterns in that category
40
+ 3. Apply progressive fixes (minimal → better → complete)
41
+ 4. Validate with React DevTools and testing
42
+
43
+ ## Problem Playbooks
44
+
45
+ ### Hooks Hygiene
46
+ **Common Issues:**
47
+ - "Invalid hook call" - Hooks called conditionally or outside components
48
+ - "Missing dependency" warnings - useEffect/useCallback missing deps
49
+ - Stale closure bugs - Values not updating in callbacks
50
+ - "Cannot update component while rendering" - State updates in render phase
51
+
52
+ **Diagnosis:**
53
+ ```bash
54
+ # Check for hook violations
55
+ npx eslint src/ --rule 'react-hooks/rules-of-hooks: error' --rule 'react-hooks/exhaustive-deps: warn' 2>/dev/null || echo "No ESLint React hooks rules configured"
56
+
57
+ # Find useEffect patterns
58
+ grep -r "useEffect" --include="*.jsx" --include="*.tsx" src/ | head -10
59
+
60
+ # Check for render-phase state updates
61
+ grep -r "setState\|useState.*(" --include="*.jsx" --include="*.tsx" src/ | grep -v "useEffect\|onClick\|onChange"
62
+ ```
63
+
64
+ **Prioritized Fixes:**
65
+ 1. **Minimal**: Add missing dependencies to dependency array, move hooks to component top level
66
+ 2. **Better**: Use useCallback/useMemo for stable references, move state updates to event handlers
67
+ 3. **Complete**: Extract custom hooks for complex logic, refactor component architecture
68
+
69
+ **Validation:**
70
+ ```bash
71
+ npm run lint 2>/dev/null || npx eslint src/ --ext .jsx,.tsx
72
+ npm test -- --watchAll=false --passWithNoTests 2>/dev/null || echo "No tests configured"
73
+ ```
74
+
75
+ **Resources:**
76
+ - https://react.dev/reference/react/hooks
77
+ - https://react.dev/reference/rules/rules-of-hooks
78
+ - https://react.dev/learn/removing-effect-dependencies
79
+
80
+ ### Rendering Performance
81
+ **Common Issues:**
82
+ - "Too many re-renders" - State updates in render or infinite loops
83
+ - "Maximum update depth exceeded" - Infinite render loops
84
+ - Component re-rendering unnecessarily - Missing memoization
85
+ - Large lists causing slowdowns - No virtualization
86
+
87
+ **Diagnosis:**
88
+ ```bash
89
+ # Check for React.memo usage
90
+ grep -r "React.memo\|memo(" --include="*.jsx" --include="*.tsx" src/ | wc -l
91
+
92
+ # Find potential performance issues
93
+ grep -r "map\|filter\|reduce" --include="*.jsx" --include="*.tsx" src/ | grep -v "useMemo\|useCallback" | head -5
94
+
95
+ # Check for object creation in render
96
+ grep -r "=.*{.*}" --include="*.jsx" --include="*.tsx" src/ | grep -v "useState\|useEffect" | head -5
97
+ ```
98
+
99
+ **Prioritized Fixes:**
100
+ 1. **Minimal**: Move state updates to event handlers, fix dependency arrays
101
+ 2. **Better**: Wrap components in React.memo, use useMemo for expensive computations
102
+ 3. **Complete**: Implement virtualization for large lists, code splitting, architectural refactor
103
+
104
+ **Validation:**
105
+ Use React DevTools Profiler to measure render count reduction and performance improvements.
106
+
107
+ **Resources:**
108
+ - https://react.dev/reference/react/memo
109
+ - https://react.dev/reference/react/useMemo
110
+ - https://react.dev/learn/render-and-commit
111
+
112
+ ### Effects & Lifecycle
113
+ **Common Issues:**
114
+ - Memory leaks from missing cleanup functions
115
+ - "Can't perform React state update on unmounted component" warnings
116
+ - Race conditions in async effects
117
+ - Effects running too often or at wrong times
118
+
119
+ **Diagnosis:**
120
+ ```bash
121
+ # Find effects without cleanup
122
+ grep -A 5 -r "useEffect" --include="*.jsx" --include="*.tsx" src/ | grep -B 5 -A 5 "useEffect" | grep -c "return.*(" || echo "No cleanup functions found"
123
+
124
+ # Check for async effects (anti-pattern)
125
+ grep -r "async.*useEffect\|useEffect.*async" --include="*.jsx" --include="*.tsx" src/
126
+
127
+ # Find potential memory leaks
128
+ grep -r "addEventListener\|setInterval\|setTimeout" --include="*.jsx" --include="*.tsx" src/ | grep -v "cleanup\|clear\|remove"
129
+ ```
130
+
131
+ **Prioritized Fixes:**
132
+ 1. **Minimal**: Add cleanup functions to effects, cancel async operations
133
+ 2. **Better**: Use AbortController for fetch cancellation, implement proper async patterns
134
+ 3. **Complete**: Extract custom hooks, implement proper resource management patterns
135
+
136
+ **Validation:**
137
+ ```bash
138
+ # Check for memory leaks (if tests are configured)
139
+ npm test -- --detectLeaks --watchAll=false 2>/dev/null || echo "No test configuration for leak detection"
140
+ ```
141
+
142
+ **Resources:**
143
+ - https://react.dev/reference/react/useEffect
144
+ - https://react.dev/learn/synchronizing-with-effects
145
+ - https://react.dev/learn/you-might-not-need-an-effect
146
+
147
+ ### State Management
148
+ **Common Issues:**
149
+ - Props drilling through many levels
150
+ - "Objects are not valid as React child" - Rendering objects instead of primitives
151
+ - State updates not batching properly
152
+ - Stale state in event handlers and closures
153
+
154
+ **Diagnosis:**
155
+ ```bash
156
+ # Find potential prop drilling patterns
157
+ grep -r "props\." --include="*.jsx" --include="*.tsx" src/ | wc -l
158
+
159
+ # Check Context usage
160
+ grep -r "useContext\|createContext" --include="*.jsx" --include="*.tsx" src/
161
+
162
+ # Look for direct state mutations
163
+ grep -r "\.push\|\.pop\|\.splice" --include="*.jsx" --include="*.tsx" src/ | grep -v "useState.*=\|setState"
164
+
165
+ # Find object rendering patterns
166
+ grep -r "{\w*}" --include="*.jsx" --include="*.tsx" src/ | grep -v "props\|style" | head -5
167
+ ```
168
+
169
+ **Prioritized Fixes:**
170
+ 1. **Minimal**: Use spread operator for state updates, fix object rendering
171
+ 2. **Better**: Lift state up to common ancestor, use Context for cross-cutting concerns
172
+ 3. **Complete**: Implement state management library (Redux Toolkit, Zustand), normalize data
173
+
174
+ **Resources:**
175
+ - https://react.dev/learn/managing-state
176
+ - https://react.dev/learn/passing-data-deeply-with-context
177
+ - https://react.dev/reference/react/useState
178
+
179
+ ### SSR/RSC Issues
180
+ **Common Issues:**
181
+ - "Hydration failed" - Server/client rendering mismatches
182
+ - "Text content does not match server HTML" - Dynamic content differences
183
+ - "localStorage is not defined" - Browser APIs called during SSR
184
+ - Data fetching inconsistencies between server and client
185
+
186
+ **Diagnosis:**
187
+ ```bash
188
+ # Check for client-only code
189
+ grep -r "window\.\|document\.\|localStorage\|sessionStorage" --include="*.jsx" --include="*.tsx" src/ | head -10
190
+
191
+ # Find server components (if using App Router)
192
+ grep -r "use server\|async function.*await" --include="*.jsx" --include="*.tsx" src/
193
+
194
+ # Check for hydration-sensitive code
195
+ grep -r "Date\(\)\|Math.random\(\)" --include="*.jsx" --include="*.tsx" src/
196
+ ```
197
+
198
+ **Prioritized Fixes:**
199
+ 1. **Minimal**: Add `typeof window !== 'undefined'` checks, use suppressHydrationWarning sparingly
200
+ 2. **Better**: Implement proper environment detection, use useEffect for client-only code
201
+ 3. **Complete**: Implement proper SSR patterns, use dynamic imports with `ssr: false`, consistent data fetching
202
+
203
+ **Resources:**
204
+ - https://react.dev/reference/react-dom/client/hydrateRoot
205
+ - https://react.dev/reference/react-dom/server
206
+ - https://nextjs.org/docs/app/building-your-application/rendering
207
+
208
+ ### Component Patterns
209
+ **Common Issues:**
210
+ - "Each child in list should have unique key" - Missing or duplicate keys
211
+ - "Cannot read properties of null" - Ref timing issues
212
+ - Tight coupling between components
213
+ - Poor component composition and reusability
214
+
215
+ **Diagnosis:**
216
+ ```bash
217
+ # Check component size and complexity
218
+ find src/ -name "*.jsx" -o -name "*.tsx" | xargs wc -l | sort -rn | head -10
219
+
220
+ # Find list rendering without keys
221
+ grep -r "\.map(" --include="*.jsx" --include="*.tsx" src/ | grep -v "key=" | head -5
222
+
223
+ # Check for ref usage
224
+ grep -r "useRef\|ref\.current" --include="*.jsx" --include="*.tsx" src/
225
+
226
+ # Find repeated patterns
227
+ grep -r "interface.*Props\|type.*Props" --include="*.tsx" src/ | wc -l
228
+ ```
229
+
230
+ **Prioritized Fixes:**
231
+ 1. **Minimal**: Add unique keys to list items, add null checks for refs
232
+ 2. **Better**: Implement proper TypeScript prop types, extract shared logic to hooks
233
+ 3. **Complete**: Create compound components pattern, implement design system with consistent patterns
234
+
235
+ **Resources:**
236
+ - https://react.dev/learn/rendering-lists
237
+ - https://react.dev/reference/react/useRef
238
+ - https://react.dev/learn/thinking-in-react
239
+
240
+ ## Runtime Considerations
241
+ - **React 18 Changes**: Automatic batching changes update timing, Strict Mode runs effects twice in development
242
+ - **Concurrent Features**: Suspense, transitions, and Server Components require different mental models
243
+ - **Fast Refresh**: Limitations with certain patterns (class components, anonymous functions)
244
+ - **Server Components**: Cannot use hooks, browser APIs, or event handlers
245
+
246
+ ## Code Review Checklist
247
+
248
+ When reviewing React code, focus on these framework-specific aspects:
249
+
250
+ ### Hooks Compliance
251
+ - [ ] Rules of Hooks followed (only at top level, only in React functions)
252
+ - [ ] Dependency arrays complete and accurate
253
+ - [ ] No conditional hook calls
254
+ - [ ] Custom hooks prefixed with `use`
255
+ - [ ] Effects properly cleaned up
256
+ - [ ] No async functions directly in useEffect
257
+
258
+ ### Performance Patterns
259
+ - [ ] Appropriate use of `React.memo` for expensive components
260
+ - [ ] `useMemo` and `useCallback` used where beneficial (not overused)
261
+ - [ ] Keys stable and unique in lists
262
+ - [ ] Large lists virtualized when needed
263
+ - [ ] Code splitting implemented for routes
264
+ - [ ] Lazy loading for heavy components
265
+
266
+ ### State Management
267
+ - [ ] State lifted to appropriate level (not too high)
268
+ - [ ] Derived state calculated, not stored
269
+ - [ ] Immutable state updates
270
+ - [ ] No direct DOM manipulation
271
+ - [ ] Form state properly controlled or uncontrolled (not mixed)
272
+ - [ ] Context not overused for frequently changing values
273
+
274
+ ### Component Design
275
+ - [ ] Single responsibility principle followed
276
+ - [ ] Props properly typed with TypeScript/PropTypes
277
+ - [ ] Default props handled correctly
278
+ - [ ] Error boundaries implemented for risky operations
279
+ - [ ] Accessibility attributes present (aria-labels, roles)
280
+ - [ ] Event handlers properly bound
281
+
282
+ ### React Patterns
283
+ - [ ] Composition over inheritance
284
+ - [ ] Render props or hooks for logic sharing (not HOCs)
285
+ - [ ] Controlled vs uncontrolled components consistent
286
+ - [ ] Side effects isolated in useEffect
287
+ - [ ] Suspense boundaries for async operations
288
+ - [ ] Portals used for modals/tooltips when needed
289
+
290
+ ### Common Pitfalls
291
+ - [ ] No array index as key for dynamic lists
292
+ - [ ] No inline function definitions in render (when avoidable)
293
+ - [ ] No business logic in components (separated into hooks/utils)
294
+ - [ ] No missing dependencies in hooks
295
+ - [ ] No memory leaks from uncleaned effects
296
+ - [ ] No unnecessary re-renders from unstable references
297
+
298
+ ## Safety Guidelines
299
+ - Never modify state objects directly - always use immutable updates
300
+ - Always include cleanup functions in useEffect for subscriptions and async operations
301
+ - Handle loading and error states explicitly in all components
302
+ - Use TypeScript or PropTypes for development-time prop validation
303
+ - Implement Error Boundaries to prevent entire app crashes
304
+ - Test components in isolation before integration
305
+
306
+ ## Anti-Patterns to Avoid
307
+ 1. **Effect Overuse**: "You might not need an Effect" - prefer derived state and event handlers
308
+ 2. **Premature Optimization**: Don't add useMemo/useCallback everywhere without profiling
309
+ 3. **Imperative DOM Access**: Avoid direct DOM manipulation - use refs sparingly
310
+ 4. **Complex Nested State**: Flatten state structure or use useReducer for complex updates