Cursor

Cursor rules setup: .cursor/rules, .mdc frontmatter, globs, alwaysApply and AGENTS.md

How do I add project rules in Cursor?

Create .mdc files in your repo's .cursor/rules folder, each with frontmatter that sets description, globs and alwaysApply. The fastest way is to type /create-rule in Agent chat. For plain markdown with no metadata, use an AGENTS.md file instead.

Where rules live

  • Project Rules: .mdc files in .cursor/rules. They are version controlled and scoped to the codebase. Subfolders are supported.
  • User Rules: global preferences set in Cursor's rules settings. They apply across all projects.
  • Team Rules: managed from the Cursor dashboard on Team and Enterprise plans.
  • AGENTS.md: plain markdown instructions with no metadata.

Project rules must use the .mdc extension. A plain .md file in .cursor/rules is ignored by the rules system.

Frontmatter and rule types

  • Always Apply: alwaysApply: true. Included in every chat session.
  • Apply to Specific Files: alwaysApply: false plus globs. Attached when a matching file is in context.
  • Apply Intelligently: alwaysApply: false plus description, no globs. Agent pulls it in when relevant.
  • Apply Manually: no description or globs. Used only when you @-mention it.

Separate multiple glob patterns with commas. For example, src/**/*.tsx matches .tsx files under src/.

Example rule files

.cursor/rules/components.mdc

---
globs: src/components/**/*.tsx
alwaysApply: false
---

- Use named exports, not default exports
- Keep components under 200 lines
- Prefer composition over prop drilling

.cursor/rules/general.mdc

---
alwaysApply: true
---

- Read the relevant source files before proposing changes
- Never modify generated files in dist/ or build/

An @file reference inside a rule tells Agent where to look. The file is not inlined, so put anything that must always be in context in the rule body.

AGENTS.md and nested instructions

Put AGENTS.md in the project root. Nested AGENTS.md files in subdirectories apply when working in that directory. They combine with parent files, and the more specific file wins.

Precedence and limits

  • Precedence is Team Rules, then Project Rules, then User Rules. All rules merge, and earlier sources win on conflicts.
  • User Rules apply only to Agent, not to Inline Edit.
  • Rules do not affect Cursor Tab.
  • Keep each rule under 500 lines and split large ones into smaller rules.

Sources

More on Cursor

Other guides

Cursor: allow all terminal commandsClaude Code: allow commands without promptsCodex CLI: approval and sandbox modesGemini CLI: YOLO mode, auto_edit and allowing specific shell commandsCursor Privacy Mode: telemetry, training and data retentionClaude Code telemetry and data retention: what is sent and how to turn it offGemini CLI: turn off usage statistics and telemetryCLAUDE.md: where it goes, how it loads, and how it works with AGENTS.mdClaude Code hooks: format on save, block risky edits, get notifiedClaude Code subagents: create one, limit its tools, and call itAdd MCP servers to Cursor with mcp.json: Keep files out of Cursor with .cursorignore: Configure Codex with config.toml: Configure Gemini CLI with settings.json: Add MCP servers to Claude Code (claude mcp add, .mcp.json, scopes): Claude Code custom slash commands and skills (SKILL.md): GitHub Copilot custom instructions: Adding MCP servers to GitHub Copilot: Claude Code settings.json: file locations, precedence, and key settingsClaude Code plugins and marketplaces: install, create, and shareGemini CLI extensions and custom commands: Configuring OpenCode with opencode.json: Cline Rules: workspace, global, and conditional rulesKiro steering files: .kiro/steering, inclusion modes, and AGENTS.mdZed agent: instruction files, MCP servers, tool permissions, and ACP agentsCursor CLI: install, headless mode, permissions and CIAider: CONVENTIONS.md, .aider.conf.yml and API keysJunie guidelines, MCP and the Action Allowlist: Amp AGENTS.md, settings.json and MCP: Configure Goose extensions, hints, recipes and permissions: Customize OpenHands with skills, AGENTS.md, setup.sh and MCP: Configure Factory Droid CLI: AGENTS.md, settings.json, autonomy, custom droids and MCPConfigure Qwen Code: settings.json, providers, QWEN.md, MCP and approval modesCursor hooks: hooks.json, beforeShellExecution, afterFileEdit and exit codesCursor sandbox: sandbox.json, network allowlist and run modesCursor settings: settings.json, Cursor Settings and the ~/.cursor config filesCursor browser agent: @browser, browser automation and approval modesCursor subagents: .cursor/agents, frontmatter, built-in Explore, Bash and BrowserCursor telemetry and OpenTelemetry export (Privacy Mode, OTLP, Analytics API):

Get the weekly agent stack update

New official MCP servers, spec changes and harness releases, checked against the source. One email a week, no fluff.

Reviewed Oct 9, 2026. Settings change often; the linked vendor docs are the source of truth.