SOP-010: Project Rules
Document Control
| Field | Value |
|---|---|
| SOP ID | SOP-010 |
| Version | 1.0 |
| Status | Active |
| Last Updated | 2024-12 |
Purpose
This SOP covers configuring Cursor Rules to provide persistent AI instructions for consistent coding behavior.
Scope
- Project Rules (.cursor/rules)
- User Rules
- Team Rules
- AGENTS.md
Prerequisites
- Cursor installed and configured
- Project open in workspace
Procedure
Rules Overview
Rule Types & Precedence (highest to lowest):
| Priority | Type | Description |
|---|---|---|
| 1 | Team Rules (Enterprise) | Managed from dashboard, can be enforced |
| 2 | Project Rules (.cursor/rules) | Version-controlled, scoped to codebase |
| 3 | User Rules (Cursor Settings) | Global preferences, apply everywhere |
Step 1: Create a Project Rule
Option A: Command Palette
- Open Command Palette:
Cmd+Shift+P/Ctrl+Shift+P - Type: "New Cursor Rule"
- Enter a name for your rule
Option B: Settings
- Open Cursor Settings:
Cmd+Shift+J - Go to Rules, Commands
- Click + Add Rule next to Project Rules
Result: Creates .cursor/rules/[rule-name]/RULE.md
Step 2: Understand Rule Structure
.cursor/rules/
├── typescript-standards/
│ └── RULE.md
├── api-patterns/
│ ├── RULE.md
│ └── templates/
│ └── endpoint.ts
└── testing/
└── RULE.mdRULE.md Format:
markdown
---
description: "Standards for TypeScript development"
globs: ["**/*.ts", "**/*.tsx"]
alwaysApply: false
---
## TypeScript Standards
- Use strict mode
- Prefer interfaces over types for objects
- Use const assertions for immutable data
- Add JSDoc comments for public APIs
## Example
@template-interface.tsStep 3: Configure Rule Types
| Type | Setting | When Applied |
|---|---|---|
| Always Apply | alwaysApply: true | Every chat session |
| Apply Intelligently | alwaysApply: false + description | When Agent decides it's relevant |
| Apply to Files | globs: ["*.ts"] | When matching files in context |
| Manual | No globs, no alwaysApply | When @-mentioned |
Example Configurations:
yaml
# Always apply (coding standards)
---
alwaysApply: true
---
# Apply to specific files
---
globs: ["src/api/**/*.ts"]
alwaysApply: false
---
# Agent decides based on description
---
description: "Database migration patterns and best practices"
alwaysApply: false
---Step 4: Write Effective Rules
DO:
- Keep rules under 500 lines
- Be specific and actionable
- Include code examples
- Split large rules into composable pieces
- Reference template files with
@filename
DON'T:
- Write vague guidance
- Create one massive rule file
- Forget to test rule effectiveness
Example: Good: "Use React.memo for components receiving objects as props" | Bad: "Optimize performance"
Step 5: Reference Files in Rules
Rules can reference other files:
markdown
---
description: "API service patterns"
---
When creating API services, follow this pattern:
@templates/service-template.ts
Key points:
- Use dependency injection
- Handle errors consistently
- Add retry logic for network callsStep 6: Set Up User Rules
For personal preferences that apply everywhere:
- Open Cursor Settings:
Cmd+Shift+J - Navigate to Rules
- Add your preferences in the User Rules text area
Example User Rules:
Reply concisely. Avoid unnecessary repetition.
Prefer functional programming patterns.
Use TypeScript for all new files.
Add tests for new functionality.Step 7: Configure Team Rules (Enterprise)
For Team/Enterprise plans:
- Go to cursor.com/dashboard
- Navigate to Team Content → Rules
- Create or import rules
Team Rule Options:
- Enable immediately - Active upon creation
- Enforce this rule - Users cannot disable
AGENTS.md Alternative
For simple projects, use AGENTS.md in project root:
markdown
# Project Instructions
## Code Style
- Use TypeScript for all new files
- Prefer functional components in React
- Use snake_case for database columns
## Architecture
- Follow repository pattern
- Keep business logic in service layers
- Use dependency injectionBenefits:
- Simple markdown, no frontmatter
- Easy to read and maintain
- Good for straightforward projects
Limitations:
- No glob patterns
- No conditional application
- Always applied when present
Importing Rules
From GitHub
- Go to Cursor Settings → Rules, Commands
- Click + Add Rule → Remote Rule (GitHub)
- Paste repository URL
- Rule syncs automatically with source
From Claude Skills
- Go to Cursor Settings → Rules
- Find Import Settings
- Toggle Claude skills and plugins on
Verification Checklist
- [ ] Project rule created in
.cursor/rules/ - [ ] Rule appears in Cursor Settings
- [ ] Rule applies when expected (check context gauge)
- [ ] @-mentioning manual rules works
- [ ] User Rules saved and applied
- [ ] Team Rules visible (if applicable)
Troubleshooting
| Issue | Solution |
|---|---|
| Rule not applying | Check globs match, verify alwaysApply |
| Rule not visible | Check file is saved, refresh settings |
| Conflict with other rules | Review precedence, adjust descriptions |
| Too many rules applied | Use more specific globs |
| Can't create rule | Check write permissions in .cursor/ |