Cursor rules are instructions that Cursor includes at the start of the model’s context, so Agent follows your conventions without you repeating them in every chat. Project rules are .mdc files in .cursor/rules, each with a few frontmatter fields that decide when it applies. Cursor’s documentation describes them as persistent, reusable context at the prompt level, because models do not retain memory between completions.
The four kinds of rules
Cursor supports four types of rules.
| Type | Where it lives | Scope |
|---|---|---|
| Project rules | .cursor/rules, version-controlled | One codebase |
| User rules | Customize, then Rules | Every project, used by Agent (Chat) |
| Team rules | Cursor dashboard, on Team and Enterprise plans | Everyone on the team |
| AGENTS.md | Plain Markdown file in the project | One project, no metadata |
When several apply, Cursor merges them in this order: Team Rules, then Project Rules, then User Rules, and earlier sources take precedence when guidance conflicts. Admins can also enforce a team rule so members cannot turn it off.
Anatomy of a project rule
A project rule is a Markdown file with frontmatter. The extension matters: Cursor says project rules must use .mdc, and a plain .md file in .cursor/rules is ignored because it has no frontmatter to specify description, globs and alwaysApply. You can name the files anything and group them in folders.
.cursor/rules/
react-patterns.mdc recognized
api-guidelines.md ignored
frontend/
components.mdc recognizedThree fields decide when a rule is included, and the Cursor docs spell out how they combine:
| Rule type in the UI | alwaysApply | description | globs | Behavior |
|---|---|---|---|---|
| Always Apply | true | ignored | ignored | Included in every chat session |
| Apply to Specific Files | false | not needed | set | Attached when a matching file is in context |
| Apply Intelligently | false | set | omitted | Agent reads the description and pulls the rule in when relevant |
| Apply Manually | false | omitted | omitted | Included only when you @-mention the rule |
Here is the glob example from the docs:
---
globs: src/components/**/*.tsx
alwaysApply: false
---
- Use named exports, not default exports
- Co-locate styles in a module CSS file next to the componentGlobs take comma-separated patterns. **/*.ts matches .ts files in any directory, src/** matches everything under src/, and docs/**/*.md, docs/**/*.mdx matches both extensions under docs/.
How to create one
Cursor offers two ways to create a rule. Type /create-rule in Agent and describe what you want, and Agent writes the file with frontmatter into .cursor/rules. Or open Customize, go to Rules and click Add Rule. Customize also shows every rule and its status.
What makes a good rule
The docs put it in one line: “Good rules are focused, actionable, and scoped.” The specific advice:
- Keep rules under 500 lines and split large ones into composable rules.
- Give concrete examples or referenced files, and avoid vague guidance.
- Reference files instead of copying their contents, so the rule stays short and does not go stale.
- Reuse a rule when you keep repeating the same prompt in chat.
A file mention such as @migration-template.sql only tells Agent where to look. Agent reads the file with its tools when it needs it, and the contents are not inlined into the prompt. Anything that must always be in context belongs in the rule body.
What to leave out
Cursor lists four things to avoid:
- Copying entire style guides. The docs say to use a linter instead, since Agent already knows common style conventions.
- Documenting every possible command, because Agent knows common tools like npm, git and pytest.
- Instructions for edge cases that rarely apply.
- Duplicating what is already in the codebase. Point to canonical examples instead.
The docs also say to “Start simple” and to add rules only when Agent keeps making the same mistake. Check them into git so the team shares them, and update a rule when Agent gets something wrong.
Rules, AGENTS.md and skills
Cursor describes AGENTS.md as a plain Markdown file without metadata, an alternative to .cursor/rules for straightforward cases. It works in the project root and in subdirectories, where nested files combine with their parents and the more specific one takes precedence. Pick project rules when you need the frontmatter controls above, such as applying only to certain files. For the file format itself and how other tools read it, see What is AGENTS.md?
Agent Skills are a separate feature. A skill is a folder containing a SKILL.md file, kept in .cursor/skills/ for a project or ~/.cursor/skills/ for you, and Agent decides when a skill is relevant from context. Cursor also ships a /migrate-to-skills command that converts eligible dynamic rules and slash commands into skills.
Rules do not affect Cursor Tab or other AI features.
Bringing in rules from a repository
Cursor says rules are not imported on their own. To use rules from a GitHub repository, package them in a plugin and publish it through a marketplace, then install the plugin. For a ready-made collection of rule files in MDC format, see Awesome Cursor Rules MDC.
Related
For why loading instructions up front helps, and when agents fetch context on demand instead, see What is context engineering?