What are Cursor rules?
Definition
Cursor rules are written instructions that the AI code editor Cursor adds to its Agent's context, so the AI follows your project's conventions without you repeating them in every chat. The Cursor docs say that when a rule is applied, "rule contents are included at the start of the model context".
Checked: 2026-10-29 (Beijing time) · Sources
The four kinds of rules
- Project rules:
.mdcfiles in.cursor/rules, version-controlled with your code. A plain.mdfile in that folder is ignored. - User rules: global preferences that apply across all your projects.
- Team rules: managed from the dashboard, available on Team and Enterprise plans.
- AGENTS.md: a plain markdown file in the project root (or in subfolders) as a simpler alternative to
.cursor/rules.
Each .mdc rule has frontmatter with three fields: description, globs and alwaysApply. They decide whether a rule is always included, attached when matching files are in context, pulled in when the Agent judges it relevant, or used only when you @-mention it. Cursor recommends keeping each rule under 500 lines, and rules do not affect Cursor Tab.
Example
A rule saved as .cursor/rules/components.mdc that applies only to React component files:
---
globs: src/components/**/*.tsx
alwaysApply: false
---
- Use named exports, not default exports
- Keep components under 200 linesRules files are not only for Cursor. GitHub Copilot code review reads AGENTS.md (GitHub suggests it for rules shared across AI tools), and Claude Code can read an existing AGENTS.md in place of its own CLAUDE.md. One trap: Cursor's PR reviewer Bugbot does not use .cursor/rules; it reads .cursor/BUGBOT.md. Ready-made files are in our free templates.
Related tools on this site
- Cursor: AI coding agent and editor: hand off coding tasks to agents that turn ideas into code.
- GitHub Copilot: GitHub's AI coding assistant and coding agent, with agent mode, code review and a CLI.
- Claude Code: Anthropic's agentic coding tool: understands your codebase, edits files, runs commands in the terminal or IDE.
Related pages
- Free prompt and Cursor rules templates
- Cursor rules for a Next.js + Tailwind landing page
- AGENTS.md and CLAUDE.md starter
- All glossary terms
Sources
- Cursor docs: Rules. Checked: 2026-10-29.
- GitHub Docs: GitHub Copilot code review. Checked: 2026-10-29.
- Cursor docs: Bugbot. Checked: 2026-10-29.
- Claude Code docs: Overview. Checked: 2026-10-29.
We only state facts we checked on the linked sources on the dates shown. Found a mistake? Email jazz.fanpeng@mail.grokbot.com.