What Are Cursor Rules
Understanding Cursor Rules
Cursor rules are declarative configuration files that define how Cursor AI behaves within your project. They act as persistent instructions that shape every AI interaction — from code generation and refactoring to code review and debugging. Rather than repeating context in every prompt, rules encode your project's standards once and apply them automatically.
Types of Cursor Rules
1. Project Rules (.cursor/rules/)
The modern approach uses a .cursor/rules/ directory containing .mdc files. Each rule file can target specific file patterns (globs), apply conditionally, and describe exactly when and how Cursor should apply the instruction. This is the recommended format for new projects.
2. Legacy .cursorrules
The older .cursorrules file is a single markdown document in the project root. It applies globally to all interactions within the project. While supported for backward compatibility, it lacks per-file targeting.
If your project still uses this format, follow the .cursorrules to Cursor Project Rules migration guide to split it into scoped .mdc files without losing your existing instructions.
3. AGENTS.md
AGENTS.md is an emerging standard for AI coding assistant instructions. It serves a similar purpose to Cursor rules but is designed to be portable across different AI tools (Cursor, Codex, Copilot, etc.).
What Can Cursor Rules Control?
- Coding style and conventions (indentation, naming, patterns)
- Framework and library preferences
- Testing requirements (framework, coverage expectations)
- Documentation standards
- Security and performance constraints
- Project architecture and file organization rules
- Response format and tone preferences
Cursor Rules vs Linters vs Documentation
| Tool | Primary job | When it helps |
|---|---|---|
| Cursor rules | Guide AI generation | Before code is written |
| Linters | Detect violations | After code is generated or edited |
| Documentation | Explain intent | For humans and onboarding |
Example Rule Categories
## Architecture
- Keep business logic out of route handlers.
- Use services/ for integrations and lib/ for pure helpers.
## Testing
- Add unit tests for parsing and generation logic.
- Use integration tests for critical user flows.
## Code Review
- Prefer small focused changes.
- Explain trade-offs when modifying shared abstractions.Next Steps
Ready to create your own rules? Use the Cursor Rules Generator to build rules from templates, or read our project rules guide for detailed configuration examples. Browse templates to find pre-built rule sets for your tech stack.
Frequently Asked Questions
- What are Cursor rules used for?
- Cursor rules give Cursor AI persistent project instructions, including style, architecture, testing, and framework-specific conventions.
- Do Cursor rules replace linters and formatters?
- No. Linters and formatters enforce code after it is written, while Cursor rules guide AI generation before code is produced.
- Should Cursor rules be committed to git?
- Project rules and team .cursorrules files should usually be committed so every contributor gets consistent AI behavior.