Cursor rules for Next.js (core)
A free, always-on Cursor rule (.mdc) for Next.js 16 + TypeScript + Tailwind: minimal diffs, strict TypeScript, no invented APIs, and a real definition of done.
- Install
.cursor/rules/00-core.mdc- Last tested
- Next.js 16.4.1 / Cursor · 2026-10-15
This is the always-on core rule from ToolTier's Next.js Cursor rules. It's set to alwaysApply, so Cursor includes it in every request in the project. It covers the habits that matter on any task: make the smallest change that works, read similar files before editing, keep TypeScript strict, and validate external input at the boundary.
Its main job is to stop the agent from falling back on older Next.js patterns from its training data. It tells Cursor to check the docs bundled in node_modules/next/dist/docs/ and the installed types before using an API it isn't sure about, and to ask instead of inventing one.
The definition of done makes the agent run typecheck, lint and build (and tests, if you have them) before it says a task is finished, and say which checks it skipped. If your scripts are named differently, edit the commands to match your package.json.
00-core.mdc---
description: Core principles for this Next.js 16 + TypeScript + Tailwind project
alwaysApply: true
---
# Core: Next.js 16 project
Stack: Next.js 16 (App Router), React 19, TypeScript 5 (strict), Tailwind CSS 4, pnpm. Node.js 20.9 or newer.
## Ground truth beats memory
- Your training data likely predates Next.js 16. Before using a Next.js API you're not certain about, read the matching guide in `node_modules/next/dist/docs/` (the managed block in `AGENTS.md` points there). Prefer the bundled docs over memory when they disagree.
- Never invent an API, config key or file convention. If you can't find it in the bundled docs or the installed package's types, say so and ask.
## How to work
- Make the smallest change that solves the task. Don't rename, reformat or "improve" unrelated code.
- Before editing, read the files you'll touch and one similar existing file, and match its patterns.
- Explain any new dependency in one sentence before adding it. Prefer the platform (Web APIs, React, Next.js) over a new package.
- Keep components and functions small. Colocate files with the route that uses them under `app/`.
## TypeScript
- `strict` mode. No `any`; use `unknown` and narrow it. No non-null `!` unless you've just checked the value.
- Use the generated route type helpers: `PageProps<'/route/[param]'>`, `LayoutProps<'/route'>`, `RouteContext<'/api/route/[param]'>`. Run `pnpm next typegen` if they're missing.
- Validate all external input (form data, search params, request bodies, webhook payloads, env vars) with zod at the boundary.
## Definition of done
A task is done only when all of these pass:
1. `pnpm tsc --noEmit`
2. `pnpm lint` (ESLint runs directly; `next lint` no longer exists in Next 16 and `next build` doesn't lint)
3. `pnpm build`
4. Tests for the changed behavior, if the project has tests
If you can't run them, say which ones you didn't run. Never claim a build passes without running it.
## Output
- Summarize what you changed by file, and anything you chose not to do.
- If a requirement is ambiguous, state your assumption at the top of your answer.
12 scoped Cursor rules, AGENTS.md and CLAUDE.md for Next.js 16.4 with Cache Components. This free entry is one file; the pack is the full multi-file set.