What are cursor rules?

What are cursor rules?

Cursor rules are ways to give AI in the editor specific instructions about your codebase.

The old way: A single .cursorrules file in the project root. This still works but is being phased out.

The new way: MDC files in the .cursor/rules directory. These are more flexible.

MDC stands for "Markdown with Context" and these files tell the AI how to understand and work with your code.

With the new system, you can:

  • Create specific rules for different parts of your project

  • Use glob patterns to match specific files (like .tsx or src/components/)

  • Reference other files using @file to include them as context

  • Chain multiple rules together

The rules are simply files in your project, so you can version control them with Git, making it easy to share with your team.

To create a new rule, use the command palette (Cmd + Shift + P > New Cursor Rule).

This system provides detailed control over how the AI interacts with different parts of your codebase, which is particularly helpful for larger projects that use various technologies or patterns.