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

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 lines

Rules 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

Related pages

Sources

We only state facts we checked on the linked sources on the dates shown. Found a mistake? Email jazz.fanpeng@mail.grokbot.com.