Cursor Rules: Where They Live, How They Apply, Examples
Short answer
Cursor rules tell its coding assistant, called Agent, how to work. For a project, save each rule as an .mdc file in .cursor/rules; a plain .md file there is ignored. The settings block at the top controls when the rule loads. Set alwaysApply: true to load it in every chat, add globs to load it for matching files, write a description so Agent can pick it when it is relevant, or leave both empty so it loads only when you mention it. For simple project instructions, use AGENTS.md in the project root.

Before you start
Open the project in Cursor and decide which instruction you want Agent to follow. You need permission to add files to the project. Use a harmless task for the first check so you can see whether the rule appears without risking live code.
Five terms you need
These words explain the settings and tests used in the steps below.
- Agent is Cursor's coding assistant.
- Context means the files and instructions available in the current chat.
- Frontmatter is the settings block between the dashed lines at the top of an
.mdcfile. - A glob is a file pattern. For example,
src/api/*.tsmatches TypeScript files in one folder. alwaysApplyis the frontmatter field that loads a rule in each chat when it is set totrue.
The four places Cursor reads rules from
Pick the source by scope: one project, all your projects, a team account or a folder tree.
Rule source | Where it lives | Who it affects |
|---|---|---|
Project Rules | | People working in that codebase |
User Rules | Cursor's Customize settings | Your Agent chats across projects |
Team Rules | Cursor dashboard | Team or Enterprise accounts |
| Project root or subdirectory | Work under that directory |
Use Project Rules when the instruction needs a settings block or file matching. Use AGENTS.md when a plain shared instruction file is enough.
Step 1: create the .mdc rule file
In Agent, type /create-rule and describe the instruction. Cursor creates a file with a settings block and saves it in .cursor/rules. You can also add the file yourself. Folders inside .cursor/rules help separate areas such as the user interface, API and tests.
The extension matters. Project rules must end in .mdc. Cursor ignores a plain .md file in that folder because it has no rule frontmatter.
A small project can use this layout. Each file shows one application mode in Step 2:
.cursor/
rules/
always-typescript.mdc
api-validation.mdc
migration-guidance.mdc
api-compatibility.mdcAfter saving, you should see the new .mdc file in the project tree under .cursor/rules.
Step 2: choose how the rule applies
The frontmatter decides whether Cursor loads a project rule in each chat, by topic, by matching file or only when asked.
Type | Frontmatter | When it loads |
|---|---|---|
Always Apply | | Every chat; description and globs are ignored |
Apply Intelligently | Description only | Agent chooses it when the description is relevant |
Specific Files | Globs set | A matching file is in context |
Manual | No description or globs | You mention the rule in chat |

The following copy-ready files are our examples, built from Cursor's documented fields.
Our examples (illustrative)
always-typescript.mdc
---
alwaysApply: true
---
Use TypeScript for new source files.alwaysApply: true
Use TypeScript for new source files.
alwaysApply: true makes this rule load in every chat.
migration-guidance.mdc
---
description: Use when changing database tables
alwaysApply: false
---
Include a way to undo each database change.description: Use when changing database tables
alwaysApply: false
Include a way to undo each database change.
The description lets Agent choose this rule when a task is relevant.
api-validation.mdc
---
globs: src/api/*.ts
alwaysApply: false
---
Check request input with the project's current rules.globs: src/api/*.ts
alwaysApply: false
Check request input with the project's current rules.
The glob makes this rule attach when a matching API file is in context.
api-compatibility.mdc
---
alwaysApply: false
---
Check that public response fields still work for current users.alwaysApply: false
Check that public response fields still work for current users.
With no description and no glob, this rule loads only when you mention @api-compatibility.
Step 3: scope the rule with globs
Use a glob when an instruction belongs to a file family. Separate multiple patterns with commas. Keep the pattern narrow enough that unrelated tasks do not inherit the rule.
Intent | Example glob |
|---|---|
TypeScript files in the API folder | |
All test files | |
React components and tests | |
A glob rule attaches when a matching file is in context. If the rule is about database changes, do not use a pattern that matches the whole project.
When you open or mention a matching file, you should see Agent follow the scoped instruction. A non-matching file should not pull in that rule.
Step 4: test it on a real task
Ask Agent to do something the rule covers, then read the answer for the behavior you required. If the rule refers to another file, the mention tells Agent where to look. Cursor does not paste that file's text into the chat request.
Rule type | Check that it loaded | What you should see |
|---|---|---|
| Start a new chat and request a small code change. | The output follows the rule without a mention. |
| Ask for a database table change. | Agent follows the described guidance on the relevant task. |
| Put a file matching | The output follows the scoped rule for that file. |
| Type | Agent follows the named rule in that chat. |
If the expected behavior is absent, return to the file extension, frontmatter and current context before rewriting the rule.

Why is my Cursor rule not being applied?
Start with the file, then check the application mode and the current task context.
- Wrong extension: rename a project rule from
.mdto.mdc. - Wrong folder: project rules belong in
.cursor/rules. - Missing description: an intelligent rule needs a description Agent can use.
- Glob mismatch: confirm that a file in context matches the pattern.
- Manual rule not mentioned: mention the rule in the chat.
- Referenced file assumed to be pasted: the mention points Agent to the file, but does not paste its text into the chat request.
AGENTS.md, User Rules and Team Rules
AGENTS.md is a plain shared file without a settings block. Cursor supports it in the project root and in folders below it. A small file can be enough:
# Project instructions
Run the unit tests for the package you change.
Keep public API changes safe for current users.User Rules are personal rules set on Cursor's Customize screen and used across projects. Team Rules are available to Team and Enterprise accounts from the Cursor dashboard. A team member cannot turn off an enforced Team Rule on the Customize screen.
Writing rules that stay useful
Cursor recommends keeping a rule under 500 lines and starting small. Add a rule when Agent repeats the same mistake, not for every preference you can imagine. Point to the main policy file instead of copying a long policy that will drift.
Rules guide an AI system; they do not control access. Keep access controls, tests, code review and automated checks in place. If you are choosing between coding agents rather than configuring one, see our Cursor versus Claude Code guide.
Where Xtrusio fits
The test above shows what Agent did. Xtrusio shows how AI tools describe your brand. It presents the answers, source links and searches behind each result.

The next step is to see how your brand appears in AI answers. Try the free check.
Frequently asked questions
Can Cursor rules reference other files?
Yes. A file mention tells Agent where to look, but it does not paste that file's text into the chat request.
Do Cursor rules apply to every chat?
Only an Always Apply rule does. Other rules depend on a description, matching globs or a manual mention.
Why is my.md rule ignored?
Project rules must use the.mdc extension. A plain.md file in.cursor/rules has no rule frontmatter and is ignored.
Sources
- Cursor: Rules, checked 30 October 2026.
Topics
- cursor rules
Xtrusio
AI visibility research
Xtrusio is the Perception Engine for B2B brands.
Keep reading
Technical SEO · 5 November 2026 · 8 min readClaude Code Permissions: Rules, Modes and How They Apply
Learn how Claude Code permission rules, modes, allow and deny matching, path patterns, hooks and settings scopes work.
Technical SEO · 5 November 2026 · 7 min readCodex Plugins: What They Are and How to Install One
Install Codex plugins from the CLI, add a marketplace, package a small plugin and fix plugins that do not load.
Technical SEO · 4 November 2026 · 9 min read