Cursor AI Rules

How to write Cursor AI
rules and system prompts

Cursor's rules system is one of the most powerful in any AI code editor. Learn how to configure global rules, project-specific .cursor/rules/ files, and the scope control techniques that keep Cursor safe on large codebases.

⏱ 10 min read Updated 2026 Works with Cursor on all platforms
Quick start

How to add rules to Cursor

Cursor has two levels of rules. Here is the fastest way to get both configured.

1
Open Cursor Settings (Cmd/Ctrl + Shift + J) and find Rules for AI
2
Paste your global rules - language preferences, testing requirements, scope restrictions
3
In your project root, create .cursor/rules/ with .mdc files for project-specific rules
4
Or create a .cursorrules file in the project root for a single-file approach
Build your Cursor prompt free →
12
AI tools covered
3
Prompt types built
5min
To your first prompt
$0
To start
Cursor rules configuration — project .mdc files vs global Settings
Cursor — .cursor/rules/*.mdc + Settings → Rules for AI (global)Use TypeScript. Prefer functional components. Never modify files outside scope.Write tests for all new functions. Ask before adding dependencies.Architecture: [describe your stack and patterns here]...

How Cursor uses system prompts via rules

Cursor AI rules are system prompts stored in your project files or in Cursor's global Settings, which tell Cursor how to write code, what scope to operate within, and what constraints to follow before it generates or modifies any code. Cursor has two distinct levels of rules that stack: global rules for all projects, and project-level rules that override or extend them for a specific codebase.

The most important Cursor rule
"Never modify files outside the current working directory or the files I specify. If a change would require modifying other files, describe what would change and ask for confirmation before proceeding." This single rule prevents the majority of unintended side effects on large codebases.

What to put in your Cursor rules

Global rules (Settings → Rules for AI)

  • Language and framework defaults - "Always use TypeScript. Prefer React functional components with hooks."
  • Scope control - "Never modify files outside the directory I specify in my request."
  • Uncertainty handling - "If you are unsure whether a change is correct, describe what you would do and ask if I want to proceed."
  • Testing - "Write unit tests for all new functions unless I say otherwise."
  • Comments - "Add JSDoc comments for all exported functions. Keep inline comments minimal."

Project rules (.cursor/rules/)

  • Architecture decisions and patterns for this project
  • Specific libraries and their preferred usage patterns
  • Naming conventions for components, files, and variables
  • Directories and files that are off-limits for modification
  • Any legacy code areas that need special handling
💡
Use .mdc files for scoped rules
The .cursor/rules/ format lets you create rules that only apply in specific contexts - for example, a react-components.mdc that only activates when working with .tsx files, or an api-patterns.mdc for the /api directory. This is far more precise than putting everything in a single .cursorrules file.

System prompt vs master prompt vs user prompt in Cursor

LayerWhere in CursorWhat it controlsScope
Global rulesSettings → Rules for AIUniversal coding preferences and behaviorAll projects
Project rules.cursor/rules/ or .cursorrulesCodebase context, architecture, scope limitsThis project only
User promptComposer or Chat inputThe specific coding taskThis task only

Common questions

Should I use .cursorrules or .cursor/rules/?

.cursorrules still works but is legacy. .cursor/rules/ with .mdc files is the recommended modern approach. For simple projects .cursorrules is fine. For complex projects with multiple contexts .cursor/rules/ gives much more control.

How do Cursor rules interact with Chat vs Composer?

Rules apply to both. In Composer (multi-file editing), scope control rules are especially important because Composer can modify multiple files at once.

How is Cursor different from Windsurf?

Both use project-level rules files but file names differ. Cursor's rules system supports multiple scoped files. Windsurf's Cascade has stronger default multi-file context awareness. See our Windsurf guide for comparison.

Build your Cursor system prompt now

Answer a short set of questions and get a master prompt engineered specifically for Cursor. Free, no account needed.

Build free with Cursor →

Cursor prompts free · 3 builds/month · Pro is $19/month for unlimited builds and Advanced mode

System prompts optimized for
understandingAI · free newsletter
Get more from your AI tools
Practical tips on system prompts, prompt engineering, and getting real results from AI. No fluff.

No spam. Unsubscribe anytime.