/nextjs-ai-skills:next-best-practicesfrom nextjs-ai-skills
Provides Next.js App Router best practices covering file conventions, RSC boundaries, async APIs, data patterns, hydration errors, metadata, route handlers, and image/font optimization. Includes security advisory checks and version-specific guidance for Next.js 16.
Ships in nextjs-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Read the installed next version and relevant node_modules/next/dist/docs/
pages before changing framework behavior. Those docs and project configuration
take precedence; use a matching online version/source tag when local docs are
unavailable. Next.js publishes workflow skills in vercel/next.js skills/.
Docs are bundled from 16.2; in a monorepo, read the app's own next package.
The nextjs.org links in these files have local equivalents with numbered
folders, so search by file name (find node_modules/next/dist/docs -name proxy.md).
01-app/02-guides/upgrading/version-16.md lists the breaking changes.
Per-error pages (/docs/messages/*) are only online; the dev/build output
carries the error's fix options.
Exact exports are also in node_modules/next/{server,navigation,headers,cache}.d.ts.
Before other work, compare the installed version with Next.js security
advisories and tell the user when it is affected. As of 2026-11-09 the patched
releases are 16.4.5 and 15.5.29. 16.0.0–16.4.0 and 15.x up to 15.5.27 have
critical RCEs: use cache functions returning typed arrays
(GHSA-673q-mjm6-r5xr, 16.x only, no workaround) and self-hosted image
optimization of SVGs on glibc Linux (GHSA-2464-fhr4-w9xw; interim fix: sharp
0.35.5+), plus a Server Actions DoS (GHSA-p3m5-59mp-jv5r); 16.4.1 and 15.5.28
fixed those. Seven medium advisories of 2026-11-03 remain through 16.4.4 and
15.5.28: cross-user use cache disclosure (GHSA-rhh4-g77r-r9qj and three more,
16.x only), cross-client response injection when self-hosted
(GHSA-pc58-hwjq-p385), an image-optimization SVG bypass and an Edge-route
cookie exposure. From 16.4,
experimental.agentUpgrade (default 'security') reminds during
next dev/next build; 16.3.x and older get no reminder.
cookies(), headers(), draftMode(),
params (including image-metadata routes), searchParams and sitemap id
are promises. next typegen generates global PageProps<'/route'>,
LayoutProps and RouteContext types.middleware.ts is deprecated: proxy.ts exporting proxy (or default)
runs on Node.js only and rejects a runtime option; code that needs Edge
stays in middleware.ts. Codemod: npx @next/codemod@latest middleware-to-proxy ..dev and build; a custom webpack config
fails the build unless --webpack keeps it or explicit --turbopack ignores
it. next lint is removed and
next build no longer lints. serverRuntimeConfig/publicRuntimeConfig
are removed.default.tsx, or the build fails.next/image: priority is deprecated for preload; qualities defaults to
[75] (other quality values are coerced); local src with a query string
needs images.localPatterns; images.domains is deprecated for
remotePatterns.revalidateTag(tag) is deprecated; pass a profile such as 'max' or
{ expire: 0 } for immediate expiry. updateTag and refresh are Server
Action-only. Caching details: cache-components.The params and proxy shapes, checked against next 16.3.8 (next typegen,
tsc --noEmit, next build):
// app/blog/[slug]/page.tsx; PageProps is global after `next typegen` (or dev/build)
export async function generateStaticParams() {
return [{ slug: 'hello' }] // cacheComponents: needed for this top-level await; never []
}
export default async function Page({ params }: PageProps<'/blog/[slug]'>) {
const { slug } = await params // a Promise; sync access was removed in 16
return <h1>{slug}</h1>
}
// proxy.ts, replacing middleware.ts: Node.js runtime, no `runtime` export
import { NextResponse, type NextRequest } from 'next/server'
export function proxy(request: NextRequest) {
// Optimistic check only: authorize again where the data is read.
if (request.cookies.has('session')) return NextResponse.next()
return NextResponse.redirect(new URL('/login', request.url))
}
export const config = { matcher: ['/dashboard/:path*'] }
The upgrade codemod does not migrate synchronous request-API access; run
next-async-request-api separately when migrating that code. Use the project's
package runner and review the resulting types and runtime behavior.
For an authorized upgrade, npx next@canary upgrade [app-dir] --agent=security
(or =latest; experimental, documented from 16.4 in the installed
02-guides/upgrading/agent-upgrade.md) selects the target and prints its guides,
codemods and checks for the current agent; plain next upgrade runs the
interactive codemods.
Review the actual failure or feature, rather than applying every optimization. Keep the project's router, caching mode, runtime and package manager unless migration is requested.
| Area | Local reference |
|---|---|
| Route files, groups, proxy | File conventions |
| Server/client imports and props | RSC boundaries, directives |
| Params and request APIs | Async APIs, functions |
| Reads, mutations and APIs | Data patterns, Route Handlers |
| Rendering and failures | Suspense, hydration, errors |
| Metadata and public discovery | Metadata; nextjs-seo for an SEO audit |
| Assets and loading | Images, fonts, scripts |
| Package/runtime behavior | Bundling, runtime |
| Navigation slots/modals | Parallel routes |
| Deployment/debugging | Self-hosting, diagnostics |
Use cache-components when that mode is enabled and relevant to the task.
Tag invalidation can also operate on fetch caches outside that mode.
Validate with the project's lint/typecheck scripts and a production build,
then exercise the changed route under next start. A dev render can
hide prerender/Suspense issues; a build cannot prove authorization, hydration,
freshness or cross-instance behavior. Report what was actually exercised.
async-patterns.md (opens in a new tab)bundling.md (opens in a new tab)data-patterns.md (opens in a new tab)debug-tricks.md (opens in a new tab)directives.md (opens in a new tab)error-handling.md (opens in a new tab)file-conventions.md (opens in a new tab)font.md (opens in a new tab)functions.md (opens in a new tab)hydration-error.md (opens in a new tab)image.md (opens in a new tab)metadata.md (opens in a new tab)parallel-routes.md (opens in a new tab)route-handlers.md (opens in a new tab)rsc-boundaries.md (opens in a new tab)runtime-selection.md (opens in a new tab)scripts.md (opens in a new tab)self-hosting.md (opens in a new tab)suspense-boundaries.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub laguagu/claude-code-nextjs-skills --plugin nextjs-ai-skills24 skills in this plugin
/agent-harness-reviewReviews an agent harness or agent design against Anthropic's agent and model prompting guidance (Opus 5.5, Fable 5.2), Cognition's context principles and 2026 research on skill routing and skill-induced failures. Covers when subagents or parallel agents pay off, how to brief them, how many skills, plugins, MCP servers and hooks load every session, tool design and proportionate verification. Use when auditing a Claude Code or Codex setup, deciding whether to add subagents or a multi-agent workflow, trimming a skill library, or designing an agent loop in an app. For writing a new skill or measuring a skill's trigger rate with evals, use skill-creator./ai-appBuilds full-stack Next.js AI applications with the AI SDK and the shadcn/ui AI Elements patterns. Use when creating a chatbot, agent dashboard or custom AI application./ai-elementsMaintains AI chat UI built from elements.ai-sdk.dev AI Elements components already copied into the project. Use when changing or debugging those components (conversations, messages, prompt inputs, attachments, reasoning, tool output, sources). New chat UI uses the shadcn/ui AI Elements patterns (`shadcn` skill)./ai-sdkAnswer questions about the AI SDK and help build AI-powered features. Use when developers ask about Vercel AI SDK, generateText, streamText, ToolLoopAgent, useChat, AI SDK providers, tools, structured output, embeddings or streaming, or want to add AI features to a TypeScript or JavaScript app. First identify the installed major version and route version-specific work: use ai-sdk-7 for AI SDK 7 features/migrations such as WorkflowAgent, HarnessAgent, reasoning, runtime/tools context, toolApproval, telemetry, realtime, or v6-to-v7 upgrades; for v6 code read the docs shipped in the installed package./ai-sdk-6Vercel AI SDK v6 development, for projects already on ai@6. Use when building or maintaining AI agents, chatbots, tool integrations, streaming apps, or structured output in a v6 codebase. New projects and ai@7 code use ai-sdk-7; an unknown version goes through ai-sdk. Covers ToolLoopAgent, useChat, generateText, streamText, tool approval, provider tools, MCP integration, and Output patterns./ai-sdk-7Vercel AI SDK v7 development and migration. Use when building or upgrading AI SDK 7 apps, especially ToolLoopAgent, WorkflowAgent, HarnessAgent, Claude Code/Codex/Pi harnesses, runtimeContext, toolsContext, toolApproval, telemetry, reasoning, file or skill uploads, realtime, video generation, or v6-to-v7 breaking changes. For version discovery, v6 code and general doc lookup use ai-sdk.Other plugins' skills for the same job