mit einem Klick
next-ppr-optimizer
// Optimize the static shell of a `cacheComponents` page. Use this skill when a Next.js page feels slow on first paint and you want to maximize what's prerendered before any dynamic data streams in.
// Optimize the static shell of a `cacheComponents` page. Use this skill when a Next.js page feels slow on first paint and you want to maximize what's prerendered before any dynamic data streams in.
Backport a merged Next.js pull request from canary to a previous release branch such as next-16-2. Use when the user asks to backport, cherry-pick, or open a backport PR from a PR number to an older Next.js version. Covers finding the merged PR commit, creating a backport branch from the target release branch, cherry-picking from canary, validating, and opening the PR with the release branch as the base.
Create Git branches, commits, pushes, and GitHub pull requests for Next.js. Use when the user asks to create a branch, commit current changes, open a PR or draft PR, publish a pull request, or recover from gh pr create / PR template issues. Covers .github/pull_request_template.md, --body formatting, NEXT_JS_LLM_PR, codex/ branch names, and Codex app git directives.
Verify Next.js runtime behavior after editing app code. Use this skill to confirm a change actually works in a running app โ not just that it compiles or type-checks. Combines /_next/mcp (Next.js's view) with agent-browser (the browser's view). Requires a running `next dev`.
How to create and maintain agent skills in .agents/skills/. Use when creating a new SKILL.md, writing skill descriptions, choosing frontmatter fields, or deciding what content belongs in a skill vs AGENTS.md. Covers the supported spec fields, description writing, naming conventions, and the relationship between always-loaded AGENTS.md and on-demand skills.
DCE-safe require() patterns and edge runtime constraints. Use when writing conditional require() calls, guarding Node-only imports (node:stream etc.), or editing define-env-plugin.ts / app-render / stream-utils for edge builds. Covers if/else branching for webpack DCE, TypeScript definite assignment, the NEXT_RUNTIME vs real feature flag distinction, and forcing flags false for edge in define-env.ts.
How to add or modify Next.js experimental feature flags end-to-end. Use when editing config-shared.ts, config-schema.ts, define-env-plugin.ts, next-server.ts, export/worker.ts, or module.compiled.js. Covers type declaration, zod schema, build-time injection, runtime env plumbing, and the decision between runtime env-var branching vs separate bundle variants.
| name | next-ppr-optimizer |
| description | Optimize the static shell of a `cacheComponents` page. Use this skill when a Next.js page feels slow on first paint and you want to maximize what's prerendered before any dynamic data streams in. |
The agentic optimization loop for PPR: diagnose the shell, pick the highest-ROI refactor, apply it, confirm the shell actually grew.
Two refactor levers:
decide for the
autonomy threshold.'use cache' and pick a cacheLife
profile. Freshness is a domain judgment โ never invent a profile;
always ask the user with the named presets.The hard part is prioritization: rank candidates by the visible pixel area they cover. Largest gap first.
next-dev-loop already initiated for this session.cacheComponents: true in next.config.ts. Without it there's
no static shell to optimize โ refuse.cacheComponents: true in next.config.ts. The
user-driven browser session from next-dev-loop's preflight
must already be open at the target URL.next-instant-navigation-testing
cookie via agent-browser cookies set โ pass name and value as
separate positional args, not as a name=value blob. Value
format [0,"p<random>"], scoped to the dev server hostname.
Reload.
While the cookie is held, dynamic streaming pauses and what's
visible equals the static shell + Suspense fallbacks.Sanity-check the view. Confirm the visible content is the
shell, not the dev error overlay (which can paint a sparse
viewport that mimics a partially-suspended shell). Any of these
signals means it's a no-shell state โ surface the bailout from
mcp get_logs (look for NEXT_STATIC_GEN_BAILOUT /
blocking-route) and stop:
mcp get_page_metadata returns segments: [] or
routerType: "pages" on what should be an app route.List candidates. agent-browser react suspense lists every
Suspense boundary on the current page and points at the JSX
site. The source paths are compiled chunks; resolve them to
user source via POST /__nextjs_original-stack-frames (the
endpoint the dev error overlay uses). That returns user file +
line + column for each boundary, including ones declared in
layouts and in imported component files. Blocker classification
is a soft hint only โ plain fetch() often classifies as
unknown โ so rely on the resolved JSX site and the source you
read, not on the classification.
Rank by rendered area. Take both renders: shell-only (instant cookie set) and full (instant cookie removed by name โ see teardown). For each candidate, use the larger of its fallback rect (shell-only) and rendered subtree rect (full) as the per-candidate ROI. Sort descending. The fallback rect alone misleads when developers used an undersized spinner.
If one boundary dominates, re-diagnose deeper. When a
candidate's rect covers roughly the entire viewport AND it's
the only dynamic boundary, push-down is not the move โ that
wrapper is the shell. Resolve the boundary's JSX site, read
the source it wraps, recurse into the wrapped component, and
enumerate each await and each async child. Those are the
real candidates; loop back to step 3 with them.
For each candidate, pick a lever.
cacheLife profile (seconds, minutes, hours,
days, weeks, max, or default). Never invent.Trivial push-down: extract the awaited call into an async child;
replace the parent with a sync function rendering the static
shell plus <Suspense fallback={โฆ}> around the new child; pass
the values the child needs as props.
Cache: insert 'use cache' at the top of the function body, then
cacheLife('<profile>') from the agreed preset.
Re-take the shell-only render. The targeted candidate's gap should be strictly smaller, or gone (content promoted to shell). If neither, undo โ a refactor that compiles but doesn't grow the shell is still a regression. Then re-run the diagnose-step-1 check โ a botched extract can introduce a no-shell state where there wasn't one before.
cacheLife presets live in
packages/next/src/server/config-shared.ts โ the source of
truth if the user asks what each preset means.next-instant-navigation-testing cookie freezes streaming; what's
visible = static shell + fallbacks
POST /__nextjs_original-stack-frames compiled chunk URL + line/col
โ user file + line/col
cacheLife('<profile>') default | seconds | minutes | hours
| days | weeks | max
Remove the next-instant-navigation-testing cookie by name. Do
not use agent-browser cookies clear (no args) โ that wipes the
user's auth and any other session state.
Sibling of next-dev-loop โ initiate that first. Pick the loop
that matches the work: next-dev-loop for general edit/verify,
next-ppr-optimizer for shell-area optimization.