Cursor Rules Guide: How to Write .mdc Files, Globs & MCP
Cursor marks root .cursorrules files as legacy and silently ignores plain .md files inside .cursor/rules/. Here is how to structure scoped .mdc rules using alwaysApply, path globs, and an mcp-usage.mdc security template without bloating context.

THE STORY IN THREE POINTS
- Always use the .mdc extension inside .cursor/rules/—Cursor marks legacy root .cursorrules files as deprecated and silently skips plain .md files inside .cursor/rules/ because its rule parser looks specifically for .mdc YAML frontmatter.
- Split instructions across three scoping modes: alwaysApply: true for tiny universal repo invariants, path globs (such as src/api/**/*.ts) for language-specific patterns, and description-triggered rules such as mcp-usage.mdc to constrain MCP tool calls and block secret leaks.
- Never set alwaysApply: true on every rule file: stuffing full style manuals into every turn wastes input tokens and triggers contradictory Agent edits; share cross-agent commands in root AGENTS.md and keep .cursor/rules/*.mdc tightly scoped.
Why .cursor/rules/*.mdc replaces root .cursorrules—and why .md fails
Developers updating older repositories still run into tutorials teaching a single monolithic .cursorrules file at the project root. Per Cursor’s official rules documentation, root .cursorrules is officially legacy: modern teams store modular Markdown Cursor (.mdc) files inside .cursor/rules/ so individual rules can version cleanly in Git and trigger only when relevant files enter context.
The single most common silent failure highlighted across Catio.tech’s November 15 guide is saving rules with a plain .md file extension. Cursor’s rule loader strictly inspects .mdc files carrying YAML frontmatter keys (description, globs, and alwaysApply)—meaning .cursor/rules/typescript.md sits completely ignored unless renamed to .cursor/rules/typescript.mdc.
Three .mdc patterns: alwaysApply invariants, path globs, and on-demand rules
Effective repositories separate rules into three lightweight scoping tiers rather than one sprawling instruction dump. First, a tiny core.mdc file using alwaysApply: true and empty globs reserves unconditional system context strictly for universal project truths: package manager commands, test commands, forbidden directories, and git boundaries—or points cleanly to root AGENTS.md when teams run Claude Code, Codex, or OpenCode alongside Cursor.
Second, path-scoped rules set alwaysApply: false alongside targeted globs such as src/api/**/*.ts or **/*.sql so database migration conventions, Zod validation rules, or React component patterns attach automatically only when Cursor Agent or Composer opens matching paths. Third, agent-requested rules leave globs blank and alwaysApply: false, providing a clear description sentence so the model pulls specialized checklists (such as release tagging or schema audits) purely when task intent matches.
Writing mcp-usage.mdc to govern MCP tools and block secret exposure
As Shattered.io’s November 10 Cursor Rules walkthrough emphasizes, teams connecting internal databases, ticketing trackers, or browser tools over Model Context Protocol (MCP) need explicit guardrail rules inside .cursor/rules/mcp-usage.mdc.
With alwaysApply: true (or a tight MCP-focused description) and concise imperative bullets, mcp-usage.mdc should enforce four operational rules: prefer approved workspace MCP tools over ad-hoc curl scripts when querying Jira or Postgres; never create, edit, or install unapproved entries in .cursor/mcp.json autonomously; never pass API keys, .env contents, or bearer tokens into external MCP server arguments; and always summarize read-before-write mutation diffs for human confirmation when an MCP tool writes external state.
Troubleshooting rule conflicts, context bloat, and multi-IDE drift
When Cursor Agent ignores carefully written guidelines, three culprits explain nearly every failure: marking five or six long .mdc files with alwaysApply: true (diluting attention across thousands of preloaded tokens), writing vague descriptions on agent-requested rules, or leaving contradictory legacy .cursorrules entries active alongside newer .mdc files.
Audit .cursor/rules/ just like production code—keeping always-on rules under 50 lines, validating glob patterns against nested workspaces, and checking how Cursor’s Composer 2.5 harness interacts with other tools in our Cursor vs GitHub Copilot and Claude Code vs Cursor comparisons.
Sources: Project Rules (.cursor/rules/*.mdc & Legacy .cursorrules)|Cursor Docs ↗ Cursor Rules Best Practices & .mdc Guide|Catio.tech ↗ Cursor Rules Tutorial: .mdc, Globs & Test Harness|Shattered.io ↗
THE BROADER CONTEXT · XAI DOSSIER
Explore full product specifications, pricing analysis, and continuous coverage in the xAI Desk Hub. Independent benchmarks available on the AI Intelligence Index and Coding Agents Leaderboard.


