Write Cursor project rules that actually load when you need them
Put rules in .cursor/rules as .mdc files, set alwaysApply, globs and the description on purpose, and test that the agent picks each rule up.

Tools used
Step navigator
A small set of committed .mdc rules, each with a trigger you chose and checked.
Cursor users whose rules seem to be ignored.
Before you start
A widely read r/cursor deep dive found that rules in .cursor/rules don't all switch on just by being there: whether a rule is added to the context and whether it is used depend on alwaysApply, globs and the description. Cursor's docs describe the same rule types.
Step-by-step instructions
Put project rules in .cursor/rules as .mdc files
Cursor's docs: project rules "live in .cursor/rules as .mdc files and are version-controlled." The deep dive's reason to commit them: "Teams can collaborate using shared rules."

Set the trigger deliberately
Each rule's front matter has description, globs and alwaysApply. Per the deep dive, alwaysApply and globs decide whether a rule is injected into the context, and the description decides whether the agent fetches and uses it. Asked whether rules in the folder activate automatically, the author's answer is: "No."
---
description: Backend API conventions. Use when editing files in src/api.
globs: src/api/**
alwaysApply: false
---
- Validate inputs at service boundaries
- Return { code, message } on errorsWhy this works
A vague description means the agent may never fetch the rule.
Edit .mdc files in a plain editor if the UI misbehaves
The deep dive found Cursor's built-in editor for .mdc files buggy and recommends "Editing these files with external tools like VSCode."
Test that a rule loads
The author's test: put a line in the rule like "When this rule loads, input: 'Rule loaded: global.mdc.'" and see whether the agent prints it in a new chat.
Use AGENTS.md if you want something simpler
Cursor also reads AGENTS.md, which its docs call a "Simple alternative to .cursor/rules."
End of guide · Reviewed Oct 26, 2026
Pro tips2
- Remove the test line once you have confirmed the rule loads.
- Keep one topic per rule file.
Common mistakes2
- Assuming every file in .cursor/rules applies to every chat.
- A description that does not say when the rule is relevant.


