next-cache-components-optimizer

Optimizes Next.js routes for instant navigation using test-driven Cache Components workflows.

Updated Sep 16, 2026
One-click install
npx skills add https://github.com/jasonviipers/vipers --skill next-cache-components-optimizer-jasonviipers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-cache-components-optimizer
Source: https://github.com/jasonviipers/vipers/tree/main/.agents/skills/next-cache-components-optimizer
Command: npx skills add https://github.com/jasonviipers/vipers --skill next-cache-components-optimizer-jasonviipers

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @next/playwright, @playwright/test, next, and includes references (resource) components.

What problem does it solve? Next.js routes often block navigation on dynamic data reads, forcing users to wait for the entire page before anything paints. This Skill drives a route to instant navigation by maximizing its prerendered static shell under Cache Components, using a failing @next/playwright instant() test as the goal and shipping that test as a regression guard. ## Core Features & Use Cases - Test-driven optimization loop: Encodes the goal as a failing instant() e2e test (RED), pushes Suspense boundaries down to the data they guard (FIX), and verifies with a differential revert/re-apply check before shipping. - Fix pattern library: Provides before/after recipes for common blockers including top-level awaits in layouts, cookies()/headers() reads, uncached fetches, searchParams, non-deterministic values, and dynamic metadata. - RED trustworthiness gates: Includes a robustness checklist and taxonomy of false REDs (guessed selectors, flag-gated markers, stale deployments, vacuous passes) so optimization effort lands on real problems. - Use Case: A dashboard route waits on a charts query before painting anything. The Skill sets up a production-build rig, writes a locked instant() test, defers the query behind a Suspense boundary reusing the existing skeleton, and ships the green test as a regression guard. ## Quick Start Ask the agent to make a specific route's navigation instant using the next-cache-components-optimizer skill, and it will set up the rig, write the failing instant() test, fix the route, and verify the result.

Frequently Asked Questions about next-cache-components-optimizer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make a Next.js route navigation instant with Cache Components?

Write a failing @next/playwright instant() test that asserts the route's static shell commits under the navigation lock, then push each Suspense boundary down to the specific dynamic read it guards. The route is done when the locked test passes green on a production build and a revert differential confirms the test measures the fix.

How to fix a Next.js route whose static shell is not prerendered?

Identify the blocking read with next build --debug-prerender, which prints an insight link per blocker. Common fixes include moving top-level awaits into Suspense-wrapped children, starting cookies() reads without awaiting, caching stable data with 'use cache', and deferring auth gates behind a boundary.

What Next.js version is required for Cache Components and instant() tests?

Next.js 16.3 or later with cacheComponents: true in next.config.ts is required, plus @next/playwright on the same release line as next. The production build must also enable experimental.exposeTestingApiInProductionBuild, otherwise instant() silently no-ops and tests pass vacuously.

Why does my instant() test pass but the navigation still blocks?

A green instant() test is meaningless if the build lacks the testing API, since the lock never engages and the test passes vacuously. Use the self-validating variant that also asserts deferred content is gated under the lock, and confirm exposeTestingApiInProductionBuild was set at build time.

Can I measure instant navigation on next dev?

No, next dev does not prefetch and its lock is unreliable for blocking routes, so dev-mode instant() results are not valid RED or GREEN verdicts. Always measure on a production build served by next start or an equivalent deployed artifact.

When should I use per-link prefetching instead of growing the static shell?

Use per-link prefetching only when the whole route depends on URL data like params or searchParams that cannot move behind a boundary. It requires Partial Prefetching adoption, a Link with prefetch={true}, and URL-dependent content behind 'use cache'; otherwise prefer the cheaper static shell approach.