start-vibing 2.0.3 → 2.0.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 (85) hide show
  1. package/package.json +1 -1
  2. package/template/.claude/agents/01-orchestration/agent-selector.md +1 -0
  3. package/template/.claude/agents/01-orchestration/checkpoint-manager.md +1 -0
  4. package/template/.claude/agents/01-orchestration/context-manager.md +1 -0
  5. package/template/.claude/agents/01-orchestration/error-recovery.md +1 -0
  6. package/template/.claude/agents/01-orchestration/parallel-coordinator.md +1 -0
  7. package/template/.claude/agents/01-orchestration/workflow-router.md +1 -0
  8. package/template/.claude/agents/02-typescript/bun-runtime-expert.md +1 -0
  9. package/template/.claude/agents/02-typescript/esm-resolver.md +1 -0
  10. package/template/.claude/agents/02-typescript/import-alias-enforcer.md +1 -0
  11. package/template/.claude/agents/02-typescript/ts-generics-helper.md +1 -0
  12. package/template/.claude/agents/02-typescript/ts-migration-helper.md +1 -0
  13. package/template/.claude/agents/02-typescript/ts-strict-checker.md +1 -0
  14. package/template/.claude/agents/02-typescript/ts-types-analyzer.md +1 -0
  15. package/template/.claude/agents/02-typescript/type-definition-writer.md +1 -0
  16. package/template/.claude/agents/02-typescript/zod-schema-designer.md +1 -1
  17. package/template/.claude/agents/02-typescript/zod-validator.md +1 -0
  18. package/template/.claude/agents/03-testing/playwright-assertions.md +1 -0
  19. package/template/.claude/agents/03-testing/playwright-e2e.md +2 -2
  20. package/template/.claude/agents/03-testing/playwright-fixtures.md +2 -2
  21. package/template/.claude/agents/03-testing/playwright-multi-viewport.md +2 -2
  22. package/template/.claude/agents/03-testing/playwright-page-objects.md +2 -1
  23. package/template/.claude/agents/03-testing/test-cleanup-manager.md +2 -1
  24. package/template/.claude/agents/03-testing/test-data-generator.md +2 -1
  25. package/template/.claude/agents/03-testing/tester-integration.md +1 -1
  26. package/template/.claude/agents/03-testing/tester-unit.md +1 -1
  27. package/template/.claude/agents/03-testing/vitest-config.md +2 -1
  28. package/template/.claude/agents/04-docker/container-health.md +2 -1
  29. package/template/.claude/agents/04-docker/deployment-validator.md +2 -1
  30. package/template/.claude/agents/04-docker/docker-compose-designer.md +2 -1
  31. package/template/.claude/agents/04-docker/docker-env-manager.md +2 -1
  32. package/template/.claude/agents/04-docker/docker-multi-stage.md +2 -1
  33. package/template/.claude/agents/04-docker/dockerfile-optimizer.md +2 -1
  34. package/template/.claude/agents/05-database/data-migration.md +2 -1
  35. package/template/.claude/agents/05-database/database-seeder.md +2 -1
  36. package/template/.claude/agents/05-database/mongodb-query-optimizer.md +2 -1
  37. package/template/.claude/agents/05-database/mongoose-aggregation.md +2 -1
  38. package/template/.claude/agents/05-database/mongoose-index-optimizer.md +2 -1
  39. package/template/.claude/agents/05-database/mongoose-schema-designer.md +2 -2
  40. package/template/.claude/agents/06-security/auth-session-validator.md +1 -1
  41. package/template/.claude/agents/06-security/input-sanitizer.md +2 -1
  42. package/template/.claude/agents/06-security/owasp-checker.md +1 -1
  43. package/template/.claude/agents/06-security/permission-auditor.md +2 -1
  44. package/template/.claude/agents/06-security/security-auditor.md +1 -1
  45. package/template/.claude/agents/06-security/sensitive-data-scanner.md +2 -1
  46. package/template/.claude/agents/07-documentation/api-documenter.md +2 -1
  47. package/template/.claude/agents/07-documentation/changelog-manager.md +2 -1
  48. package/template/.claude/agents/07-documentation/documenter.md +1 -1
  49. package/template/.claude/agents/07-documentation/domain-updater.md +1 -1
  50. package/template/.claude/agents/07-documentation/jsdoc-generator.md +2 -1
  51. package/template/.claude/agents/07-documentation/readme-generator.md +2 -1
  52. package/template/.claude/agents/08-git/branch-manager.md +2 -1
  53. package/template/.claude/agents/08-git/commit-manager.md +2 -2
  54. package/template/.claude/agents/08-git/pr-creator.md +2 -1
  55. package/template/.claude/agents/09-quality/code-reviewer.md +2 -1
  56. package/template/.claude/agents/09-quality/quality-checker.md +1 -1
  57. package/template/.claude/agents/10-research/best-practices-finder.md +1 -1
  58. package/template/.claude/agents/10-research/competitor-analyzer.md +1 -1
  59. package/template/.claude/agents/10-research/pattern-researcher.md +1 -1
  60. package/template/.claude/agents/10-research/research-cache-manager.md +1 -1
  61. package/template/.claude/agents/10-research/research-web.md +1 -1
  62. package/template/.claude/agents/10-research/tech-evaluator.md +1 -1
  63. package/template/.claude/agents/11-ui-ux/accessibility-auditor.md +1 -1
  64. package/template/.claude/agents/11-ui-ux/design-system-enforcer.md +2 -2
  65. package/template/.claude/agents/11-ui-ux/skeleton-generator.md +2 -2
  66. package/template/.claude/agents/11-ui-ux/ui-desktop.md +2 -2
  67. package/template/.claude/agents/11-ui-ux/ui-mobile.md +2 -2
  68. package/template/.claude/agents/11-ui-ux/ui-tablet.md +2 -2
  69. package/template/.claude/agents/12-performance/api-latency-analyzer.md +2 -1
  70. package/template/.claude/agents/12-performance/bundle-analyzer.md +2 -1
  71. package/template/.claude/agents/12-performance/memory-leak-detector.md +2 -1
  72. package/template/.claude/agents/12-performance/performance-profiler.md +2 -1
  73. package/template/.claude/agents/12-performance/query-optimizer.md +2 -2
  74. package/template/.claude/agents/12-performance/render-optimizer.md +2 -1
  75. package/template/.claude/agents/13-debugging/build-error-fixer.md +2 -1
  76. package/template/.claude/agents/13-debugging/debugger.md +2 -1
  77. package/template/.claude/agents/13-debugging/error-stack-analyzer.md +2 -1
  78. package/template/.claude/agents/13-debugging/network-debugger.md +2 -1
  79. package/template/.claude/agents/13-debugging/runtime-error-fixer.md +2 -1
  80. package/template/.claude/agents/13-debugging/type-error-resolver.md +2 -1
  81. package/template/.claude/agents/14-validation/final-validator.md +1 -1
  82. package/template/.claude/skills/debugging-patterns/SKILL.md +484 -0
  83. package/template/.claude/skills/docker-patterns/SKILL.md +547 -0
  84. package/template/.claude/skills/git-workflow/SKILL.md +454 -0
  85. package/template/.claude/skills/performance-patterns/SKILL.md +549 -0
