[ ABORT TO HUD ]
SEQ. 1
SEQ. 2

Project Rules & MDC Files

📋 Cursor Rules & Configuration 20 min 450 BASE XP⌨ HANDS-ON LAB

Teaching the AI Your Standards

Cursor Rules are persistent instructions that tell the AI how to behave. They're the difference between generic AI output and code that matches your team's exact conventions — because LLMs don't retain memory between completions, rules provide that persistent context. There are four kinds:

KindLocationScope
Project Rules.cursor/rules/*.mdcVersion-controlled, per-project (nested dirs supported)
AGENTS.mdProject root (or subdirectories)Plain-markdown alternative — open standard, no frontmatter needed
User RulesCursor Settings → RulesGlobal, all your projects (agent chat only — not Ctrl+K)
Team RulesTeam dashboard (Team/Enterprise)Org-wide, optionally enforced. Precedence: Team → Project → User
⚠️ Critical Gotcha: Project rule files must use the .mdc extension — plain .md files in .cursor/rules/ are silently ignored. The legacy root .cursorrules file still works but is deprecated.

MDC File Structure

---
description: Enforce TypeScript best practices for components
globs: src/components/**
alwaysApply: false
---
# Component Standards
- Use functional components exclusively
- Prefer named exports over default exports
- Always define a Props interface
- Reference the canonical example: @src/components/Button.tsx

The Four Application Types

  • Always Apply: alwaysApply: true — loaded into every agent interaction
  • Apply Intelligently: the agent fetches the rule based on its description when relevant
  • Apply to Specific Files: auto-attached when the file being edited matches globs
  • Apply Manually: only when you @-mention the rule by name

Best Practices (from the official docs)

  • Keep rules under 500 lines — split large rules into composable files
  • Reference files with @filename instead of pasting code into the rule
  • Don't copy entire style guides in — link the canonical examples
  • Generate rules fast: type /create-rule in the agent input
Token Tax Warning: Every alwaysApply: true rule consumes context window space in every interaction. Keep foundational rules lean and modular. Also note: rules never affect Tab autocomplete — only agent interactions.
⌨ HANDS-ON LABScaffold Your Project Rules
⭐ +150 XP

Your team wants consistent AI behavior across the repo. Create the .cursor/rules directory and drop in your first MDC rule file.

1Create the nested rules directory: .cursor/rules (hint: one flag creates parents).
2Create an MDC rule file inside it (e.g. touch .cursor/rules/typescript.mdc).
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 2 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 4
What file extension MUST project rules in .cursor/rules/ use?
.md
.mdc — plain .md files are silently ignored
.txt
.json
Project Rules & MDC Files Tutorial | Cursor Rules & Configuration — Cursor Academy