Rules Configuration in AI

From the Cursor cheat sheet ยท Context Management ยท verified Nov 2026

Rules Configuration

Set persistent coding rules and patterns

yaml
# Where rules live
.cursor/rules/*.mdc     # Project rules, version-controlled
AGENTS.md               # Plain Markdown rules (root or subfolders)
CLAUDE.md               # Read the same way as AGENTS.md
~/.cursor/rules/        # User rule files, this machine only
Customize > Rules       # User rules, synced with your account

# Rule file: .cursor/rules/api.mdc
---
description: API standards
globs: src/api/**/*.ts, src/**/*.api.ts
alwaysApply: false
---
- Use REST conventions
- Include error handling
- Add JSDoc comments

# Rule types
Always Apply             # alwaysApply: true, every chat
Apply to Specific Files  # globs match a file in context
Apply Intelligently      # Agent decides from the description
Apply Manually           # Only when you @-mention the rule

# Legacy: .cursorrules will be deprecated.
# Move it into a rule set to Always Apply.
yaml
# .cursor/rules/style.mdc
---
description: Code style guide
alwaysApply: true
---
- Use TypeScript strict mode
- Prefer const over let
- Use async/await over callbacks

# Create a rule
/create-rule                         # In chat: Agent writes the rule file
Cmd/Ctrl+Shift+P > New Cursor Rule   # Command palette
Customize > Rules > Add Rule         # Sidebar
๐Ÿ’ก Rule files must end in .mdc: a plain .md file in .cursor/rules is ignored
โšก When rules conflict: Team Rules, then Project Rules, then User Rules
๐Ÿ” globs takes one or more patterns separated by commas
๐Ÿ“Œ Rules apply to Agent in every mode, but not to Tab or Bugbot
rulesconfigurationcontext

Continue with Cursor

Save the full cheat sheet or work through every related task.

More AI tasks

Back to the full Cursor cheat sheet