Agent skill

Nextjs Bundle Optimizer

by pproenca in pproenca/dot-skills

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…

MITAuto-check passedFrontend & Design

Install Nextjs Bundle Optimizer

skills CLI
$ npx skills add pproenca/dot-skills --skill nextjs-bundle-optimizer -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install pproenca/dot-skills nextjs-bundle-optimizer --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/pproenca/dot-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.experimental/nextjs-bundle-optimizer .claude/skills/nextjs-bundle-optimizer && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
nextjs-bundle-optimizer
GitHub stars
214
Token cost
~1.5k tokens
SKILL.md length
536 words
Files
13 (incl. scripts, references)
Skills in repo
182
Repo updated
First seen
Licence
MIT

At a glance

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…

  • Phrases like First Load JS is huge
  • SKILL.md covers When to Apply, Why iterative (not "apply all…, Prerequisites and Setup, plus 4 more sections
  • Runs Shell scripts from its folder; calls bash, git and tsc
  • Build takes too long

What it does

Nextjs Bundle Optimizer is an agent skill from pproenca/dot-skills. 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…

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 14 other files, including scripts and reference files (for example `config.json`, `gotchas.md` and `metadata.json`).

It sits in Frontend & Design, covering Web performance. It works with Next.js, webpack and Turborepo. The repository describes itself as: A collection of AI agent skills following the Agent Skills open format. The licence is MIT.

When your agent uses it

  • Phrases like First Load JS is huge
  • Build takes too long
  • Page is slow to TTI
  • The user shares output from next experimental-analyze / @next/bundle-analyzer — even if the user doesnt say optimize explicitly

Example prompts

  • “t migrated yet. Triggers on phrases like”
  • “bundle size”
  • “build takes too long”
  • “/nextjs-bundle-optimizer”

Requirements

  • A Bash shell

What it can do on your machine

Read from SKILL.md and the folder at commit cf93c57. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 7 files in scripts/ (Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • bash
    • git
    • tsc

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Nextjs Bundle Optimizer loads about 1.5k tokens when it runs, and up to ~7.3k if it reads all its reference files. Until then it costs about 169 tokens; SKILL.md has 536 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~169
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from pproenca/dot-skills at commit cf93c57, republished under its MIT licence (© pproenca). 536 words, ~1,526 tokens.

Download SKILL.mdSave it as .claude/skills/nextjs-bundle-optimizer/SKILL.md (or your agent's skills folder). This skill also uses 12 other files; get the full folder from GitHub.
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.

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

Show full SKILL.md (234 more words)Show less
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).
  • 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.

© pproenca, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 12 other files (scripts, references) in skills/.experimental/nextjs-bundle-optimizer of pproenca/dot-skills.

  • SKILL.md
  • config.json
  • gotchas.md
  • metadata.json
  • references/optimizations.md
  • references/workflow.md
  • scripts/_common.sh
  • scripts/analyze.sh
  • scripts/baseline.sh
  • scripts/compare.sh
  • scripts/diagnose.sh
  • scripts/measure.sh
  • scripts/verify.sh

Open the folder on GitHubat commit cf93c57

Compare with similar skills

Nextjs Bundle Optimizer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Nextjs Bundle Optimizer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Nextjs Bundle Optimizer this skillpproenca/dot-skills214—~1.5kAutomated safety check: PassMIT
Phy Bundle Size AuditLeoYeAI/openclaw-master-skills2.2k—~4.9kAutomated safety check: PassApache-2.0
Core Web VitalsvmDeshpande/ai-agent-automation1784 repos~3.6kAutomated safety check: PassMIT
Runtime DebugOpenHikmah/openhikmah-web181—~618Automated safety check: PassGPL-3.0
Sanity Best Practicesrobotostudio/turbo-start-sanity182—~940Automated safety check: PassMIT
Bun Buildinvolvex/youtube-music-cli456—~2.1kAutomated safety check: NotesMIT

Similar skills

  • Phy Bundle Size Audit

    LeoYeAI/openclaw-master-skills

    JavaScript bundle size auditor and budget enforcer. An agent skill from LeoYeAI/openclaw-master-skills.

    2.2k GitHub stars~4.9k tokensUpdated 2 mo ago
    Frontend & DesignAuto-check passed
  • Core Web Vitals

    vmDeshpande/ai-agent-automation

    Optimize Core Web Vitals (LCP, INP, CLS) for better page experience and search ranking.

    178 GitHub starsUsed in 4 repos~3.6k tokens
    Frontend & DesignAuto-check passed
  • Runtime Debug

    OpenHikmah/openhikmah-web

    Debug and verification workflow for runtime-bundle and module-resolution regressions.

    181 GitHub stars~618 tokensUpdated today
    DevelopmentAuto-check passed
  • Sanity Best Practices

    robotostudio/turbo-start-sanity

    Sanity development best practices for schema design, GROQ queries, TypeGen, Visual Editing, images, Portable Text, Studio structure, localization, migrations, Sanity Functions, Blueprints, and…

    182 GitHub stars~940 tokensUpdated yesterday
    Frontend & DesignAuto-check passed
  • Bun Build

    involvex/youtube-music-cli

    Create optimized production bundles with Bun's native bundler.

    456 GitHub stars~2.1k tokensUpdated yesterday
    Frontend & DesignAuto-check: notes
  • Prd To Plan

    Dwlad90/stylex-swc-plugin

    Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved as a local Markdown file in ./plans/.

    111 GitHub stars~767 tokensUpdated yesterday
    Product & Project ManagementAuto-check passed

More from pproenca/dot-skills

All 182 skills in this repo
  • Audio Voice Recovery

    pproenca/dot-skills

    Audio forensics and voice recovery guidelines for CSI-level audio analysis.

    214 GitHub stars~3.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Codemod React Pipeline

    pproenca/dot-skills

    Guided, scripted pipeline for running JSX/TSX/React codemods safely across large legacy codebases.

    214 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Dev Rfc

    pproenca/dot-skills

    Create well-structured RFCs and technical proposals for software projects.

    214 GitHub stars~3.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Dx Harness

    pproenca/dot-skills

    Developer-experience friction auditing and fixing — slow onboarding, repeated manual setup steps, missing bootstrap/reset/seed scripts, undiscoverable conventions.

    214 GitHub stars~1.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Language Spec Author

    pproenca/dot-skills

    Turn a rough idea for a language into a complete, implementable specification — a DSL, query, config/data, template, or protocol language — by interviewing the author dimension by dimension until…

    214 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Python Pep Author

    pproenca/dot-skills

    Drafting Python Enhancement Proposals (PEPs) — proposing a Python language feature, a standard library change, an interoperability standard, or an informational/process document for the Python…

    214 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Nextjs Bundle Optimizer

What does Nextjs Bundle Optimizer do?

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…. Nextjs Bundle Optimizer is an agent skill from pproenca/dot-skills.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.

When should I use Nextjs Bundle Optimizer?

Nextjs Bundle Optimizer fits situations like: phrases like First Load JS is huge; build takes too long; page is slow to TTI; the user shares output from next experimental-analyze / @next/bundle-analyzer — even if the user doesnt say optimize explicitly.

How do I install Nextjs Bundle Optimizer in Claude Code?

Run `npx skills add pproenca/dot-skills --skill nextjs-bundle-optimizer -a claude-code`. Or copy the skill folder (skills/.experimental/nextjs-bundle-optimizer in pproenca/dot-skills) into .claude/skills/nextjs-bundle-optimizer in your project. Claude Code loads it when a task matches its description.

How do I install Nextjs Bundle Optimizer in Codex?

Run `npx skills add pproenca/dot-skills --skill nextjs-bundle-optimizer -a codex`. Or copy the skill folder (skills/.experimental/nextjs-bundle-optimizer in pproenca/dot-skills) into .agents/skills/nextjs-bundle-optimizer in your project. Codex loads it when a task matches its description.

Can I use Nextjs Bundle Optimizer in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add pproenca/dot-skills --skill nextjs-bundle-optimizer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/nextjs-bundle-optimizer, .gemini/skills/nextjs-bundle-optimizer, .github/skills/nextjs-bundle-optimizer and .opencode/skills/nextjs-bundle-optimizer in your project.

What does Nextjs Bundle Optimizer need to run?

Going by SKILL.md and its folder, Nextjs Bundle Optimizer needs a shell for the scripts in its folder and the command-line tools its instructions call (bash, git and tsc). Our summary lists: A Bash shell.

Does Nextjs Bundle Optimizer access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Nextjs Bundle Optimizer safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Nextjs Bundle Optimizer use?

Nextjs Bundle Optimizer is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Nextjs Bundle Optimizer use?

About 1.5k tokens (SKILL.md is roughly 6.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 5.7k tokens, read only when the agent opens those files.

What are the alternatives to Nextjs Bundle Optimizer?

Skills that share tags, products or a category with Nextjs Bundle Optimizer: Phy Bundle Size Audit (LeoYeAI/openclaw-master-skills, 2.2k stars), Core Web Vitals (vmDeshpande/ai-agent-automation, 178 stars), Runtime Debug (OpenHikmah/openhikmah-web, 181 stars) and Sanity Best Practices (robotostudio/turbo-start-sanity, 182 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Nextjs Bundle Optimizer?

pproenca (a GitHub user) maintains it in pproenca/dot-skills, which has 214 GitHub stars. The repository holds 182 skills in this directory. The repository was last updated on August 15, 2026.

Source: pproenca/dot-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.