Cursor rules
Also called cursorrules file, .cursorrules
Cursor rules are project-level instructions stored in your repository that Cursor applies to every AI request — conventions, framework versions, patterns to follow, things never to do. They live in .cursor/rules, replacing the older single .cursorrules file, and travel with the repo so the whole team inherits them.
The purpose is to stop you restating the same context in every prompt. Anything you have typed twice — "use the repository pattern", "never use default exports", "we are on Tailwind v4" — belongs here rather than in a prompt.
Good rules are specific and falsifiable. "Write clean code" does nothing. "Server components by default; add 'use client' only when a hook or event handler requires it" changes output on every request.
What this means in practice
The newer .cursor/rules directory allows multiple scoped files rather than one flat list, so rules can apply to particular paths. If you are still on a single .cursorrules file it continues to work, but splitting it by area makes each rule apply where it belongs.
A .cursor/rules file worth starting from
# Stack Next.js 15 App Router, TypeScript strict, Tailwind. No new dependencies without asking. # Conventions - Server components by default; add "use client" only when a hook or event handler requires it. - Named exports only. No default exports outside app/ route files. - Data access goes through lib/db.ts. Never import the driver directly. - Errors: throw typed AppError from lib/errors.ts; never return null to signal failure. # Verification After any multi-file change, run: npm run lint && npm run typecheck. A change is not done until both pass. # Never - Never edit files in app/api/webhooks/ without being asked explicitly. - Never commit; leave staging to me.
Replace the stack line and the data-access path with yours; keep the Verification and Never sections — they change behaviour more than the conventions do.
Prompts for the tools this applies to
Related terms
- CLAUDE.md
CLAUDE.md is a Markdown file in your repository that Claude Code reads at the start of every session.
- AGENTS.md
AGENTS.md is a tool-neutral convention for a Markdown file in a repository that gives AI coding agents the project context they need — build commands, conventions, architecture, and constraints.
- Custom instructions
Custom instructions are standing directions you give an AI tool that apply to every request rather than a single one — preferred language and framework, response style, conventions to follow.
- Context engineering
Context engineering is the practice of deciding what information an AI model sees for a given task — which files, which conventions, which prior results — and in what form.