Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pproenca avatar

Nextjs Bundle Optimizer

  • 86 installs
  • 191 repo stars
  • Updated July 24, 2026
  • pproenca/dot-skills

nextjs-bundle-optimizer is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.

Key points

  • nextjs-bundle-optimizer
  • AI & Agent Building
  • AI-coding skill

Nextjs Bundle Optimizer by the numbers

  • 86 all-time installs (skills.sh)
  • +6 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #5,032 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pproenca/dot-skills --skill nextjs-bundle-optimizer

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs86
repo stars191
Last updatedJuly 24, 2026
Repositorypproenca/dot-skills

How do I helps with ai & agent building tasks during ai-assisted development?

Helps with ai & agent building tasks during AI-assisted development.

Who is it for?

Best when you're working on ai & agent building and need structured help with nextjs-bundle-optimizer.

Skip if: Teams with no ai & agent building needs, or anyone wanting a generic chat assistant without this specific workflow.

When should I use this skill?

When you need to helps with ai & agent building tasks during ai-assisted development, or when nextjs-bundle-optimizer is a claude code skill for ai & agent building. it helps solo builders move faster with ai-assisted coding.

What you get

Structured output aligned to nextjs-bundle-optimizer: nextjs-bundle-optimizer; AI & Agent Building; AI-coding skill.

Files

SKILL.mdMarkdownGitHub ↗

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.

Setup

On first use, run:

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 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)

ScriptPurposeOutput
scripts/baseline.shEstablish the reference pointbaselines/{ts}/{bundle,timing,manifest}.json
scripts/analyze.shRun analyzer, parse top offendersiterations/{n}/findings.json
scripts/diagnose.sh [findings.json]Map findings → recipesstdout: prioritized recipe list
scripts/measure.shRe-measure after a changeiterations/{n}/{bundle,timing}.json
scripts/compare.sh [baseline] [current]Diff snapshotsstdout: delta table; exit 1 on regression
scripts/verify.shFull verificationexit 0 = safe to commit, exit 1 = revert

Optimization Recipes

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 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.

Related skills

FAQ

What does nextjs-bundle-optimizer do?

nextjs-bundle-optimizer is a Claude Code skill for ai & agent building. It helps developers move faster with AI-assisted coding.

When should I use nextjs-bundle-optimizer?

When you need to helps with ai & agent building tasks during ai-assisted development, or when nextjs-bundle-optimizer is a claude code skill for ai & agent building. it helps developers move faster with ai-assisted coding.

What are the main capabilities?

nextjs-bundle-optimizer; AI & Agent Building; AI-coding skill.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.