11 / 12
The bundled documentation, AGENTS.md, MCP, error prompts and the Next.js skills.
Next.js has changed quickly over the last two years. A model's training data is usually older than the installed version, and it suggests the old patterns.1 The older forms of the changes in this guide, as they commonly turn up in AI output:
| Old advice | In Next.js 16.4 |
|---|---|
middleware.ts | proxy.ts |
export const revalidate = 60, dynamic = "force-static" | "use cache" and cacheLife |
params.slug | const { slug } = await params |
import { useRouter } from "next/router" | next/navigation |
reset() in error.tsx | retry() |
next lint | eslint |
getServerSideProps | await in a Server Component |
The Next.js team decided to solve this from inside the framework. Since 16.2, every release has come with separate tooling for agents.23
Since Next.js 16.2 the documentation ships inside the package, under node_modules/next/dist/docs/. It matches the installed version exactly and needs no internet. Since 16.3, create-next-app and next dev write a block into the project's root AGENTS.md that points the agent at that folder:1
<!-- BEGIN:nextjs-agent-rules -->
## This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ
from your training data. Read the relevant guide in `node_modules/next/dist/docs/`
before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->Next.js only manages the part between the markers; you can write your own rules in the rest of the file. To turn it off, set agentRules: false in next.config.ts.4
Why AGENTS.md rather than a skill? In Vercel's evaluation for Next.js 16, a compressed documentation index embedded in AGENTS.md passed 100% of the tests, while the skill-based approach reached 79% at best. In 56% of the cases the agent never called the skill at all.5 The conclusion: information that is always in the context beats information the agent has to go looking for.
Tip
Claude Code does not read AGENTS.md if there is a CLAUDE.md in the directory. If you use both, import it by writing @AGENTS.md inside CLAUDE.md. Rule files are covered in the Prompt and context engineering lesson.
If the agent cannot reach node_modules: every documentation page on nextjs.org returns plain Markdown with a .md extension, and /docs/llms.txt offers an index.1
With Cache Components on, a blocking error arrives with tagged fixes. The same list appears in the development overlay, in the terminal and in the next build output, which means an agent reading the CI logs sees it too:1
Route "/products/[slug]": Next.js encountered uncached data during prerendering.
Ways to fix this:
- [stream] Provide a placeholder with `<Suspense fallback={...}>` around the data access
- [cache] Cache the data access with `"use cache"`
- [block] Set `export const instant = false` to allow a blocking route
Learn more: https://nextjs.org/docs/messages/blocking-prerender-dynamicThe Copy prompt button on the error screen turns the fix you chose into an instruction to paste to an agent. The Learn more pages are written for agents to read too: the pattern for each fix, its trade-off, and the points people miss on a first attempt.1
For an agent to verify its change, it needs to know what both the framework and the browser see:16
next dev writes the browser console's errors and warnings to the terminal as well, so the agent sees client errors in output it already reads.
The dev server opens an MCP endpoint at /_next/mcp. An agent connected with next-devtools-mcp reads the routes, the errors and the compilation problems; it can ask whether the code compiles without running next build. Setting it up is in the MCP lesson.
The next-dev-loop skill adds the browser's DOM, console and network views through the agent-browser CLI. Because it starts with React DevTools open, it also reads the component tree and the pending Suspense boundaries.
The documentation provides knowledge; skills sequence multi-step jobs. The Next.js team's own skills:17
| Skill | What it does |
|---|---|
next-dev-loop | Verifies in the running dev server and the browser after every edit |
next-cache-components-adoption | Migrates an existing application to Cache Components, checking with you at each step |
next-cache-components-optimizer | Grows a page's static shell; it writes a failing instant() test first |
next-partial-prefetching-adoption | Migrates the application to Partial Prefetching |
next-bundle-optimizer | Looks at Turbopack's bundle analysis and shrinks the client bundle (16.4) |
$ pnpm dlx skills add vercel/next.js --skill next-dev-loop"After every edit, verify with the next-dev-loop skill that the page works."
The method of the optimizer skills is a good habit: describe the behaviour you want in a test first, change things until the test passes, and commit the test so that a future change that breaks it gets caught.1 The general rules for writing a skill are in the Skills lesson.
next upgrade --agent gathers the new version's migration guides and hands the work to the agent; the agent makes the change and verifies the application. In 16.4 it is experimental and works with the canary release:8
npx next@canary upgrade --agent=latestDo
Ask the agent to read AGENTS.md and node_modules/next/dist/docs/ first.
Require it to run npm run lint, tsc --noEmit and next build before it says it is done.
Compare the code it suggests against the table above; if you see an old pattern, give the agent the relevant documentation page.
In a folder with no AGENTS.md, ask an AI tool to "cache the product page in Next.js so that it refreshes every 60 seconds". Then make the same request in a project created with create-next-app. Compare the answers with the rows in the table.
Read uncached data outside a <Suspense> on a page. Paste the Copy prompt from the error screen to an agent and see which fix it picks.
Connect next-devtools-mcp and ask the agent to "list the routes in the project".
Official docs: "How Next.js supports AI coding agents"; the bundled documentation, the error guides, MCP, the skills and agent feedback.1
Article: Vercel's "AGENTS.md outperforms skills in our agent evals"; how the evaluation was set up and why the skills fell behind.5
Official docs: the AI announcements for Next.js 16.2 and 16.3; which release brought which of these tools, and why.23
Sources
The bundled documentation, the `AGENTS.md` block, `.md` and `llms.txt`, tagged error fixes, runtime visibility and the Next.js skills.
March 18, 2026. The bundled documentation and the first tools for agents to use the browser.
June 26, 2026. The documentation through `AGENTS.md`, the first Next.js skills, the Agent Browser and the focused MCP server.
The managed instruction block, turning it off, and the version history.
January 2026. A documentation index in `AGENTS.md` at 100%, skills at 79% at best, and the skill not being called in 56% of the cases.
`/_next/mcp`, `next-devtools-mcp` and the runtime tools.
The source of the Next.js team's skills.
`next upgrade --agent` and the upgrade policies.
Check the lesson's main ideas with three questions.
Your progress is stored only in this browser.
Last updated: November 3, 2026