Cursor rules tell the agent how your project works. This page shows where they go, how the four rule types differ, and how to write one. The facts come from Cursor's rules docs, read on Nov 25, 2026. Check them for your version.
Where project rules live
Project rules live in .cursor/rules/ as .mdc files. They are version controlled, so check them into git.
One trap: a plain .md file in .cursor/rules is ignored, because it has no frontmatter. If you prefer plain Markdown, use AGENTS.md instead.
The four rule types
| Type | When it applies |
|---|---|
| Always Apply | Every chat session |
| Apply Intelligently | When the agent decides it is relevant, based on the description |
| Apply to Specific Files | When a file matches the globs pattern |
| Apply Manually | When you @-mention the rule in chat |
The frontmatter fields are description, globs and alwaysApply.
An example
This rule applies only to Python files in one folder:
---
description: API error response conventions
globs: app/routers/**/*.py
alwaysApply: false
---
- Use HTTPException with a detail message that has no internal details.
- Return 400 for bad input, 404 for a missing item, 409 for a conflict.
And this one is always on, so keep it very short:
---
description: Plain writing for docs and commits
alwaysApply: true
---
- Start with the answer. No warm-up line.
- Use plain words. No hype. Give numbers, not adjectives.
- No em dashes. No emoji at the start of list items.
Tips from the Cursor docs
- Keep each rule under 500 lines. Split big rules into smaller ones.
- Give a concrete example, or point to a file instead of copying its text.
- Do not copy a whole style guide. Use a linter.
- Do not document every command. The agent already knows
npm,gitandpytest. - Add a rule when you see the agent make the same mistake twice, not before.
Always-on rules cost tokens
A rule with alwaysApply: true goes into every chat. Give most rules a globs pattern or a description so they load only when needed. Our free Agent Cost Saver has a script, cost_audit.py, that adds up your always-on rules and tells you which to scope.
A free rule to start with
Anti-Slop Rules has a ready .mdc file (templates/anti-slop.mdc) that keeps the agent's READMEs, commits and PR text plain. Copy it to .cursor/rules/. It is MIT licensed.
Related guides
Made by Tidy Byte Tools.