Rules for AI
Rules for AI
Community notes on Cursor rules for AI. Official docs are at cursor.com/docs.
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
- 1Open command palette:
Cmd + Shift + P - 2Type and select "New Cursor Rule"
- 3Write your instructions in the new file
- 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.

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

Auto Attachment
Rules automatically attach when you open matching files - no manual invocation needed.
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.mdManaging Rules
Access and edit rules through Cursor's Settings interface or directly edit .mdc files.

Location: Settings → General → Project Rules
Storage: .cursor/rules/ directory
Team Collaboration
TIPS FOR TEAMSRules 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+PFile Type
.mdcLocation
.cursor/rules/Reference
@file