performance-optimization
Use when creating performance optimization plan for backend, API, or general system performance. Enforces BASELINE → PROFILE → OPTIMIZE → VALIDATE sequence. Triggers: "optimize API", "backend slow", "API latency", "database performance", "query optimization", "server response time". For "Core Web Vitals" in backend/API context, use this skill. For frontend UI accessibility + performance (WCAG, Lighthouse accessibility), use frontend-production-quality instead. If thinking "bottleneck is obvious" - profile first.
When & Why to Use This Skill
The Performance Optimization skill is a specialized framework for backend engineers and system architects to systematically improve system efficiency. It enforces a data-driven 'Baseline → Profile → Optimize → Validate' workflow to eliminate guesswork in performance tuning. By prioritizing profiling over intuition, it helps users identify root causes like N+1 queries or blocking renders, ensuring that optimizations lead to measurable improvements in API latency and server response times without causing regressions.
Use Cases
- Case 1: Developing a comprehensive optimization plan for slow backend APIs by establishing performance baselines and identifying specific bottlenecks.
- Case 2: Reducing database latency through systematic query profiling and the implementation of targeted indexing or architectural changes.
- Case 3: Improving Core Web Vitals from a backend perspective by optimizing server-side rendering and data fetching strategies.
- Case 4: Validating the impact of system-wide performance patches to ensure that optimizations meet target metrics without degrading other functional areas.
| name | performance-optimization |
|---|---|
| description | Use when creating performance optimization plan for backend, API, or general system performance. Enforces BASELINE → PROFILE → OPTIMIZE → VALIDATE sequence. Triggers: "optimize API", "backend slow", "API latency", "database performance", "query optimization", "server response time". For "Core Web Vitals" in backend/API context, use this skill. For frontend UI accessibility + performance (WCAG, Lighthouse accessibility), use frontend-production-quality instead. If thinking "bottleneck is obvious" - profile first. |
Performance Optimization
MANDATORY FIRST STEP
TodoWrite: Create 20+ items (5 sections × 4 items)
- Baseline measurement (tool, current value, target, conditions)
- Bottleneck analysis (profile, identify slowest, root cause)
- Optimization strategy (prioritize, evaluate approaches, expected improvement)
- Implementation (files, config, local verification)
- Validation (re-measure, compare, check regressions)
Never skip measurement:
- 70% of "obvious" bottlenecks are wrong → Profile first
- 40% of optimizations without baseline cause regressions
5-Section Process
1. Baseline Measurement (BEFORE implementation)
- Tool + current value (e.g., "Lighthouse: LCP = 4.2s on 3G")
- Target metric (e.g., "LCP < 2.5s")
- Conditions recorded
2. Bottleneck Analysis
- Profile with tool (Chrome DevTools, pg_stat_statements, DataDog)
- Identify slowest operation + time (e.g., "Chart.js render = 2.8s, 67% of total")
- Root cause (N+1 queries, large bundle, blocking render)
3. Optimization Strategy
- Prioritize by impact (2.8s → 0.5s = 82% faster)
- Evaluate 2-3 approaches
- Expected improvement
4. Implementation
- Files + changes
- Configuration
- Local verification
5. Validation
- Re-measure same tool + conditions
- Compare before/after
- Check no regressions (FID, CLS, functionality)
Verification Checkpoint
Before marking complete:
- ✅ Baseline measured with specific tool + value
- ✅ Profile identifies bottleneck with % of total time
- ✅ Validation re-measures with same tool/conditions
Red Flags
| Thought | Reality |
|---|---|
| "Bottleneck is obvious" | 70% wrong without profiling |
| "We'll measure after" | Can't validate improvement |
| "Manual testing is enough" | Need metrics, not feelings |