Skip to content

SOP-010: Project Rules

Document Control

FieldValue
SOP IDSOP-010
Version1.0
StatusActive
Last Updated2024-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):

PriorityTypeDescription
1Team Rules (Enterprise)Managed from dashboard, can be enforced
2Project Rules (.cursor/rules)Version-controlled, scoped to codebase
3User Rules (Cursor Settings)Global preferences, apply everywhere

Step 1: Create a Project Rule

Option A: Command Palette

  1. Open Command Palette: Cmd+Shift+P / Ctrl+Shift+P
  2. Type: "New Cursor Rule"
  3. Enter a name for your rule

Option B: Settings

  1. Open Cursor Settings: Cmd+Shift+J
  2. Go to Rules, Commands
  3. 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.md

RULE.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.ts

Step 3: Configure Rule Types

TypeSettingWhen Applied
Always ApplyalwaysApply: trueEvery chat session
Apply IntelligentlyalwaysApply: false + descriptionWhen Agent decides it's relevant
Apply to Filesglobs: ["*.ts"]When matching files in context
ManualNo globs, no alwaysApplyWhen @-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 calls

Step 6: Set Up User Rules

For personal preferences that apply everywhere:

  1. Open Cursor Settings: Cmd+Shift+J
  2. Navigate to Rules
  3. 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:

  1. Go to cursor.com/dashboard
  2. Navigate to Team Content → Rules
  3. 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 injection

Benefits:

  • 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

  1. Go to Cursor Settings → Rules, Commands
  2. Click + Add RuleRemote Rule (GitHub)
  3. Paste repository URL
  4. Rule syncs automatically with source

From Claude Skills

  1. Go to Cursor Settings → Rules
  2. Find Import Settings
  3. 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

IssueSolution
Rule not applyingCheck globs match, verify alwaysApply
Rule not visibleCheck file is saved, refresh settings
Conflict with other rulesReview precedence, adjust descriptions
Too many rules appliedUse more specific globs
Can't create ruleCheck write permissions in .cursor/

See Also

Built with VitePress | Powered by Claude AI