performance-optimization
Performance Optimization Skill
Comprehensive frameworks for analyzing and optimizing application performance across the entire stack.
When to Use
- Application feels slow or unresponsive
- Database queries taking too long
- Frontend bundle size too large
- API response times exceed targets
- Core Web Vitals need improvement
- Preparing for scale or high traffic
Performance Targets
Core Web Vitals (Frontend)
| Metric | Good | Needs Work |
|---|---|---|
| LCP (Largest Contentful Paint) | < 2.5s | < 4s |
| INP (Interaction to Next Paint) | < 200ms | < 500ms |
| CLS (Cumulative Layout Shift) | < 0.1 | < 0.25 |
| TTFB (Time to First Byte) | < 200ms | < 600ms |
Backend Targets
| Operation | Target |
|---|---|
| Simple reads | < 100ms |
| Complex queries | < 500ms |
| Write operations | < 200ms |
| Index lookups | < 10ms |
Bottleneck Categories
| Category | Symptoms | Tools |
|---|---|---|
| Network | High TTFB, slow loading | Network tab, WebPageTest |
| Database | Slow queries, pool exhaustion | EXPLAIN ANALYZE, pg_stat_statements |
| CPU | High usage, slow compute | Profiler, flame graphs |
| Memory | Leaks, GC pauses | Heap snapshots |
| Rendering | Layout thrashing | React DevTools, Performance tab |
Database Optimization
Key Patterns
- Add Missing Indexes - Turn
Seq ScanintoIndex Scan - Fix N+1 Queries - Use JOINs or
includeinstead of loops - Cursor Pagination - Never load all records
- Connection Pooling - Manage connection lifecycle
Quick Diagnostics
-- Find slow queries (PostgreSQL)
SELECT query, calls, mean_time / 1000 as mean_seconds
FROM pg_stat_statements ORDER BY total_time DESC LIMIT 10;
-- Verify index usage
EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = 123;
See
templates/database-optimization.tsfor N+1 fixes and pagination patterns
Caching Strategy
Cache Hierarchy
L1: In-Memory (LRU, memoization) - fastest
L2: Distributed (Redis/Memcached) - shared
L3: CDN (edge, static assets) - global
L4: Database (materialized views) - fallback
Cache-Aside Pattern
const cached = await redis.get(key);
if (cached) return JSON.parse(cached);
const data = await db.query(...);
await redis.setex(key, 3600, JSON.stringify(data));
return data;
See
templates/caching-patterns.tsfor full implementation
Frontend Optimization
Bundle Optimization
- Code Splitting -
lazy()for route-based splitting - Tree Shaking - Import only what you need
- Image Optimization - WebP/AVIF, lazy loading, proper sizing
Rendering Optimization
- Memoization -
memo(),useCallback(),useMemo() - Virtualization - Render only visible items in long lists
- Batch DOM Operations - Read all, then write all
See
templates/frontend-optimization.tsxfor patterns
Analysis Commands
# Lighthouse audit
lighthouse http://localhost:3000 --output=json
# Bundle analysis
npx @next/bundle-analyzer # Next.js
npx vite-bundle-visualizer # Vite
API Optimization
Response Optimization
- Field Selection - Return only requested fields
- Compression - Enable gzip/brotli (threshold: 1KB)
- ETags - Enable 304 responses for unchanged data
- Pagination - Cursor-based for large datasets
See
templates/api-optimization.tsfor middleware examples
Monitoring Checklist
Before Launch
- Lighthouse score > 90
- Core Web Vitals pass
- Bundle size within budget
- Database queries profiled
- Compression enabled
- CDN configured
Ongoing
- Performance monitoring active
- Alerting for degradation
- Lighthouse CI in pipeline
- Weekly query analysis
- Real User Monitoring (RUM)
See
templates/performance-metrics.tsfor Prometheus metrics setup
Extended Thinking Triggers
Use Opus 4.5 extended thinking for:
- Complex debugging - Multiple potential causes
- Architecture decisions - Caching strategy selection
- Trade-off analysis - Memory vs CPU vs latency
- Root cause analysis - Performance regression investigation
Templates Reference
| Template | Purpose |
|---|---|
database-optimization.ts |
N+1 fixes, pagination, pooling |
caching-patterns.ts |
Redis cache-aside, memoization |
frontend-optimization.tsx |
React memo, virtualization, code splitting |
api-optimization.ts |
Compression, ETags, field selection |
performance-metrics.ts |
Prometheus metrics, performance budget |
More from aiskillstore/marketplace
skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Codex's capabilities with specialized knowledge, workflows, or tool integrations.
499xlsx
Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas
220frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
218pptx
Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks
209docx
Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks
202skill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill content", or needs guidance on skill structure, progressive disclosure, or skill development best practices for Claude Code plugins.
183