Agent skill
bundle-size
Bundle size analysis, budget enforcement, and regression detection for Vite/Rollup builds. This skill should be used when: (1) analyzing bundle composition or total size, (2) checking size budgets, (3) comparing PR vs baseline for regressions, (4) investigating why bundle size increased, or (5) optimizing bundle size. Reads Vite manifest for chunk graph (Tier B). Cannot attribute sizes to specific npm packages without stats.json (Tier C unavailable by default).
Install this agent skill to your Project
npx add-skill https://github.com/nikhillinit/Updog_restore/tree/main/.claude/skills/bundle-size
SKILL.md
Bundle Size Analysis
Quick Reference
| Operation | Command | Output |
|---|---|---|
| Check budgets | node scripts/check-budgets.cjs |
Pass/fail per bundle |
| Size report | node scripts/size-report.mjs |
Top 10 assets by gzip |
| Compare to baseline | node scripts/compare-bundle-size.js |
Delta + PR comment |
| First load size | node scripts/size-first-load.mjs |
Initial load bundle size |
| Visual treemap | Open dist/stats.html |
Interactive module breakdown |
Capability Tiers
This skill operates at different capability levels depending on available data:
| Tier | Data Required | Available |
|---|---|---|
| A | dist/ files only |
Always |
| B | + dist/public/.vite/manifest.json |
After npm run build |
| C | + stats.json from Rollup | NOT enabled by default |
See references/capability-tiers.md for details.
CRITICAL: Agent Claim Constraints
These rules are NON-NEGOTIABLE. Violating them produces hallucinations.
Tier A/B (Default - No stats.json)
ALLOWED claims:
- "Total JS is 245KB gzipped"
- "The largest chunk is vendor-abc123.js at 118KB"
- "Initial load includes 3 entry chunks totaling 89KB"
- "Bundle increased 12KB (+5%) from baseline"
- "New file vendor-forms-xyz.js appeared in this build"
FORBIDDEN claims:
- "lodash contributes 40KB to the bundle"
- "Replace moment.js with dayjs to save 30KB"
- "The zod package is responsible for the increase"
- "date-fns accounts for 15% of vendor chunk"
When asked about package attribution:
"To identify package-level contribution, open dist/stats.html for an interactive treemap, or enable Rollup stats output in vite.config.ts for programmatic analysis."
On Regressions
ALLOWED:
- Report the delta (bytes and percent)
- List new/removed/changed files
- Reference commit diff if available
FORBIDDEN:
- Guess the cause without evidence
- Attribute to specific code changes without seeing the diff
- Claim a package caused the regression
When cause is uncertain:
"Bundle increased by X KB. To identify the cause, review the commit diff or open dist/stats.html to compare module sizes."
Existing Scripts
scripts/check-budgets.cjs
Per-bundle budget enforcement. Reads .size-limit.json configuration.
node scripts/check-budgets.cjs
# Exit 0 = pass, Exit 1 = budget exceeded
scripts/size-report.mjs
Reports top 10 largest assets by gzip size.
node scripts/size-report.mjs
# Outputs table to stdout
scripts/compare-bundle-size.js
Compares current build to baseline artifact. Used in CI.
node scripts/compare-bundle-size.js --base baseline.json --head current.json
scripts/size-first-load.mjs
Reports the initial load bundle size (entry chunks only).
node scripts/size-first-load.mjs
# Outputs initial load size
CI Integration
The existing workflow .github/workflows/bundle-size-check.yml:
- Downloads baseline artifact from main branch
- Builds PR branch
- Compares sizes
- Posts PR comment with delta
- Fails if budget exceeded (unless
approved:perf-budget-changelabel applied)
Troubleshooting
See references/troubleshooting.md for common issues:
- Manifest not found
- Baseline unavailable
- Budget configuration errors
Enabling Tier C (Package Attribution)
To unlock package-level attribution, add Rollup stats output:
// vite.config.ts
import { visualizer } from 'rollup-plugin-visualizer';
export default defineConfig({
plugins: [
visualizer({
filename: 'dist/stats.json',
json: true, // Enable JSON output
}),
],
});
WARNING: This increases build time. Only enable if package attribution is regularly needed.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
financial-calc-correctness
statistical-testing
ui-ux-pro-max
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.
code-reviewer
Comprehensive multi-AI code review system for Python, JavaScript, and TypeScript. Use when reviewing code for quality, security, performance, or best practices. Includes automated analysis scripts, language-specific patterns, and AI collaboration workflows for complex decisions.
dependency-guardian
Automated dependency management with security scanning, update orchestration, and compatibility validation
documentation-sync
Detects code/documentation drift, validates examples, generates diagrams, auto-updates documentation
Didn't find tool you were looking for?