performance-optimizer
Optimize application performance and scalability. Use when investigating slow applications, scaling bottlenecks, or improving response times. Use for profiling, caching, database optimization, frontend performance, and backend tuning.
What this skill does
# Performance Optimizer ## Overview Provides a systematic approach to application performance optimization across the full stack. Use when diagnosing slow page loads, high API latency, database bottlenecks, or scaling issues. Not a substitute for application-specific profiling -- always measure before optimizing. ## Quick Reference ### Performance Budgets | Metric | Target | Category | | ------------------------------- | ------- | -------------- | | Largest Contentful Paint (LCP) | < 2.5s | Core Web Vital | | Interaction to Next Paint (INP) | < 200ms | Core Web Vital | | Cumulative Layout Shift (CLS) | < 0.1 | Core Web Vital | | First Contentful Paint (FCP) | < 1.8s | Frontend | | Time to Interactive (TTI) | < 3.8s | Frontend | | Total Blocking Time (TBT) | < 200ms | Frontend | | API Response Time (P95) | < 500ms | Backend | | Database Query Time (P95) | < 100ms | Database | | Server Response Time (TTFB) | < 600ms | Backend | ### Optimization Phases | Phase | Focus | Key Action | | ------------- | ----------------------------- | ---------------------------------------------------------------- | | 1. Profiling | Identify real bottlenecks | Chrome DevTools, React Profiler, EXPLAIN ANALYZE | | 2. Database | Eliminate slow queries | Strategic indexes, fix N+1, connection pooling | | 3. Caching | Reduce redundant work | Redis, HTTP headers, CDN for static assets | | 4. Frontend | Reduce bundle and render time | Bundle analysis, code splitting, resource hints, lazy loading | | 5. Backend | Speed up API responses | Serverless optimization, streaming, conditional requests, queues | | 6. Monitoring | Sustain performance | APM tools, alerting thresholds, dashboards | ### Caching Layers | Layer | Scope | Duration | | ------------- | ---------------------- | ------------------------------------------------- | | Browser Cache | HTTP headers | Static assets: 1 year (immutable); HTML: no-cache | | CDN | Cloudflare, CloudFront | Same as browser, purge on deploy | | Application | Redis, Memcached | Varies (e.g., 1 hour for user data) | | Database | Query cache | Automatic | ## Common Mistakes | Mistake | Correct Pattern | | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | | Optimizing before profiling | Measure first with Chrome DevTools, EXPLAIN ANALYZE, or APM tools to find real bottlenecks | | Adding indexes on every column | Use strategic indexes on columns in WHERE, ORDER BY, and JOIN clauses; monitor with slow query log | | SELECT \* on large tables | Select only needed columns to reduce I/O and memory | | N+1 queries in loops | Eager loading or DataLoader batching | | Functions in WHERE clause | Store normalized values, use generated columns to preserve index usage | | Caching without an invalidation strategy | Define TTL and invalidate-on-write policies; stale cache is worse than no cache | | Loading entire libraries for a single utility | Use direct imports and tree-shaking | | Running heavy computations synchronously in request handlers | Offload to background job queues (BullMQ) and return immediately | ## Delegation When working on performance optimization, delegate to: - `frontend-builder` -- React-specific performance patterns - `application-security` -- Rate limiting and DDoS protection - `ci-cd-architecture` -- Build pipeline optimization ## References - [Profiling and Measurement](references/profiling.md) -- Chrome DevTools, React Profiler, Node.js/Python profiling, database EXPLAIN - [Database Optimization](references/database.md) -- Strategic indexes, N+1 fixes, query optimization, connection pooling - [Caching Strategies](references/caching.md) -- Redis patterns, HTTP cache headers, CDN configuration - [Frontend Performance](references/frontend.md) -- Bundle analysis, code splitting, resource hints, third-party scripts, mobile performance, React patterns - [Backend Performance](references/backend.md) -- Serverless optimization, streaming responses, conditional requests, background queues, rate limiting - [Monitoring and Alerting](references/monitoring.md) -- APM tools, custom monitoring, dashboards, alert thresholds
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.