BACK TO DIRECTORY
commandadvanced
/perf
A comprehensive performance analysis command that runs multiple profiling tools. Analyzes JavaScript bundle sizes with tree-map visualization, runs Lighthouse audits for web performance scores, profiles server-side rendering time, checks database query performance, and identifies the largest dependencies in your bundle. Provides actionable recommendations for each finding.
345 STARS
4.6k DOWNLOADS
claude-templates
performancelighthousebundleprofilingmetrics
CONFIGURATION
markdown
1# /perf Command23## Description4Profile application performance across multiple dimensions.56## Analysis Areas78### 1. Bundle Analysis9```bash10# Build with analysis11ANALYZE=true next build1213# Or standalone14npx @next/bundle-analyzer15```1617Output:18- Total bundle size (JS + CSS)19- Per-page breakdown20- Largest dependencies21- Tree-shaking effectiveness2223### 2. Lighthouse Audit24```bash25npx lighthouse http://localhost:3000 --output json --output html26```2728Checks:29- Performance score (target: >90)30- First Contentful Paint (target: <1.8s)31- Largest Contentful Paint (target: <2.5s)32- Cumulative Layout Shift (target: <0.1)33- Total Blocking Time (target: <200ms)3435### 3. Server Performance36```bash37# API response times38curl -w "\nTotal: %{time_total}s\nTTFB: %{time_starttransfer}s\n" \39 http://localhost:3000/api/health40```4142### 4. Database Queries43```sql44-- Find slow queries45SELECT query, mean_exec_time, calls46FROM pg_stat_statements47ORDER BY mean_exec_time DESC48LIMIT 10;49```5051### 5. Recommendations52Common optimizations:53- Dynamic imports for heavy components54- Image optimization (next/image, WebP/AVIF)55- Font subsetting and preloading56- API response caching (Redis, CDN)57- Database query optimization (indexes, connection pooling)5859## Usage60- `/perf` - Run full performance audit61- `/perf bundle` - Bundle analysis only62- `/perf lighthouse` - Lighthouse audit only63- `/perf db` - Database query analysis