.cursorrules — Custom Rules for Cursor
The .cursorrules file is a project-level configuration that tells Cursor how to write code for your specific codebase. It’s loaded into every AI interaction, giving Cursor persistent context about your project’s conventions and preferences.
What problem does it solve?
Every project has its own coding style — naming conventions, framework preferences, architectural patterns, and rules. Without explicit guidance, AI assistants default to generic patterns that may not match your codebase. A .cursorrules file ensures Cursor follows your project’s standards on every interaction.
How it works
Place a .cursorrules file at your project root. Cursor reads it automatically and applies the rules to all AI-generated code. The file is plain text with natural language instructions.
Cursor also supports .mdc rules
In addition to the global .cursorrules file, Cursor supports .cursor/rules/*.mdc files for more granular, file-pattern-specific rules. Each .mdc file can target specific file types or directories and includes frontmatter for metadata.
Tips for effective rules
- Be specific — “use Tailwind” is better than “use good styling”
- Include your tech stack explicitly
- Describe your project structure so the agent knows where to put files
- Add error handling and testing preferences
- Keep it under 2000 tokens — it’s loaded on every prompt
Similar formats in other tools
| Tool | Rules file |
|---|---|
| Cursor | .cursorrules |
| Claude Code | CLAUDE.md |
| Windsurf | .windsurf/rules |
| Cline | .clinerules |
| GitHub Copilot | .github/copilot-instructions.md |
Related specs
Cursor Documentation
Learn more about .cursorrules and rules configuration in the Cursor docs.
Read the Cursor rules documentation