Guide
What you get: The agent builds App Router pages the way the rules say: Server Components by default, async params awaited, generateMetadata with a canonical URL, a small client form posting to a Server Action validated with your library, not-found.tsx for missing pages, and a test. Best for Teams on Next.js App Router who want Cursor (or any agent that reads a rules/context file) to stop writing client-side data fetching and ad-hoc spinners..
Before you start
- A Next.js App Router project
- Your validation library installed (we used zod)
- A working test command (we added Vitest: npm test)
- Cursor: save as .cursor/rules/nextjs.mdc. Claude Code/Codex: paste the rules into CLAUDE.md / AGENTS.md
Worked example (Nov 14, 2026, Claude Code 2.1.318 (claude-opus-5-5); Codex 0.151.0 (gpt-5.6-sol))
Input
create-next-app 16.4.6 starter (cacheComponents on) plus lib/posts.ts and Vitest. Filled with validation_library=zod, test_command=npm test. Task: add /blog, /blog/[slug] with a proper not-found page, and a newsletter signup form saving emails via a new lib/subscribers.ts.
Result
Claude Code: `const { slug } = await params;` ... `alternates: { canonical: `/blog/${post.slug}` }` and a 'use client' NewsletterForm using useActionState with a 'use server' action. Codex: same structure, zod schema in lib/subscribers.ts, plus actions.test.ts.Not tested in Cursor or Copilot: the rule text was saved verbatim (front matter included) as CLAUDE.md for Claude Code and AGENTS.md for Codex, the files those agents load at startup, plus a copy at its normal path. Both runs: npm test, npm run lint and next build passed when we re-ran them; no useEffect data fetching; zod validation on the server; only the form is a client component; both added metadataBase to the root layout because a relative canonical needs it. Runtime check with next start: /blog and posts return 200 with the canonical link; an unknown slug shows the not-found page with noindex but HTTP 200, which is documented Next.js 16 behaviour when notFound() runs after streaming starts (not something the rules cover). Codex also read installed personal skills; Claude Code's reply echoed the tester's personal ~/.claude/CLAUDE.md wording (no project files affected).
How to check it worked
- Run lint, tests and the build after the agent finishes
- grep the diff for useEffect and 'use client': client components should only be the interactive leaves
- Open an unknown slug and check the status code, not just the page text
Common problems
- Relative alternates.canonical without metadataBase in the root layout: the agent has to add one (both did)
- Unknown slugs can return HTTP 200 with the not-found UI under cacheComponents/streaming; the rules don't mention it
- Leftover {{validation_library}} or {{test_command}} gets repeated literally
Log in to join the discussion.