Cursor Rules: Best Practices
Cursor rules are instruction files for the Cursor editor, scoped globally or by file-glob. The craft is scoping: always-on rules tax every request like a CLAUDE.md, while glob-scoped rules attach only when matching files are touched, making them the cheapest triggered behavior in any instruction format. Write rules with rationale and negative examples; both change how models weigh them.
Key takeaways
- Glob scoping is the format's superpower: a rule attached only to the files it governs costs zero context elsewhere.
- Rules with rationale outperform bare imperatives; models weigh justified constraints more heavily.
- Negative examples disambiguate faster than positive ones: show the failure the rule prevents.
- The .mdc format with frontmatter (description, globs, alwaysApply) superseded monolithic .cursorrules files.
- Community rule collections are corpora to mine, not systems to adopt; many encode stale framework advice.
The format, current
Modern Cursor rules live in .cursor/rules/ as .mdc files with frontmatter:
---
description: When this rule should influence edits
globs: ["src/**/*.sql"]
alwaysApply: false
---
# Parameterized queries only
[rule body with rationale and examples]The monolithic .cursorrules file still works and is where most published collections live, but the .mdc format's scoping is the reason to migrate: rules attach per file-glob instead of taxing every request.
Scoping is the craft
Every alwaysApply: true rule is a line of context spent on every request, relevant or not, which is the same context tax a bloated CLAUDE.md pays. Glob-scoped rules cost zero until a matching file is touched.
The discipline: glob-scoped by default, always-on by exception. Universal constraints (security posture, license headers) earn alwaysApply; everything stack-specific belongs to its globs. A rule about SQL applied while editing CSS is noise at best and misdirection at worst.
Writing rules that work
Three properties separate rules that change behavior from rules that decorate a repo:
- Rationale. Models weigh justified constraints more heavily than bare imperatives, and the humans maintaining the rules file need the why to know when the rule expired. "Parameterized queries only, because string-built SQL reached production twice in 2025" outlives "write safe SQL."
- A negative example. Show the failure the rule prevents. Negative examples disambiguate faster than positive ones, exactly as they do in skill authoring.
- One concern per rule. Multi-topic rules fire on the wrong globs and get half-applied. Split them.
The template carries this structure with annotations.
Mining the community collections
The original corpus and the .mdc collection are worth mining and dangerous to adopt wholesale: both are aggregators without review rubrics, and a meaningful fraction of entries encode framework advice that has since expired. The workflow that works: find your stack's entry, read it as a draft, delete what a linter already enforces, verify the remaining claims against current docs, and add your rationale lines.
Relationship to the rest of the identity layer
Cursor rules straddle the instruction-file boundary: always-on rules are identity (like CLAUDE.md content), glob-scoped rules behave like lightweight triggered skills. If multiple agent tools touch the repo, keep shared conventions in one canonical file (usually AGENTS.md) and let the Cursor rules carry only the Cursor-specific and glob-triggered parts. Divergent conventions across tools are worse than either alone, because each agent trusts what it read.
Frequently asked questions
What are Cursor rules?
Instruction files (.cursor/rules, .mdc format) applying persistent conventions and glob-triggered behaviors to Cursor's AI edits.
alwaysApply or glob-scoped?
Glob-scoped by default. Reserve alwaysApply for genuinely universal constraints; every always-on rule taxes every request.
How do Cursor rules relate to CLAUDE.md?
Same identity layer, different runtime, plus scoping: always-on rules mirror CLAUDE.md content, glob rules behave like lightweight skills. Keep shared conventions in one canonical place if both tools touch the repo.
Summary
- Topic
- Cursor rules best practices
- Definition
- Scoped instruction files for Cursor: global or glob-triggered conventions with rationale
- Best used for
- Stack-specific conventions that fire only where relevant
- Common mistakes
- Everything alwaysApply, rules without rationale, adopting stale community rules unreviewed
- Related concepts
- Cursor rules, instruction file, trigger conditions
- Recommendation
- Glob-scope by default, include rationale and a negative example, review mined rules for freshness