How to Set Up Custom Rules in Cursor
Configure Cursor rules to enforce coding conventions, project patterns, and AI behavior with .cursorrules files.
Step-by-step
How to Set Up Custom Rules in Cursor
Create a .cursorrules file
Create a `.cursorrules` file in your project root. This file tells Cursor's AI about your project conventions, preferred patterns, and rules to follow — similar to CLAUDE.md for Claude Code.
Define your coding conventions
Write plain language rules: 'Always use TypeScript strict mode', 'Prefer functional components over class components', 'Use snake_case for database columns'. Cursor follows these in all AI-generated code.
Add project-specific context
Include information about your tech stack, key file paths, and architectural decisions. Example: 'This is a Next.js 14 app using App Router, Tailwind CSS, and Prisma ORM.'
Set global rules in Cursor Settings
For rules that apply across all projects, go to Cursor Settings → General → 'Rules for AI'. These rules are always active regardless of which project you have open.
Tips
Pro tips
- *
Keep .cursorrules concise — 20-50 lines is ideal. AI performance degrades with very long rule files
- *
Commit .cursorrules to git so your team shares the same AI behavior
- *
Use specific, actionable rules ('use Zod for validation') rather than vague guidelines ('write clean code')
Related guides