Skip to content

/next-cache-components-optimizer

Optimize the meaningful UI available immediately from a Next.js route on an initial load (hard navigation) or named client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route and entry point at a

From plugin
nextjs
143k6 skills

Claude Code

$ npx -y skills add vercel/next.js --skill next-cache-components-optimizer --agent claude-code

SKILL.md

next-cache-components-optimizer.SKILL.md
name: next-cache-components-optimizer
description: >
  Optimize the meaningful UI available immediately from a Next.js route on an
  initial load (hard navigation) or named client-side navigation (soft
  navigation). Encode the goal as a failing @next/playwright instant() e2e and
  work it to green, one verified route and entry point at a time; the shipped
  test then guards against regression. Use when asked to grow a static shell,
  fix a slow first paint or non-instant navigation, diagnose which Suspense
  boundary blocks useful UI, or add instant() regression coverage. Requires
  Next.js 16.3+ with Cache Components already adopted.

next-cache-components-optimizer

Set up an agentic optimization loop that drives a Next.js route from "not instant" to "instant" and keeps it there. The loop is test-driven: encode the goal as a failing `@next/playwright` `instant()` test, work it to green, and ship the test as the regression guard. Run it once per target route and entry point. Work the phases P → G in order; each ends in a gate.

Before changing the route, read the bundled **Optimizing the static shell** guide at `node_modules/next/dist/docs/01-app/02-guides/optimizing-the-static-shell.md`. If it is unavailable, use the [online guide](https://nextjs.org/docs/app/guides/optimizing-the-static-shell). The guide owns the framework behavior and implementation patterns. This skill owns the navigation contract, production rig, trustworthy RED-to-GREEN loop, parity check, differential, and report.

What is invariant, and what is yours

One thing here is fixed. The rest is yours. Read this before treating any command, platform, or env var below as a requirement.

  • **Invariant: the verification loop.** Maximizing the shell is worthless

unless you can prove it. The proof is an automated check: under a lock that gates dynamic data, the static shell still commits. RED shows the gap, GREEN shows it closed, the test ships as the regression guard. It must run on a production-like build and must not be able to pass vacuously. Stand the loop up once; every later optimization is then verifiable by construction. The loop is the deliverable, not any one route.

  • **The mechanism: `@next/playwright` `instant()`.** This skill uses

[`instant()`](https://nextjs.org/docs/app/guides/instant-navigation#prevent-regressions-with-e2e-tests) as a ruler, not a stopwatch (phase A). It comes from `@next/playwright` (installed alongside `@playwright/test`, on the same release line as `next`), so it isn't tied to any host. Keep it. Timing a navigation by hand is too flaky to trust, and is the failure mode this skill exists to prevent.

  • **Yours: the rig.** How you build, deploy, authenticate, configure

Playwright, and loop belongs to your stack, not to this skill. A local `next build && next start`, a CI/staging container, and a per-push preview deploy are equally valid rigs; the verdict comes from the build, never the platform. Phase 0 maps the invariant onto your repo. Read every platform name, env-var spelling, and command below as an example to translate, not a requirement.

Two entry points, two instant UI contracts

A route reaches the user two ways:

  • **Initial load (hard navigation)** commits the route's prerendered static

shell; deferred parts stream in behind their loading skeletons (Suspense fallbacks, `loading.tsx`).

  • **Client-side navigation (soft navigation)** reuses shared layouts and

commits the available App Shell for the destination segments that change.

The same implementation patterns can make either entry point instant. The test differs only in how the navigation is driven ("Driving the navigation in tests" below), and the available UI can differ because a soft navigation reuses layouts above the source and destination's divergence point. Guard the entry point the user named, and both when both matter. See [What "instant" means](https://nextjs.org/docs/app/guides/instant-navigation#what-instant-means).

This skill is therefore not limited to increasing the direct-load static shell. It can also fix a non-instant client navigation when caching reusable work or moving request-time work behind a focused boundary makes the destination's available App Shell commit immediately. When that App Shell is already instant and the goal is to fetch additional URL-specific content before the click, hand off to `next-partial-prefetching-optimizer`.

Goal

Make the most meaningful available App Shell UI commit immediately, and let only genuinely request-time work stream afterward. The shipped test deterministically encodes **present ∧ instant**. **Non-blank** is the additional bar the workflow enforces by judgment because an `instant()` pass alone is satisfied by an empty shell.

`instant()` is a ruler, not a stopwatch: assert that the shell appears under the lock; do not time it. A trustworthy verdict requires a production build (phase A).

The GREEN under the lock is the deterministic verdict; each gate keeps it trustworthy.

Reporting to the user

This loop is meant to run unattended, so it doesn't stop to ask between steps. Work the navigation the user named, finish it, and stop. What matters is how you word and present the results, not how often you interrupt. The mechanics below — the rig, RED, GREEN, the gates — are your scaffolding; the user never needs to hear those words.

  • **Speak their language.** Describe the gap and the result in terms of what the

user sees: "navigating to the dashboard waited on the charts query before anything painted; now the layout and skeletons paint instantly and the charts stream in" — not RED/GREEN, the lock, or the phase letters.

  • **Show, don't tell.** When you report a route, drive the browser (or attach

before/after screenshots) so the user watches the shell commit immediately and the data stream in, rather than reading a claim. Identical before and after means the fix did nothing — roll it back.

  • *
Read more
@vercel
Ships withnextjs

The React Framework

Stars on GitHub

Momentum

stars in total
143.4k
Star history of vercel/next.js on GitHub, a chart by star-history.com

Other skills on nextjs.

next-bundle-optimizer
Auto-invoked

next-bundle-optimizer

Audit and reduce Next.js browser initial-load work. Use for slow route startup, oversized client bundles, duplicate browser…

@vercel@vercelInstall Skill
next-cache-components-adoption
Auto-invoked

next-cache-components-…

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt,…

@vercel@vercelInstall Skill
next-dev-loop
Auto-invoked

next-dev-loop

Verify Next.js runtime behavior after editing app code. Use this skill to confirm a change actually works in a running app — not…

@vercel@vercelInstall Skill

More skills from other plugins.

migrate-radix-to-base

migrate-radix-to-base

Migrates React projects and components from Radix UI to Base UI. Use when asked to migrate from radix, move to base-ui, convert…

ui10d127k
@shadcn-ui@shadcn-uiInstall Skill
chrome-release-cls

chrome-release-cls

Given a Chrome Releases blog post URL (chromereleases.googleblog.com), extract every CVE/bug and find the underlying Gerrit CL…

electron1d124k
@electron@electronInstall Skill
taste-skill
Auto-invoked

taste-skill

tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One…

@leonxlnx@leonxlnxInstall Skill
angular-developer

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, services, or HTTP…

angular11d101k
@angular@angularInstall Skill

Questions about next-cache-components-optimizer.

Which coding agents can use next-cache-components-optimizer?
next-cache-components-optimizer installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.