1 nextjs rules available
One Claude rule matches nextjs exactly: a Next.js expert rule covering the App Router and React. In Claude Code, scoping it with paths to app/ keeps App Router instructions out of sessions that only touch scripts or backend code.
Claude Code loads persistent project instructions from CLAUDE.md files and from Markdown rules in .claude/rules/. Rules can be scoped to file paths with a paths frontmatter field, and CLAUDE.md can import other files with @path syntax. The rules in this directory are written as plain instruction prompts: in Claude Code, save them as CLAUDE.md or .claude/rules/ content; in Claude.ai or the Claude API, use the same text as project instructions or a system prompt instead.
.claude/rules/nextjs.mdStarting point, not a tested configuration for your repository. Loaded when Claude Code works with files matching paths. Review the instructions, adapt the file paths and run your project's existing checks.
--- paths: - "app/**/*.ts" - "app/**/*.tsx" - "src/app/**/*.ts" - "src/app/**/*.tsx" --- # Next.js instructions for Claude Code ## Focus for this project - When adding a dynamic route, also add generateMetadata and a not-found path for unknown slugs. - Run the build or type check in the shell and report the actual result before declaring the task complete. - Do not convert an existing Server Component to a client component to fix an error; explain the boundary instead. ## Next.js conventions - Check package.json for the Next.js major version and whether the project uses app/ (App Router) or pages/ (Pages Router); follow the router that already exists instead of mixing them. - Files under app/ are Server Components by default. Add "use client" only at the smallest component that needs state, effects, event handlers or browser APIs. - From Next.js 15, params, cookies() and headers() are asynchronous, and so is searchParams in page files: await them in pages, layouts, route handlers and generateMetadata. - Put API endpoints in route.ts files that export named HTTP-method functions (GET, POST, ...), and validate request bodies before using them. ## Before you finish - Run the project's lint script and next build (type errors and invalid route exports fail the build) and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - You have shell access: run the checks yourself instead of asking the user to, unless a command needs credentials or would deploy.
Create your own Claude rules for Next.js and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Imports with @path can nest up to four hops deep, according to the docs. Claude Code can read AGENTS.md as project instructions without extra configuration, but by default only when there is no CLAUDE.md in the working directory or above it. The docs list this behavior for version 2.1.277 and later and describe a setting (claude-md-and-agents-md) that loads both files. If you maintain AGENTS.md for other tools, you can also import it from CLAUDE.md with @AGENTS.md.
Documentation checked 2026-11-05: Claude Code docs: Manage Claude's memory
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You ask Claude Code to add a dynamic route and want awaited params, generated metadata and a build check it runs itself.
Add app/blog/[slug]/page.tsx that renders a post from getPost(slug) and returns 404 for unknown slugs.
A page that awaits params, calls notFound() when getPost returns null, exports generateMetadata using the same lookup, and the real lint/build output from the session.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.