Feature Comparison
| Template | Use when | Suggested file |
|---|---|---|
| Project baseline | Every repo needs commands and core conventions | .cursor/rules/project.mdc |
| Frontend React or Next.js | Components, routes, styling, accessibility | .cursor/rules/frontend.mdc |
| Backend API | Routes, services, database access, auth boundaries | .cursor/rules/backend.mdc |
| Monorepo package | Different packages have different commands | .cursor/rules/package-name.mdc |
| Testing | Test naming, fixtures, mocks, and commands | .cursor/rules/tests.mdc |
| Review guardrails | Prevent risky edits and unrelated churn | .cursor/rules/review.mdc |
Directory Structure
Keep rules close to the repository and name files by the workflow or area they govern.
.cursor/
rules/
project.mdc
frontend.mdc
backend.mdc
tests.mdc
review.mdcProject Baseline Template
Use this as the first rule in a new repository, then customize the commands to match the actual package manager.
--- description: Project baseline rules globs: ["**/*"] --- Use the existing architecture before adding new abstractions. Prefer small, reviewable diffs. Run the narrowest relevant test first, then run the full build before release. Do not edit generated files unless the task explicitly requires it.
Frontend Template
Scope frontend rules to app and component files so Cursor sees them when it edits UI code.
---
description: Frontend rules
globs: ["app/**/*", "components/**/*", "src/**/*.{tsx,jsx,css}"]
---
Use existing components and design tokens before creating new patterns.
Keep interactive states accessible.
Check mobile layout for text wrapping and overflow.
Run npm run build after route or component changes.Backend Template
Backend rules should name ownership boundaries and data safety expectations.
---
description: Backend API rules
globs: ["api/**/*", "server/**/*", "src/**/*.{ts,js}"]
---
Keep validation close to request boundaries.
Do not widen auth or database permissions without explicit review.
Prefer existing service helpers before adding new clients.
Run targeted API tests for route, schema, or migration changes.Generate A Custom Rule
Use the local generator when you want a project-specific .cursor/rules/project.mdc file with stack, commands, style, and review expectations filled in.
FAQ
Where should Cursor Rules live?
Project rules commonly live under .cursor/rules in the repository, with one or more .mdc files.
Should I create many Cursor Rules files?
Only when scope helps. Start with project.mdc, then split by frontend, backend, tests, or package when the instructions differ.
Can Cursor Rules include commands?
Yes. Good rules include real install, lint, test, typecheck, and build commands that apply to the files being edited.
Should Cursor Rules be committed?
Usually yes, if they represent team conventions and do not include secrets or local-only paths.