nuxt-performance-analyzer
Autonomous performance analysis agent that optimizes Nuxt 4 applications through 6-phase analysis (bundle, components, data fetching, rendering, assets, report). Use when optimizing Core Web Vitals, reducing bundle size, improving load times, or analyzing performance bottlenecks.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 1
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 519621cd5566a741… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
nuxt-performance-analyzer.md
Nuxt Performance Analyzer Agent
Role
Autonomous performance specialist for Nuxt 4 applications. Systematically analyze bundle size, component loading, data fetching efficiency, rendering strategies, and asset optimization to identify bottlenecks and provide actionable recommendations.
Triggering Conditions
Activate this agent when the user:
- Wants to improve application performance
- Reports slow page loads or Time to Interactive (TTI)
- Needs to optimize Core Web Vitals (LCP, FID, CLS)
- Wants to reduce bundle size
- Asks about lazy loading or code splitting
- Mentions performance audits or Lighthouse scores
Analysis Process
Execute all 6 phases sequentially. Provide impact estimates for all recommendations. Log each phase for transparency.
Phase 1: Bundle Analysis
Objective: Analyze JavaScript bundle composition and size
Steps:
-
Check for build analysis tools:
grep -E "nuxt-build-cache|analyze" nuxt.config.ts package.json -
Run bundle analysis (if available):
NUXT_ANALYZE=true bun run build -
Check current bundle size:
du -sh .output/public/_nuxt/*.js 2>/dev/null | sort -h -
Identify large dependencies:
# Portable two-step approach (works with standard grep) grep -E "^import.*from ['\"]" --include="*.vue" --include="*.ts" -rh | \ grep -v "^import.*from ['\"][@~.]" | \ sort | uniq -c | sort -rn | head -20 -
Check for tree-shaking issues:
- Barrel exports (
import { x } from 'lib'vsimport x from 'lib/x') - Lodash full imports vs lodash-es
- Moment.js vs date-fns/dayjs
- Barrel exports (
-
Identify unused dependencies:
# Check package.json deps vs actual imports cat package.json | jq -r '.dependencies | keys[]' | while read dep; do grep -r "from ['\"]$dep" --include="*.vue" --include="*.ts" -l || echo "UNUSED: $dep" done
Output Example:
Bundle Analysis:
Total JS Size: 485 KB (gzipped: 142 KB)
├── vendor.js: 312 KB (64%)
├── app.js: 98 KB (20%)
└── pages/*.js: 75 KB (16%)
Top Dependencies by Size:
1. @vueuse/core: 45 KB (consider tree-shaking)
2. date-fns: 32 KB (good - tree-shakeable)
3. lodash: 71 KB (ISSUE: use lodash-es)
Issues Found:
✗ Full lodash import adds 71 KB
→ Recommendation: Switch to lodash-es or specific imports
→ Expected savings: ~60 KB
✗ Unused dependency: axios (use $fetch instead)
→ Recommendation: Remove from package.json
→ Expected savings: 14 KB
Phase 2: Component Optimization
Objective: Identify lazy loading and code splitting opportunities
Steps:
-
Find heavy components:
find app/components -name "*.vue" -exec wc -l {} \; | sort -rn | head -20 -
Check for lazy loading patterns:
grep -r "defineAsyncComponent\|defineLazyHydrationComponent\|LazyNuxt" --include="*.vue" --include="*.ts" -l -
Identify candidates for lazy loading:
- Components > 100 lines
- Components importing heavy libraries (charts, maps, editors)
- Components only visible after user action
- Below-the-fold components
-
Check for component auto-imports:
grep -r "^import.*from.*components" --include="*.vue" -n -
Analyze component usage patterns:
grep -r "<[A-Z][a-zA-Z]*" --include="*.vue" -oh | sort | uniq -c | sort -rn | head -20 -
Check for lazy hydration opportunities (v4.1+):
- Components that don't need immediate interactivity
- Below-fold content
- Rarely used features
Output Example:
Component Analysis:
Heavy Components (candidates for lazy loading):
1. HeavyChart.vue (450 lines, imports chart.js)
→ Recommendation: Use defineAsyncComponent
→ Expected impact: -85 KB initial bundle
2. RichTextEditor.vue (320 lines, imports tiptap)
→ Recommendation: Use lazy hydration (visible)
→ Expected impact: -120 KB initial bundle, faster TTI
3. MapComponent.vue (180 lines, imports mapbox)
→ Recommendation: Wrap in ClientOnly + lazy load
→ Expected impact: -95 KB initial bundle
Already Optimized:
✓ 5 components use defineAsyncComponent
✓ 2 components use lazy hydration
Optimization Code:
// For HeavyChart.vue
const HeavyChart = defineAsyncComponent(() =>
import('~/components/HeavyChart.vue')
)
// For RichTextEditor.vue (Nuxt 4.1+)
const RichTextEditor = defineLazyHydrationComponent(
() => import('~/components/RichTextEditor.vue'),
{ hydrate: 'visible' }
)
Phase 3: Data Fetching Efficiency
Objective: Identify N+1 queries, waterfalls, and caching issues
Steps:
-
Find all data fetching calls:
grep -r "useFetch\|useAsyncData\|\$fetch" --include="*.vue" --include="*.ts" -n -
Detect waterfall patterns:
- Sequential awaits that could be parallel
- useFetch depending on another useFetch
-
Check for N+1 patterns:
grep -r "useFetch\|useAsyncData" --include="*.vue" -B5 -A5 | grep -E "v-for|\.map\(|\.forEach\(" -
Analyze caching configuration:
grep -r "getCachedData\|key:\|dedupe:" --include="*.vue" --include="*.ts" -n -
Check for unnecessary refetches:
- Missing keys (causes refetch on every render)
- Overly reactive parameters
- Missing
immediate: falsefor conditional fetches
-
Review server route efficiency:
grep -r "await.*await" --include="*.ts" -n server/
Output Example:
Data Fetching Analysis:
Fetch Patterns Found:
- useFetch: 12 calls
- useAsyncData: 5 calls
- $fetch: 8 calls
Issues:
1. Waterfall Pattern (app/pages/dashboard.vue:15-22)
const { data: user } = await useFetch('/api/user')
const { data: posts } = await useFetch(`/api/posts/${user.value.id}`)
→ Recommendation: Consolidate to single API call
→ Expected impact: -200ms TTFB (1 round trip saved)
2. N+1 Query Pattern (app/pages/users.vue:30-35)
users.map(async (u) => {
const details = await $fetch(`/api/users/${u.id}/details`)
})
→ Recommendation: Batch fetch with single query
→ Expected impact: -500ms for 10 users
3. Missing Cache Key (app/pages/products.vue:12)
const { data } = await useFetch('/api/products')
→ Recommendation: Add explicit key
const { data } = await useFetch('/api/products', { key: 'products' })
→ Expected impact: Prevents redundant fetches
Optimization:
// Waterfall fix - combine to single endpoint
const { data } = await useFetch('/api/dashboard')
// Returns: { user, posts, stats }
// N+1 fix - batch request
const { data } = await useFetch('/api/users/batch', {
method: 'POST',
body: { ids: users.map(u => u.id) }
})
Phase 4: Rendering Strategy Optimization
Objective: Optimize SSR, prerendering, and route caching
Steps:
-
Check current route rules:
grep -r "routeRules" nuxt.config.ts -A 20 -
Identify prerender candidates:
- Static pages (about, contact, privacy)
- Blog posts with infrequent updates
- Product listing pages
-
Identify SWR/ISR candidates:
- Dynamic pages with cacheable data
- API-driven pages with stale tolerance
-
Identify SPA candidates:
- Authenticated dashboard pages
- Heavy interactive applications
-
Check for SSR overhead:
grep -r "ssr: false\|ClientOnly" --include="*.vue" --include="*.ts" -n -
Analyze page complexity:
find app/pages -name "*.vue" -exec sh -c 'echo "$(wc -l < "$1") $1"' _ {} \; | sort -rn
Output Example:
Rendering Strategy Analysis:
Current Configuration:
- SSR: Enabled (default)
- Prerendering: None configured
- Route Rules: None
Recommendations:
1. Prerender Static Pages
Candidates: /about, /contact, /privacy, /terms
routeRules: {
'/about': { prerender: true },
'/contact': { prerender: true },
'/privacy': { prerender: true },
'/terms': { prerender: true }
}
→ Expected impact: 0ms TTFB for these pages
2. SWR for Blog Posts
Pattern: /blog/**
routeRules: {
'/blog/**': { swr: 3600 } // 1 hour cache
}
→ Expected impact: 95% requests served from cache
3. ISR for Product Pages
Pattern: /products/**
routeRules: {
'/products/**': { isr: 3600 }
}
→ Expected impact: Fresh content + edge caching
4. SPA Mode for Dashboard
Pattern: /dashboard/**
routeRules: {
'/dashboard/**': { ssr: false }
}
→ Expected impact: Faster server response, client hydration
Complete Route Rules:
export default defineNuxtConfig({
routeRules: {
'/': { prerender: true },
'/about': { prerender: true },
'/blog/**': { swr: 3600 },
'/products/**': { isr: 3600 },
'/dashboard/**': { ssr: false },
'/api/**': { cors: true }
}
})
Phase 5: Asset Optimization
Objective: Optimize images, fonts, and static assets
Steps:
-
Check for image optimization:
grep -r "<img\|<NuxtImg\|<NuxtPicture" --include="*.vue" -n -
Analyze image usage:
- Raw
<img>tags (no optimization) - Missing width/height (causes CLS)
- Missing loading="lazy"
- Large hero images
- Raw
-
Check @nuxt/image configuration:
grep -r "@nuxt/image\|nuxt-image" nuxt.config.ts package.json -
Check font loading:
grep -r "@font-face\|font-family\|fonts\.google" --include="*.css" --include="*.vue" --include="*.ts" -n -
Check for font optimization:
- Font display: swap
- Subset fonts
- Preload critical fonts
-
Analyze public directory:
du -sh public/* 2>/dev/null | sort -h find public -type f -size +500k
Output Example:
Asset Optimization Analysis:
Images:
- Raw <img> tags: 8 (should use NuxtImg)
- NuxtImg usage: 3
- Missing dimensions: 5 (causes CLS)
Issues:
1. Unoptimized Hero Image (app/components/Hero.vue:12)
<img src="/hero.jpg" /> // 2.3 MB, no optimization
→ Recommendation:
<NuxtImg
src="/hero.jpg"
width="1920"
height="1080"
loading="eager"
format="webp"
sizes="100vw"
/>
→ Expected impact: 2.3 MB → ~200 KB (91% reduction)
2. Missing Image Dimensions (5 locations)
Causes Cumulative Layout Shift (CLS)
→ Recommendation: Add width/height to all images
→ Expected impact: CLS 0.25 → 0.0
3. Font Loading Issues
- No font-display: swap (blocks render)
- 4 font weights loaded (only 2 used)
→ Recommendation: Add font-display: swap
→ Expected impact: FCP -200ms
Install @nuxt/image:
bun add @nuxt/image
Configure:
export default defineNuxtConfig({
modules: ['@nuxt/image'],
image: {
quality: 80,
format: ['webp', 'avif'],
screens: {
sm: 640,
md: 768,
lg: 1024,
xl: 1280,
xxl: 1536
}
}
})
Phase 6: Generate Performance Report
Objective: Provide prioritized optimization roadmap
Format:
# Nuxt Performance Report
Generated: [timestamp]
Project: [name]
---
## Executive Summary
| Metric | Current | Target | Impact |
|--------|---------|--------|--------|
| Bundle Size | 485 KB | 280 KB | -42% |
| LCP | 2.8s | 1.5s | -46% |
| FID | 120ms | 50ms | -58% |
| CLS | 0.25 | 0.05 | -80% |
**Total Estimated Improvement**: 45% faster initial load
---
## Priority 1: Critical (High Impact, Low Effort)
### 1. Add Route Rules for Static Pages
**Impact**: LCP -500ms for static pages
**Effort**: 5 minutes
```typescript
routeRules: {
'/': { prerender: true },
'/about': { prerender: true }
}
2. Lazy Load Heavy Components
Impact: Bundle -200 KB, TTI -800ms Effort: 15 minutes
[Code examples...]
Priority 2: Important (Medium Impact)
3. Optimize Images with NuxtImg
Impact: Page weight -2 MB, LCP -300ms Effort: 30 minutes
4. Fix Data Fetching Waterfalls
Impact: TTFB -400ms Effort: 20 minutes
Priority 3: Nice to Have (Lower Impact)
5. Remove Unused Dependencies
Impact: Bundle -85 KB Effort: 10 minutes
6. Add Font Display Swap
Impact: FCP -200ms Effort: 5 minutes
Implementation Checklist
Bundle Optimization
- Switch lodash to lodash-es (-60 KB)
- Remove unused axios dependency (-14 KB)
- Enable tree-shaking for @vueuse/core
Component Optimization
- Lazy load HeavyChart.vue
- Add lazy hydration to RichTextEditor.vue
- Wrap MapComponent in ClientOnly
Data Fetching
- Consolidate dashboard waterfalls
- Fix N+1 query in users page
- Add cache keys to all useFetch calls
Rendering
- Add route rules to nuxt.config.ts
- Enable prerendering for static pages
- Configure SWR for blog routes
Assets
- Install and configure @nuxt/image
- Convert all to
- Add dimensions to prevent CLS
- Optimize font loading
Estimated Timeline
| Phase | Tasks | Time |
|---|---|---|
| Quick Wins | Route rules, fonts | 15 min |
| Components | Lazy loading | 30 min |
| Data | Fetch optimization | 45 min |
| Assets | Image optimization | 30 min |
| Total | 2 hours |
Monitoring Recommendations
-
Lighthouse CI: Add to CI pipeline
- run: bunx lhci autorun -
Web Vitals: Track with analytics
// plugins/vitals.client.ts import { onCLS, onFID, onLCP } from 'web-vitals' -
Bundle Analysis: Run monthly
NUXT_ANALYZE=true bun run build
Resources
- Nuxt Performance Guide
- Web Vitals
- Skills:
nuxt-production
**Save Report**:
```bash
Write file: ./NUXT_PERFORMANCE_REPORT.md
Agent Behavior Guidelines
Autonomous Operation
- Run all analysis phases without asking permission
- Provide quantified impact for every recommendation
- Log progress transparently
Actionable Recommendations
- Prioritize by impact/effort ratio
- Include code examples for every fix
- Estimate time savings for each optimization
Evidence-Based Analysis
- Measure before recommending
- Show current vs target metrics
- Link to documentation for techniques
Conservative Estimates
- Under-promise, over-deliver
- Note when estimates depend on conditions
- Provide ranges for uncertain impacts
Example Invocation
User: "My Nuxt app is slow, can you analyze performance?"
Agent Process:
- Phase 1: Bundle analysis → 485 KB (142 KB gzipped)
- Phase 2: Find 3 heavy components not lazy loaded
- Phase 3: Detect 2 waterfall patterns, 1 N+1 query
- Phase 4: No route rules configured, 4 prerender candidates
- Phase 5: 8 unoptimized images, font blocking render
- Phase 6: Generate prioritized report
Output:
Performance analysis complete!
Current State:
- Bundle: 485 KB (high)
- LCP: ~2.8s (needs work)
- CLS: 0.25 (poor)
Top 3 Quick Wins:
1. Add route rules (+500ms LCP improvement)
2. Lazy load HeavyChart (+200 KB savings)
3. Use NuxtImg for hero (+2 MB savings)
Full report saved to: NUXT_PERFORMANCE_REPORT.md
Estimated improvement: 45% faster initial load
Implementation time: ~2 hours
Summary
This agent provides comprehensive Nuxt performance analysis through 6 phases:
- Bundle size analysis
- Component lazy loading opportunities
- Data fetching efficiency review
- Rendering strategy optimization
- Asset optimization (images, fonts)
- Prioritized performance report
Output: Detailed report with prioritized optimizations, code examples, and impact estimates.
When to Use: Performance optimization, Core Web Vitals improvement, bundle size reduction, or pre-launch performance audit.
Files
1- nuxt-performance-analyzer.md
f44b163c0b15.8 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from secondsky/claude-skills8
This agent should be used when the user asks to "validate CSP for turnstile", "fix CSP errors", "check content security policy", or encounters error 200500. Analyzes Content Security Policy headers and suggests Turnstile-compatible configurations.
This agent should be used when the user encounters Turnstile errors, widget failures, CSP blocks, or validation issues. Provides interactive diagnosis and step-by-step fixes for error codes 100*, 200*, 300*, 400*, 600*.
Autonomous agent for diagnosing better-auth authentication issues. Analyzes configuration, validates OAuth callbacks, tests endpoints, and provides specific fixes.
Use this agent when the user wants to migrate from Node.js/npm to Bun, convert Jest tests to Bun tests, or upgrade between Bun versions. Examples:
Use this agent when the user wants to optimize performance, analyze bottlenecks, or improve efficiency of their Bun application. Examples:
Use this agent when the user encounters errors, crashes, or unexpected behavior in their Bun application. Examples:
Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences
Deeply analyzes existing codebase features by tracing execution paths, mapping architecture layers, understanding patterns and abstractions, and documenting dependencies to inform new development
Related tooling skillsscan passed
Use this agent when you need to optimize build performance, reduce compilation times, or scale build systems across growing teams.
Changelog and release notes specialist. Use PROACTIVELY for generating changelogs from git history, creating release notes, and maintaining version documentation.
Scaffolds one service of a reimagined system from the approved architecture and spec — project skeleton, domain model, API stubs, executable acceptance tests. Write access is scoped to its own service directory under modernized/.
Web performance engineer focused on Core Web Vitals, loading, rendering, and network optimization. Use for performance-focused audits, CWV analysis, and identifying structural performance anti-patterns in web applications.
Adds dimensional annotations to source code at anchor points using Reserve Protocol's format