performance
React performance patterns — memoization, code splitting, RTK Query cache tuning, Core Web Vitals. Use when working with React.memo, useMemo, useCallback, lazy loading, or optimizing render performance.
What this skill does
## Quick Reference
### Memoization Rules
- NEVER memoize without profiling evidence
- `React.memo`: only when component receives same props but parent re-renders
- `useMemo`: only for expensive computations (>1ms) with stable deps
- `useCallback`: only when passed as prop to memoized child component
- If you can't explain WHY it needs memoization, remove it
### Code Splitting
```typescript
// Route-level splitting (always do this)
const Dashboard = React.lazy(() => import('./pages/Dashboard'));
// Next.js
const Chart = dynamic(() => import('./components/Chart'), { ssr: false });
```
### RTK Query Performance
```typescript
// ✅ selectFromResult — only re-render when YOUR data changes
const { user } = useGetUsersQuery(undefined, {
selectFromResult: ({ data }) => ({ user: data?.find(u => u.id === id) }),
});
// ✅ Appropriate cache times
keepUnusedDataFor: 300, // 5 min for stable data
pollingInterval: 30000, // 30s for live data
refetchOnMountOrArgChange: 60, // re-fetch if >60s stale
```
### Barrel Imports
```typescript
// BAD: imports entire library (200-800ms in dev)
import { Check, X, ChevronDown } from 'lucide-react';
// GOOD: direct imports
import Check from 'lucide-react/dist/esm/icons/check';
// GOOD: Next.js optimizePackageImports
// next.config.js: experimental: { optimizePackageImports: ['lucide-react'] }
```
Known barrel-heavy libraries: `lucide-react`, `@mui/material`, `lodash`, `date-fns`, `react-icons`.
### React Compiler
If React Compiler is enabled (`babel-plugin-react-compiler` or `react-compiler-runtime` in deps), `memo()`, `useMemo()`, `useCallback()` are handled automatically. Remove manual memoization to reduce noise.
### Core Web Vitals Targets
- LCP < 2.5s | INP < 200ms | CLS < 0.1
### Waterfall Elimination
Sequential awaits are the #1 server performance killer. Independent async operations must run in parallel.
```typescript
// BAD: sequential — total time = a + b + c
const users = await getUsers();
const posts = await getPosts();
const comments = await getComments();
// GOOD (async-parallel): parallel — total time = max(a, b, c), 2-10x faster
const [users, posts, comments] = await Promise.all([
getUsers(),
getPosts(),
getComments(),
]);
// GOOD (async-dependencies): start early, await late
const usersPromise = getUsers(); // starts immediately
const config = await getConfig(); // needed first
const users = await usersPromise; // already in flight
// GOOD (async-api-routes): kick off fetches before unrelated work
export async function GET(request: Request) {
const dataPromise = fetchExternalData(); // start fetch
const session = await getSession(); // do auth meanwhile
if (!session) return unauthorized();
const data = await dataPromise; // fetch likely done already
return Response.json(data);
}
// GOOD (async-defer-await): await only in branches that need the value
const resultPromise = expensiveComputation();
if (condition) {
return quickPath(); // never awaits
}
const result = await resultPromise; // only awaited when needed
```
**`async-suspense-boundaries`**: Wrap async Server Components in `<Suspense>` to stream progressively. Without boundaries, the entire page blocks on the slowest component.
```tsx
// BAD: entire page waits for slowest component
export default async function Page() {
return (
<div>
<SlowChart /> {/* 3s — blocks everything */}
<FastSidebar /> {/* 100ms — waits for chart */}
</div>
);
}
// GOOD: fast parts stream immediately, slow parts show fallback
export default function Page() {
return (
<div>
<Suspense fallback={<ChartSkeleton />}>
<SlowChart />
</Suspense>
<FastSidebar /> {/* renders immediately */}
</div>
);
}
```
### Bundle Optimization
```typescript
// bundle-conditional: dynamic import inside event handler / feature flag
const handleExport = async () => {
const { exportToPDF } = await import('./exportToPDF');
exportToPDF(data);
};
// bundle-defer-third-party: load analytics AFTER hydration
useEffect(() => {
import('./analytics').then(({ init }) => init());
}, []);
// Or Next.js: <Script src="analytics.js" strategy="afterInteractive" />
// bundle-preload: preload on hover for perceived instant navigation
<Link
href="/dashboard"
prefetch={true} // Next.js built-in
onMouseEnter={() => import('./pages/Dashboard')} // manual preload
>
Dashboard
</Link>
```
### Rendering Performance
```css
/* rendering-content-visibility: skip rendering of off-screen sections */
.long-list-item {
content-visibility: auto;
contain-intrinsic-size: auto 200px; /* estimated height */
}
```
**`rendering-hydration-no-flicker`**: Inline a small `<script>` for client-only data (theme, auth state) to prevent FOUC. The script runs before React hydrates.
```html
<!-- In <head> or before React root -->
<script>
// Prevents theme flash — runs before paint
document.documentElement.dataset.theme =
localStorage.getItem('theme') || 'system';
</script>
```
For detailed patterns, see `references/` directory.
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.