Rules for AI

Community notes on Cursor rules for AI. Official docs are at cursor.com/docs.

Last updated: March 7, 2025

What They Are

Custom instructions that guide AI behavior without repeating prompts

Why Use Them

Enforce coding standards and project conventions automatically

How They Work

Stored as .mdc files, automatically applied based on file patterns

Getting Started

What Are Rules?

Rules for AI allow you to customize how Cursor's AI analyzes and generates code. They act as persistent guidelines that help the AI understand your project's requirements, conventions, and constraints.

Pro Tip: Think of rules as your personal instructions to the AI that persist across all your coding sessions.

Creating Your First Rule

  1. 1Open command palette: Cmd + Shift + P
  2. 2Type and select "New Cursor Rule"
  3. 3Write your instructions in the new file
  4. 4Define description and file patterns (globs)

Creating Cursor Rule

Learn how to create Cursor rules for your projects and attach files for contextual understanding.

Key Components

Descriptions

Short explanation of when the rule should apply - helps both you and AI understand its purpose.

Rule description

File Patterns

Glob patterns specify which files the rule applies to (e.g., *.tsx).

File patterns
Tip: Click "Global" to apply on every request

Auto Attachment

Rules automatically attach when you open matching files - no manual invocation needed.

Context-aware activation
Pattern-based matching
Zero manual configuration

Advanced Features

Reference Files with @file

Include additional files as context when rules are applied using the @file syntax.

Example:

@file ../api-guide.md
@file ./tsconfig.json
@file ./style-guide.md
•Attach TypeScript configs
•Include design documents
•Reference API documentation
•Chain multiple rules together

Managing Rules

Access and edit rules through Cursor's Settings interface or directly edit .mdc files.

Managing rules

Location: Settings → General → Project Rules

Storage: .cursor/rules/ directory

Team Collaboration

TIPS FOR TEAMS

Rules are stored in .cursor/rules/ and can be version-controlled. Commit them to your repository to ensure everyone's AI follows the same guidelines.

Benefits

  • Consistent AI behavior across team
  • Easier onboarding for new developers
  • Historical tracking of rule changes

Best Practices

  • Review rules through PR process
  • Auto-distribute with code pulls
  • Regular team rule reviews

Quick Reference

Command

Cmd+Shift+P

File Type

.mdc

Location

.cursor/rules/

Reference

@file