React Performance Optimizer Agent
Powerful agent for specialist, react, performance, patterns. Includes structured workflows, validation checks, and reusable patterns for web tools.
React Performance Optimizer Agent
Diagnoses React rendering bottlenecks, bundle bloat, memory leaks, and Core Web Vitals regressions in production applications.
When to Use This Agent
Choose this agent when you need to:
- Profile React render cycles using concurrent features, memoization, and virtualization
- Analyze and reduce bundle sizes through code splitting and dependency replacement
- Implement Core Web Vitals monitoring specific to React's rendering and hydration pipeline
Consider alternatives when:
- Performance issues stem from backend API latency rather than frontend rendering
- You need architecture guidance for new features rather than optimizing existing ones
Quick Start
Configuration
name: react-performance-optimizer-agent type: agent category: web-tools
Example Invocation
claude agent:invoke react-performance-optimizer-agent "Profile Dashboard component tree for unnecessary re-renders"
Example Output
Re-render Analysis: Dashboard
==============================
EXCESSIVE RENDERS:
1. <UserAvatar /> 47/sec (cause: parent state update)
Fix: Wrap with React.memo
2. <NotificationBell /> 23/sec (cause: context consumer)
Fix: Split NotificationContext into Count + List contexts
3. <SidebarNav /> 12/sec (cause: inline object prop)
Fix: Extract navConfig to module-level constant
MEMORY: 342 detached DOM nodes from VirtualList unmount
Fix: Add IntersectionObserver cleanup in useEffect
Impact: -63% render cycles, -18ms interaction latency
Core Concepts
Performance Domains
| Aspect | Details |
|---|---|
| Render Optimization | React.memo, useMemo, useCallback, avoiding inline object/function props |
| Concurrent Features | useTransition, useDeferredValue for non-blocking UI during heavy computation |
| Virtualization | react-window/react-virtuoso for rendering only visible items in long lists |
| Bundle Analysis | Webpack treemaps, chunk splitting, and dependency audit for dead code |
| Memory Management | useEffect cleanup, listener deregistration, and WeakRef for caches |
React Render Pipeline
+-------------------+ +-------------------+ +------------------+
| State Change |---->| Reconciliation |---->| DOM Commit |
| (setState/ctx) | | (VDOM diffing) | | (Paint/Layout) |
+-------------------+ +-------------------+ +------------------+
| | |
v v v
+-------------------+ +-------------------+ +------------------+
| Avoid Trigger | | Minimize Diff | | Reduce Paint |
| React.memo | | useMemo/keys | | CSS containment |
| Context split | | Virtualization | | will-change |
+-------------------+ +-------------------+ +------------------+
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
| profiling_mode | string | "development" | Build: "development" for DevTools or "production" for real metrics |
| bundle_budget_kb | number | 250 | Max client JS budget before optimization triggers |
| render_threshold_ms | number | 16 | Max render duration (one frame at 60fps) |
| memory_check | boolean | true | Enable detached DOM and listener leak detection |
| vitals_tracking | boolean | true | Enable LCP, FID, CLS measurement and alerting |
Best Practices
-
Profile Before Optimizing - Use React DevTools Profiler to record flamegraphs before adding memoization. Premature React.memo adds complexity without benefit if the component was not re-rendering excessively.
-
Split Context by Update Frequency - A single context holding fast-changing data (notification count) and stable data (user preferences) re-renders all consumers on any update. Split by frequency to insulate stable subscribers.
-
Virtualize Lists Beyond 100 Items - Hundreds of DOM nodes require layout and paint even when off-screen. Libraries like react-window render only the visible slice, reducing render time from seconds to milliseconds.
-
Replace Heavy Dependencies - Swap moment.js (67KB) for date-fns, lodash (72KB) for lodash-es or native methods. Each replacement compounds into meaningful bundle reduction.
-
Enforce Performance Budgets in CI - Add bundle size checks with bundlesize or size-limit. Failing builds when client JS exceeds thresholds prevents regressions from merging unnoticed.
Common Issues
-
Inline Props Defeat React.memo -
style={{color:'red'}}creates new references every render, bypassing memoization. Extract to module-level constants or useMemo for referential stability. -
useEffect Missing Cleanup - Listeners and observers without cleanup functions accumulate on remount. StrictMode double-mounts double the leak rate. Always return a cleanup function.
-
Code Splitting Waterfalls - Splitting every component with React.lazy creates sequential loading chains. Group related components into shared chunks and preload critical lazy chunks to parallelize fetching.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
API Endpoint Builder
Agent that scaffolds complete REST API endpoints with controller, service, route, types, and tests. Supports Express, Fastify, and NestJS.
Documentation Auto-Generator
Agent that reads your codebase and generates comprehensive documentation including API docs, architecture guides, and setup instructions.
Ai Ethics Advisor Partner
All-in-one agent covering ethics, responsible, development, specialist. Includes structured workflows, validation checks, and reusable patterns for ai specialists.