My Internet Blog

Setting Up Project-Level Rules in Cursor

The .cursor Directory Structure

.cursor/
└── rules/
    ├── style.md
    ├── architecture.md
    ├── testing.md
    └── conventions.md
└── docs/
    ├── setup.md
    ├── deployment.md
    └── contributing.md

Rule File Examples

style.md

# Code Style Rules

- Use camelCase for variable names
- Maximum line length: 100 characters
- Include JSDoc comments for public functions
- Use meaningful variable names
- Prefer const over let when possible

architecture.md

# Architecture Guidelines

- Follow Model-View-Controller pattern
- Place shared utilities in /src/utils
- Use dependency injection for services
- Keep components single-responsibility
- Implement interfaces for major services

conventions.md

# Project Conventions

- Feature flags should be prefixed with 'FF_'
- Database models go in /src/models
- Test files should end with .test.ts
- Use meaningful file names
- Group related files in feature folders

Best Practices

  1. Rule Organization

    • Keep rules concise and focused
    • Use clear, descriptive filenames
    • Organize rules by domain (style, architecture, testing, etc.)
  2. Documentation Structure

    • Place general documentation in a docs folder
    • Keep API documentation close to the code
    • Use README files in key directories
  3. Version Control

    • Include .cursor directory in version control
    • Document rule changes in commit messages
    • Review rule updates with team members

Integration with AI Features

Rules defined in the .cursor/rules directory automatically influence:

The Agent will automatically choose which rules to follow based on the context of your request.

Example Project Structure

project/
├── .cursor/
│   ├── rules/
│   │   ├── style.md
│   │   ├── architecture.md
│   │   ├── testing.md
│   │   └── conventions.md
│   └── docs/
│       ├── setup.md
│       ├── deployment.md
│       └── contributing.md
├── src/
├── tests/
└── README.md

Remember to keep your rules updated as your project evolves and ensure all team members understand and follow them.