@@ -0,0 +1,549 @@
1
+ ---
2
+ name: performance-patterns
3
+ description: Performance profiling and optimization patterns. React optimization, bundle analysis, memory leaks, API latency, database queries. Use when optimizing application performance.
4
+ allowed-tools: Read, Write, Edit, Bash, Grep, Glob
5
+ ---
6
+
7
+ # Performance Patterns - Optimization Best Practices
8
+
9
+ ## Purpose
10
+
11
+ Expert guidance for performance:
12
+
13
+ - **React Optimization** - Re-renders, memoization, lazy loading
14
+ - **Bundle Analysis** - Code splitting, tree shaking
15
+ - **Memory Management** - Leak detection and prevention
16
+ - **API Performance** - Latency reduction, caching
17
+ - **Database Optimization** - Query efficiency, indexing
18
+
19
+ ---
20
+
21
+ ## React Performance
22
+
23
+ ### Prevent Unnecessary Re-renders
24
+
25
+ ```typescript
26
+ // WRONG - New object on every render
27
+ <Component style={{ color: 'red' }} />
28
+
29
+ // CORRECT - Stable reference
30
+ const style = useMemo(() => ({ color: 'red' }), []);
31
+ <Component style={style} />
32
+ ```
33
+
34
+ ### React.memo for Pure Components
35
+
36
+ ```typescript
37
+ // Memoize component that receives stable props
38
+ const UserCard = React.memo(function UserCard({ user }: { user: User }) {
39
+ return (
40
+ <div>
41
+ <h2>{user.name}</h2>
42
+ <p>{user.email}</p>
43
+ </div>
44
+ );
45
+ });
46
+
47
+ // Custom comparison for complex props
48
+ const ExpensiveList = React.memo(
49
+ function ExpensiveList({ items }: { items: Item[] }) {
50
+ return <>{items.map(item => <Item key={item.id} {...item} />)}</>;
51
+ },
52
+ (prev, next) => prev.items.length === next.items.length
53
+ );
54
+ ```
55
+
56
+ ### useMemo for Expensive Computations
57
+
58
+ ```typescript
59
+ function Analytics({ data }: { data: DataPoint[] }) {
60
+ // Memoize expensive calculation
61
+ const statistics = useMemo(() => {
62
+ return {
63
+ total: data.reduce((sum, d) => sum + d.value, 0),
64
+ average: data.reduce((sum, d) => sum + d.value, 0) / data.length,
65
+ max: Math.max(...data.map(d => d.value)),
66
+ };
67
+ }, [data]);
68
+
69
+ return <StatsDisplay stats={statistics} />;
70
+ }
71
+ ```
72
+
73
+ ### useCallback for Event Handlers
74
+
75
+ ```typescript
76
+ function TodoList({ todos, onToggle }: Props) {
77
+ // Stable callback reference
78
+ const handleToggle = useCallback((id: string) => {
79
+ onToggle(id);
80
+ }, [onToggle]);
81
+
82
+ return todos.map(todo => (
83
+ <TodoItem key={todo.id} todo={todo} onToggle={handleToggle} />
84
+ ));
85
+ }
86
+ ```
87
+
88
+ ### Lazy Loading Components
89
+
90
+ ```typescript
91
+ import { lazy, Suspense } from 'react';
92
+
93
+ // Lazy load heavy components
94
+ const HeavyChart = lazy(() => import('./components/HeavyChart'));
95
+ const AdminPanel = lazy(() => import('./components/AdminPanel'));
96
+
97
+ function App() {
98
+ return (
99
+ <Suspense fallback={<LoadingSpinner />}>
100
+ <HeavyChart data={chartData} />
101
+ </Suspense>
102
+ );
103
+ }
104
+ ```
105
+
106
+ ### Virtual Lists for Large Data
107
+
108
+ ```typescript
109
+ import { useVirtualizer } from '@tanstack/react-virtual';
110
+
111
+ function VirtualList({ items }: { items: Item[] }) {
112
+ const parentRef = useRef<HTMLDivElement>(null);
113
+
114
+ const virtualizer = useVirtualizer({
115
+ count: items.length,
116
+ getScrollElement: () => parentRef.current,
117
+ estimateSize: () => 50,
118
+ });
119
+
120
+ return (
121
+ <div ref={parentRef} style={{ height: '400px', overflow: 'auto' }}>
122
+ <div style={{ height: `${virtualizer.getTotalSize()}px`, position: 'relative' }}>
123
+ {virtualizer.getVirtualItems().map((virtualItem) => (
124
+ <div
125
+ key={virtualItem.key}
126
+ style={{
127
+ position: 'absolute',
128
+ top: 0,
129
+ left: 0,
130
+ width: '100%',
131
+ height: `${virtualItem.size}px`,
132
+ transform: `translateY(${virtualItem.start}px)`,
133
+ }}
134
+ >
135
+ <ItemRow item={items[virtualItem.index]} />
136
+ </div>
137
+ ))}
138
+ </div>
139
+ </div>
140
+ );
141
+ }
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Bundle Optimization
147
+
148
+ ### Code Splitting
149
+
150
+ ```typescript
151
+ // Route-based splitting
152
+ const routes = [
153
+ {
154
+ path: '/dashboard',
155
+ component: lazy(() => import('./pages/Dashboard')),
156
+ },
157
+ {
158
+ path: '/settings',
159
+ component: lazy(() => import('./pages/Settings')),
160
+ },
161
+ ];
162
+
163
+ // Feature-based splitting
164
+ const HeavyEditor = lazy(() =>
165
+ import(/* webpackChunkName: "editor" */ './components/HeavyEditor')
166
+ );
167
+ ```
168
+
169
+ ### Bundle Analysis
170
+
171
+ ```bash
172
+ # Analyze bundle size
173
+ bunx vite-bundle-analyzer
174
+
175
+ # Alternative: source-map-explorer
176
+ bunx source-map-explorer dist/assets/*.js
177
+
178
+ # Check specific package size
179
+ bunx bundlephobia zod
180
+ ```
181
+
182
+ ### Tree Shaking
183
+
184
+ ```typescript
185
+ // WRONG - Imports entire library
186
+ import _ from 'lodash';
187
+ const result = _.debounce(fn, 300);
188
+
189
+ // CORRECT - Import only what you need
190
+ import debounce from 'lodash/debounce';
191
+ const result = debounce(fn, 300);
192
+
193
+ // BEST - Use native or smaller alternative
194
+ function debounce<T extends (...args: any[]) => any>(fn: T, ms: number) {
195
+ let timeoutId: ReturnType<typeof setTimeout>;
196
+ return (...args: Parameters<T>) => {
197
+ clearTimeout(timeoutId);
198
+ timeoutId = setTimeout(() => fn(...args), ms);
199
+ };
200
+ }
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Memory Leak Prevention
206
+
207
+ ### Common Leak Patterns
208
+
209
+ ```typescript
210
+ // LEAK - Event listener not removed
211
+ useEffect(() => {
212
+ window.addEventListener('resize', handleResize);
213
+ // Missing cleanup!
214
+ }, []);
215
+
216
+ // FIXED - Proper cleanup
217
+ useEffect(() => {
218
+ window.addEventListener('resize', handleResize);
219
+ return () => window.removeEventListener('resize', handleResize);
220
+ }, []);
221
+ ```
222
+
223
+ ### Abort Controllers for Fetch
224
+
225
+ ```typescript
226
+ useEffect(() => {
227
+ const controller = new AbortController();
228
+
229
+ async function fetchData() {
230
+ try {
231
+ const response = await fetch('/api/data', {
232
+ signal: controller.signal,
233
+ });
234
+ const data = await response.json();
235
+ setData(data);
236
+ } catch (error) {
237
+ if (error instanceof Error && error.name === 'AbortError') {
238
+ return; // Ignore abort errors
239
+ }
240
+ throw error;
241
+ }
242
+ }
243
+
244
+ fetchData();
245
+
246
+ return () => controller.abort();
247
+ }, []);
248
+ ```
249
+
250
+ ### Closure Leaks
251
+
252
+ ```typescript
253
+ // LEAK - Timer holds reference after unmount
254
+ function Component() {
255
+ const [count, setCount] = useState(0);
256
+
257
+ useEffect(() => {
258
+ const id = setInterval(() => {
259
+ setCount(c => c + 1); // Uses stale closure
260
+ }, 1000);
261
+ return () => clearInterval(id); // MUST cleanup
262
+ }, []);
263
+ }
264
+ ```
265
+
266
+ ### WeakMap for Object References
267
+
268
+ ```typescript
269
+ // Use WeakMap to avoid holding strong references
270
+ const cache = new WeakMap<object, ComputedValue>();
271
+
272
+ function getComputed(obj: object): ComputedValue {
273
+ if (cache.has(obj)) {
274
+ return cache.get(obj)!;
275
+ }
276
+ const computed = expensiveComputation(obj);
277
+ cache.set(obj, computed);
278
+ return computed;
279
+ }
280
+ ```
281
+
282
+ ---
283
+
284
+ ## API Latency Optimization
285
+
286
+ ### Response Caching
287
+
288
+ ```typescript
289
+ // In-memory cache with TTL
290
+ const cache = new Map<string, { data: unknown; expires: number }>();
291
+
292
+ async function cachedFetch<T>(url: string, ttl = 60000): Promise<T> {
293
+ const cached = cache.get(url);
294
+ if (cached && cached.expires > Date.now()) {
295
+ return cached.data as T;
296
+ }
297
+
298
+ const response = await fetch(url);
299
+ const data = await response.json();
300
+
301
+ cache.set(url, { data, expires: Date.now() + ttl });
302
+ return data;
303
+ }
304
+ ```
305
+
306
+ ### Request Deduplication
307
+
308
+ ```typescript
309
+ const pending = new Map<string, Promise<Response>>();
310
+
311
+ async function dedupedFetch(url: string): Promise<Response> {
312
+ if (pending.has(url)) {
313
+ return pending.get(url)!;
314
+ }
315
+
316
+ const promise = fetch(url).finally(() => {
317
+ pending.delete(url);
318
+ });
319
+
320
+ pending.set(url, promise);
321
+ return promise;
322
+ }
323
+ ```
324
+
325
+ ### Parallel Requests
326
+
327
+ ```typescript
328
+ // SLOW - Sequential requests
329
+ const user = await fetchUser(id);
330
+ const posts = await fetchPosts(id);
331
+ const comments = await fetchComments(id);
332
+
333
+ // FAST - Parallel requests
334
+ const [user, posts, comments] = await Promise.all([
335
+ fetchUser(id),
336
+ fetchPosts(id),
337
+ fetchComments(id),
338
+ ]);
339
+ ```
340
+
341
+ ### Response Compression
342
+
343
+ ```typescript
344
+ // Enable compression in server
345
+ import compression from 'compression';
346
+ app.use(compression());
347
+
348
+ // Or in Bun
349
+ Bun.serve({
350
+ fetch(request) {
351
+ const response = Response.json(largeData);
352
+ // Bun auto-compresses based on Accept-Encoding
353
+ return response;
354
+ },
355
+ });
356
+ ```
357
+
358
+ ---
359
+
360
+ ## MongoDB Query Optimization
361
+
362
+ ### Use Indexes
363
+
364
+ ```typescript
365
+ // Create indexes for frequent queries
366
+ const userSchema = new Schema({
367
+ email: { type: String, unique: true, index: true },
368
+ createdAt: { type: Date, index: true },
369
+ status: { type: String, index: true },
370
+ });
371
+
372
+ // Compound index for common query pattern
373
+ userSchema.index({ status: 1, createdAt: -1 });
374
+ ```
375
+
376
+ ### Avoid N+1 Queries
377
+
378
+ ```typescript
379
+ // WRONG - N+1 problem
380
+ const posts = await Post.find();
381
+ for (const post of posts) {
382
+ post.author = await User.findById(post.authorId);
383
+ }
384
+
385
+ // CORRECT - Use populate
386
+ const posts = await Post.find().populate('author');
387
+
388
+ // CORRECT - Manual batch fetch
389
+ const posts = await Post.find();
390
+ const authorIds = [...new Set(posts.map(p => p.authorId))];
391
+ const authors = await User.find({ _id: { $in: authorIds } });
392
+ const authorMap = new Map(authors.map(a => [a._id.toString(), a]));
393
+ posts.forEach(p => p.author = authorMap.get(p.authorId.toString()));
394
+ ```
395
+
396
+ ### Projection - Select Only Needed Fields
397
+
398
+ ```typescript
399
+ // WRONG - Fetches all fields
400
+ const users = await User.find({ status: 'active' });
401
+
402
+ // CORRECT - Select only needed fields
403
+ const users = await User.find({ status: 'active' })
404
+ .select('name email avatar')
405
+ .lean();
406
+ ```
407
+
408
+ ### Use .lean() for Read-Only
409
+
410
+ ```typescript
411
+ // Returns plain JS objects (faster)
412
+ const users = await User.find().lean();
413
+
414
+ // vs Mongoose documents (slower, but has methods)
415
+ const users = await User.find();
416
+ ```
417
+
418
+ ### Aggregation Pipeline
419
+
420
+ ```typescript
421
+ // Efficient aggregation
422
+ const stats = await Order.aggregate([
423
+ { $match: { status: 'completed' } },
424
+ { $group: {
425
+ _id: '$userId',
426
+ totalOrders: { $sum: 1 },
427
+ totalSpent: { $sum: '$amount' },
428
+ }},
429
+ { $sort: { totalSpent: -1 } },
430
+ { $limit: 10 },
431
+ ]);
432
+ ```
433
+
434
+ ---
435
+
436
+ ## Profiling Tools
437
+
438
+ ### React DevTools Profiler
439
+
440
+ ```typescript
441
+ // Wrap component to profile
442
+ import { Profiler } from 'react';
443
+
444
+ function onRender(
445
+ id: string,
446
+ phase: 'mount' | 'update',
447
+ actualDuration: number,
448
+ baseDuration: number,
449
+ ) {
450
+ console.log(`${id} ${phase}: ${actualDuration.toFixed(2)}ms`);
451
+ }
452
+
453
+ <Profiler id="ExpensiveComponent" onRender={onRender}>
454
+ <ExpensiveComponent />
455
+ </Profiler>
456
+ ```
457
+
458
+ ### Performance API
459
+
460
+ ```typescript
461
+ // Measure operation time
462
+ performance.mark('fetch-start');
463
+ await fetchData();
464
+ performance.mark('fetch-end');
465
+
466
+ performance.measure('fetch-duration', 'fetch-start', 'fetch-end');
467
+ const measure = performance.getEntriesByName('fetch-duration')[0];
468
+ console.log(`Fetch took ${measure?.duration.toFixed(2)}ms`);
469
+ ```
470
+
471
+ ### MongoDB Query Explain
472
+
473
+ ```bash
474
+ # In MongoDB shell
475
+ db.users.find({ email: "test@example.com" }).explain("executionStats")
476
+
477
+ # Check if using index
478
+ # "winningPlan.inputStage.stage" should be "IXSCAN" not "COLLSCAN"
479
+ ```
480
+
481
+ ---
482
+
483
+ ## Core Web Vitals
484
+
485
+ ### LCP (Largest Contentful Paint) < 2.5s
486
+
487
+ ```typescript
488
+ // Preload critical resources
489
+ <link rel="preload" href="/hero-image.webp" as="image" />
490
+
491
+ // Use priority hints
492
+ <img src="/hero.webp" fetchpriority="high" />
493
+ ```
494
+
495
+ ### FID (First Input Delay) < 100ms
496
+
497
+ ```typescript
498
+ // Break up long tasks
499
+ async function processLargeArray(items: Item[]) {
500
+ for (let i = 0; i < items.length; i += 100) {
501
+ const chunk = items.slice(i, i + 100);
502
+ await processChunk(chunk);
503
+ // Yield to main thread
504
+ await new Promise(r => setTimeout(r, 0));
505
+ }
506
+ }
507
+ ```
508
+
509
+ ### CLS (Cumulative Layout Shift) < 0.1
510
+
511
+ ```typescript
512
+ // Always set dimensions on images
513
+ <img src="/photo.jpg" width={800} height={600} alt="Photo" />
514
+
515
+ // Use aspect-ratio CSS
516
+ <div style={{ aspectRatio: '16/9' }}>
517
+ <img src="/video-thumb.jpg" />
518
+ </div>
519
+ ```
520
+
521
+ ---
522
+
523
+ ## Agent Integration
524
+
525
+ This skill is used by:
526
+
527
+ - **performance-profiler** agent
528
+ - **bundle-analyzer** agent
529
+ - **memory-leak-detector** agent
530
+ - **api-latency-analyzer** agent
531
+ - **query-optimizer** agent
532
+ - **render-optimizer** agent
533
+
534
+ ---
535
+
536
+ ## FORBIDDEN
537
+
538
+ 1. **Premature optimization** - Measure first, optimize second
539
+ 2. **Missing cleanup in useEffect** - Always return cleanup function
540
+ 3. **N+1 queries** - Use batch fetching or populate
541
+ 4. **Fetching all fields** - Use projection/select
542
+ 5. **Blocking main thread** - Use web workers for heavy computation
543
+ 6. **Ignoring Core Web Vitals** - Monitor LCP, FID, CLS
544
+
545
+ ---
546
+
547
+ ## Version
548
+
549
+ - **v1.0.0** - Initial implementation based on 2024-2025 performance patterns