nextjs-bundle-optimizer
Next.js 16 bundle-size and build-time optimization — runs a data-driven iteration loop: measure baseline → analyze top offenders → apply ONE recipe →…
Skill by pproenca
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/pproenca-nextjs-bundle-optimizer
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend, data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Shell scripts
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/nextjs-bundle-optimizer
What's inside
- Skill name
nextjs-bundle-optimizer- Description
- Next.js 16 bundle-size and build-time optimization — runs a data-driven iteration loop: measure baseline → analyze top offenders → apply ONE recipe → re-measure → verify nothing broke (build + types + tests + no regression) → commit or revert. Built for Next.js 16 with Turbopack default, and falls back to webpack-mode tooling when the project hasn't migrated yet. Triggers on phrases like "First Load JS is huge", "bundle size", "build takes too long", "page is slow to TTI", "reduce bundle", "tree-shake", or when the user shares output from `next experimental-analyze` / `@next/bundle-analyzer` — even if the user doesn't say "optimize" explicitly.
- License
- MIT
- Instructions
- 112 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (13)
- SKILL.md
- config.json
- gotchas.md
- metadata.json
- optimizations.md · references/
- workflow.md · references/
- _common.sh · scripts/
- analyze.sh · scripts/
- baseline.sh · scripts/
- compare.sh · scripts/
- diagnose.sh · scripts/
- measure.sh · scripts/
- verify.sh · scripts/
SKILL.md (first lines)
# Next.js Bundle & Build-Time Optimizer
Data-driven optimization loop for Next.js 16 applications. The skill orchestrates `next experimental-analyze`, builds, type checks, and tests to make verifiable improvements one change at a time.
## When to Apply
Use this skill when:
- The user wants to reduce bundle size / First Load JS / route bundles in a Next.js 16 app.
- Production builds are slow and the user wants to diagnose and fix the bottleneck.
- The user shares analyzer output, a screenshot of the treemap, or asks "why is `<X>` so big?"
- A new dependency was added and bundles grew — they want to understand why and unwind it.
- The user wants to set a performance budget and enforce it iteratively.
## Why iterative (not "apply all optimizations at once")
Bundle optimization is full of foot-guns. Examples:
- Moving a "client-only" dep behind `next/dynamic` can break SSR consumers that depended on its presence at first paint.
- `experimental.optimizePackageImports` with the wrong package can mis-resolve subpath exports.
- Aggressive `modularizeImports` regex rewrites can hit unintended modules.
- Narrowing the polyfill target can break older mobile browsers in production.
The only reliable way is: **one change, measure, verify, commit (or revert)**. This skill enforces that discipline through scripts.
## Prerequisites
- Next.js 16+ project (the skill auto-detects from `package.json`).
- `git` (the workflow uses commits as checkpoints and revert as rollback).
- `jq` available on PATH (used by analyze/compare scripts).
- A clean working tree before starting (the verify step uses `git status` to confirm).
- For projects still on Next.js 15 or earlier in webpack mode: the skill detects this and uses `@next/bundle-analyzer` instead of `experimental-analyze`. See [gotchas.md](gotchas.md).
## Setup
On first use, run:
```bash
bash scripts/baseline.sh --setup
```
This walks through `config.json` interactively. If `config.json` already has values, scripts use those and skip the prompts.
## Workflow Overview
```
┌── 1. baseline ──┐ Clean build, snapshot bundles + timing → baselines/{timestamp}/
│ │
│ 2. analyze ───┤ Run `next experimental-analyze --output`, extract top offenders
│ │
│ 3. diagnose ──┤ Map each offender to a recipe in references/optimizations.md
│ │
│ ── apply ─────┤ User (or agent) applies ONE recipe. Skill helps draft the change.
│ │
│ 4. measure ───┤ Re-build, re-analyze, save to iterations/{n}/
│ │
│ 5. compare ───┤ Diff vs baseline; flag regressions; print delta table
│ │
│ 6. verify ────┤ Build + tsc + tests + no overall regression. Hard PASS/FAIL.
│ │
│ commit OR ────┘ `git commit` (PASS+improvement) or `git revert` (FAIL/no win)
│ revert
│
└── loop back to step 2 with new baseline if you want a fresh measurement point.
```
Read [references/workflow.md](references/workflow.md) for the detailed loop with error handling, rollback procedures, and what each script's output looks like.
## Quick Reference
### Scripts (run from the Next.js app root)
| Script | Purpose | Output |
|--------|---------|--------|
| `scripts/baseline.sh` | Establish the reference point | `baselines/{ts}/{bundle,timing,manifest}.json` |
| `scripts/analyze.sh` | Run analyzer, parse top offenders | `iterations/{n}/findings.json` |
| `scripts/diagnose.sh [findings.json]` | Map findings → recipes | stdout: prioritized recipe list |
| `scripts/measure.sh` | Re-measure after a change | `iterations/{n}/{bundle,timing}.json` |
| `scripts/compare.sh [baseline] [current]` | Diff snapshots | stdout: delta table; exit 1 on regression |
| `scripts/verify.sh` | Full verification | exit 0 = safe to commit, exit 1 = revert |
### Optimization Recipes
[references/optimizations.md](references/optimizations.md) catalogs recipes by analyzer signal:
**Bundle size**
- Barrel-import bloat → `experimental.optimizePackageImports` (webpack) / auto in Turbopack
- Heavy client lib pulled in on every route → `next/dynamic({ ssr: false })`
- Server-only lib imported from a client component → move to Server Component
- Duplicate dependency versions → dedupe via `overrides` / `resolutions`
- Polyfill bloat → tighten `browserslist`
- Per-icon imports for icon libraries
**Build time**
- Enable `experimental.turbopackFileSystemCacheForBuild`
- Narrow `transpilePackages` (overuse balloons compile time)
- Split `tsc --noEmit` from `next build` in CI
- Identify single-file bottlenecks with `NEXT_TURBOPACK_TRACING=1`
Each recipe documents: **signal → fix → expected impact → verify step**.
## Gotchas
See [gotchas.md](gotchas.md) for accumulated failure points. Initially seeded with the most common Next.js 16 traps:
- `next build` no longer prints First Load JS — don't grep build output for it.
- `optimizePackageImports` is a no-op under Turbopack (default in 16) — Turbopack auto-optimizes.
- Comparing build times needs cache state controlled — either delete `.next/` (cold) or pre-warm (warm).
## Related Skills
- `vercel:nextjs` — general Next.js App Router guidance; consult for refactoring decisions while applying recipes.
- `vercel:turbopack` — for build-time debugging beyond what this skill covers.
- `vercel:next-cache-components` — when a recipe touches caching boundaries.From pproenca/dot-skills, MIT.
More from pproenca/dot-skills
- 0.694score
tanstack-query
community
TanStack Query v5 performance optimization for data fetching, caching, mutations, and query patterns.
SkillCFreshness: C★ 218Claude Code +9 - 0.596score
mlflow-3
pproenca
MLflow 3 (open-source, pinned to 3.15) for classic-ML MLOps — logging and registering models, promoting versions across dev/staging/prod, standing up a…
SkillBFreshness: B★ 218Claude Code +9 - 0.596score
ray
pproenca
Production Ray (open-source, pinned to 2.57) for classic-ML workloads from training to serving — Ray Train, Tune, Data, Serve, Core, and cluster deployment on…
SkillBFreshness: B★ 218Claude Code +9 - 0.596score
mlflow-mlops-migration
pproenca
Guided workflow for taking any ML codebase — including one with no experiment tracking at all, or one full of MLflow 2-era idioms — to a production-grade…
SkillBFreshness: B★ 218Claude Code +9 - 0.596score
ray-llm
pproenca
LLM workloads on open-source Ray (pinned to 2.57) — OpenAI-compatible serving with ray.serve.llm (vLLM-backed LLMConfig + build_openai_app) and batch…
SkillBFreshness: B★ 218Claude Code +9 - 0.550score
expo-ui
pproenca
Library reference for @expo/ui SwiftUI components on iOS — covers Host boundaries, modifier composition, iOS 26 Liquid Glass and Human Interface Guidelines…
SkillCFreshness: C★ 218Claude Code +9 - 0.550score
debug
pproenca
Comprehensive debugging methodology for finding and fixing bugs (formerly debugging).
SkillCFreshness: C★ 218Claude Code +9 - 0.550score
bug-review
pproenca
Use this skill when a user asks to review a pull request for bugs, wants AI code review focused on correctness issues, or runs /bug-review.
SkillCFreshness: C★ 218Claude Code +9 - 0.550score
ios-taste
pproenca
Designs iOS 18+ SwiftUI experiences with real taste — starting from user goals, not pixels.
SkillCFreshness: C★ 218Claude Code +9 - 0.550score
implementation-functional-patterns
pproenca
TypeScript's functional answers to the 22 Gang of Four classes — factory functions (Factory Method, Abstract Factory, Prototype, Memento), module-scope…
SkillCFreshness: C★ 218Claude Code +9 - 0.550score
expo
pproenca
Expo React Native performance optimization guidelines.
SkillCFreshness: C★ 218Claude Code +9 - 0.550score
deterministic-metric-design
pproenca
Inventing deterministic metrics — turning a fuzzy property like 'maintainability', 'risk', or 'how reducible this code is' into a deterministic, computable…
SkillCFreshness: C★ 218Claude Code +9
Signals
- Stars
- 218
- Forks
- 19
- Open issues
- 3
- Last commit (this folder)
- Jul 5, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/pproenca/dot-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from pproenca
- 0.596score
ray-llm
pproenca
LLM workloads on open-source Ray (pinned to 2.57) — OpenAI-compatible serving with ray.serve.llm (vLLM-backed LLMConfig + build_openai_app) and batch…
SkillBFreshness: B★ 218Claude Code +9 - 0.596score
mlflow-mlops-migration
pproenca
Guided workflow for taking any ML codebase — including one with no experiment tracking at all, or one full of MLflow 2-era idioms — to a production-grade…
SkillBFreshness: B★ 218Claude Code +9 - 0.596score
mlflow-3
pproenca
MLflow 3 (open-source, pinned to 3.15) for classic-ML MLOps — logging and registering models, promoting versions across dev/staging/prod, standing up a…
SkillBFreshness: B★ 218Claude Code +9 - 0.596score
ray
pproenca
Production Ray (open-source, pinned to 2.57) for classic-ML workloads from training to serving — Ray Train, Tune, Data, Serve, Core, and cluster deployment on…
SkillBFreshness: B★ 218Claude Code +9 - 0.550score
expo
pproenca
Expo React Native performance optimization guidelines.
SkillCFreshness: C★ 218Claude Code +9 - 0.550score
debug
pproenca
Comprehensive debugging methodology for finding and fixing bugs (formerly debugging).
SkillCFreshness: C★ 218Claude Code +9
Cite this page
nextjs-bundle-optimizer skill. Agent Mart. https://agentmart.dev/skills/pproenca-nextjs-bundle-optimizer (last updated 2026-10-24)