.cursorrules file and the newer .cursor/rules .mdc directory. This guide covers both — the formats, the four rule types, globs, and the practices that keep rules working.June 4, 2026 · 13 min read · by Harish Ganapathi
.cursorrules file and the newer .cursor/rules .mdc directory. This guide covers both — the formats, the four rule types, globs, and the practices that keep rules working.Key takeaways
.cursor/rules/*.mdc — scoped rules with frontmatter. A plain .md file there is ignored.description, globs, and alwaysApply..cursorrules file is legacy but still read. Cursor also natively reads AGENTS.md.Cursor rules are persistent instructions injected into the model’s context so the AI codes the way your project expects — your stack, your patterns, your forbidden moves. Without them, Cursor re-derives your conventions from whatever files happen to be open, and gets them wrong often enough to be annoying. With them, “use our internal RPC pattern” or “never use any” becomes a standing order.
There are two generations of the feature. Understanding which is which is the whole game.
The original mechanism was a single .cursorrulesfile at the repo root: free-form text or Markdown, no frontmatter, injected into every conversation. It’s elegant — one file, no schema — but everything in it is always on, with no way to scope a rule to one task or one file type. As the file grows it starts contradicting itself.
# Project: Acme API
## Standards
- Strict TypeScript. No `any`, no unguarded `as` casts.
- Functions under 50 lines, files under 800.
## Testing
- Vitest for unit, Playwright for E2E. 80% line coverage.
## Don't
- Don't run `pnpm install` without asking.Status: legacy
Cursor now treats .cursorrulesas legacy and recommends migrating to Project Rules. It’s still read at the repo root for backward compatibility, but new capabilities target the .mdcsystem, and recent releases have had bugs where root rules weren’t reliably injected. Treat it as a migration source, not a place to invest.
Project Rules live in .cursor/rules/ as individual .mdcfiles — “Markdown with metadata.” The metadata matters: a plain .md file in that directory is ignored, because it has no frontmatter to tell Cursor when to apply it.
---
description: RPC service conventions for our internal framework
globs: ["src/**/*.ts", "src/**/*.tsx"]
alwaysApply: false
---
- Use our internal RPC pattern when defining services.
- Service names are snake_case.
- See the canonical template below and mirror its structure.
@service-template.tsdescription — what the rule is about. Cursor’s agent reads this to decide whether to pull the rule in (this drives the “Apply Intelligently” mode).globs — file path patterns. When you open, read, or edit a matching file, the rule is auto-attached.alwaysApply — a boolean. true includes the rule in every conversation.The three fields combine into four practical activation modes. Heads up on naming:Cursor’s current UI says one thing, and almost every third-party guide (and Cursor’s own earlier docs) says another. They’re the same four modes — here are both vocabularies:
| Official label | Common name | When it loads | Set by |
|---|---|---|---|
| Always Apply | Always | Every chat session | alwaysApply: true |
| Apply Intelligently | Agent Requested | When the agent judges it relevant | description (no globs) |
| Apply to Specific Files | Auto Attached | When a file matches the pattern | globs |
| Apply Manually | Manual | Only when you @-mention it | Neither field |
A rule can pull another file into context with @filename.ts. Instead of pasting a whole boilerplate template into the rule, reference the real file — the rule stays small and never drifts from the source. You can also @-mention a rule in chat to apply it on the spot.
Cursor has four related concepts. Keeping them straight saves a lot of confusion:
| Concept | Scope | Where it lives |
|---|---|---|
| Project Rules | One codebase | .cursor/rules/*.mdc, in version control |
| User Rules | All your projects | Cursor Settings (global, Agent/Chat only) |
| Team Rules | Whole org | Cursor dashboard (Team/Enterprise plans) |
| Memories | Per project, per user | Auto-generated from your chats |
The key distinction is Rules vs Memories. Rules are static text you maintain on purpose. Memories are auto-generated— Cursor watches a chat, extracts a durable preference, and stores it so you stop re-explaining yourself. Memories are per-project and per-user, so a teammate doesn’t inherit yours unless you promote it into a rules file by hand.
/Generate Cursor Rules to capture the decisions from a back-and-forth into a rule (shipped in Cursor v0.49)./create-rule in chat, or Cursor Settings › Rules → Add Rule, or the command palette’s “New Cursor Rule.”@file rather than duplicating them.alwaysApply: true sparingly. It’s global config; prefer Auto Attached or Agent Requested for anything scoped.For copy-paste starting points by framework, see the best .cursorrules examples by stack.
As of 2026, Cursor natively reads AGENTS.md — including nested files in subdirectories, with more specific paths taking precedence. Cursor positions it as a simple, portable alternative to .cursor/rules for straightforward cases. The trade-off: AGENTS.md is plain Markdown with no globs or per-mode activation, so you give up Cursor-specific scoping in exchange for a file that every other agent reads too.
Here’s the catch almost no rules guide mentions: most developers don’t only use Cursor. The moment you also run Claude Code or Copilot, the same conventions you just encoded in .mdc files have to be re-encoded in CLAUDE.md and copilot-instructions.md — and then kept in sync forever.
Two ways forward: convert your .cursorrules into the other formats once, or keep a single canonical library and compile to all of them. Skillwright does the latter — author once, deploy to Cursor, Claude Code, Windsurf, and Copilot. See how to manage AI coding rules across tools for the full picture, or grab ready-made rule templates to start.
.cursorrules is the legacy single file at your repo root — always loaded, no scoping. .cursor/rules/ is the newer system: a directory of .mdc files, each with frontmatter (description, globs, alwaysApply) and one of four activation modes. Use .cursor/rules for anything beyond a trivial project.
Effectively yes. Cursor treats the root .cursorrules file as legacy and recommends migrating to Project Rules in .cursor/rules. It's still read for backward compatibility today, but new features target the .mdc system, and some recent versions have had bugs where .cursorrules wasn't reliably injected.
There's no hard cap on the number of rules, but each rule should stay under about 500 lines, and your total context budget is finite. The guidance is to split large rules into smaller composable ones and use Auto Attached / Agent Requested modes so only relevant rules load.
Yes. Rules apply in Agent and Chat. User Rules apply only to the Agent/Chat, and Auto Attached rules fire automatically when the agent reads or writes a file matching their globs.
Cursor reads both. Use .cursor/rules when you need globs or per-mode activation that's specific to Cursor. Use AGENTS.md when you want portable, plain-Markdown instructions that other tools (Codex, Copilot, Gemini) also read. Many teams keep AGENTS.md as the source of truth and add .mdc rules only for Cursor-specific scoping.