---
description: This rule explains how to create new .mdc project rule files for the Cursor agent.
globs:
alwaysApply: true
---
# Cursor Rules Location
How to add new cursor rules to the project
1. Always place rule files in PROJECT_ROOT/.cursor/rules/:
```
.cursor/rules/
├── your-rule-name.mdc
├── another-rule.mdc
└── ...
```
2. Follow the naming convention:
- Use kebab-case for filenames
- Always use .mdc extension
- Make names descriptive of the rule's purpose
3. Directory structure:
```
PROJECT_ROOT/
├── .cursor/
│ └── rules/
│ ├── your-rule-name.mdc
│ └── ...
└── ...
```
4. Never place rule files:
- In the project root
- In subdirectories outside .cursor/rules
- In any other location
5. Cursor rules have the following structure:
```
---
description: Short description of the rule's purpose
globs: optional/path/pattern/**/*
alwaysApply: false
---
# Rule Title
Main content explaining the rule with markdown formatting.
1. Step-by-step instructions
2. Code examples
3. Guidelines
Example:
```typescript
// Good example
function goodExample() {
// Implementation following guidelines
}
// Bad example
function badExample() {
// Implementation not following guidelines
}
```
Creating rules in Cursor allows you to define consistent guidance for the AI assistant in your project. This rule specifically explains how to properly add new .mdc rule files to your project structure, ensuring they're placed in the correct location and follow the appropriate formatting conventions.
The "Create Rules" rule serves as a guide for setting up new rule files in your Cursor projects. It outlines the proper directory structure, naming conventions, and file format for Cursor rules. Following these guidelines ensures that your custom rules are properly recognized and applied by the Cursor AI assistant.
When adding rules to your project, proper organization is critical:
All rule files must be placed in the .cursor/rules/
directory at the root of your project. This specific location ensures Cursor can find and apply your rules automatically. The rule defines a clear structure:
PROJECT_ROOT/
├── .cursor/
│ └── rules/
│ ├── your-rule-name.mdc
│ └── ...
└── ...
Rules should never be placed in the project root, subdirectories outside .cursor/rules
, or any other location.
For rule files to be properly recognized, they must follow these naming guidelines:
code-style-guide.mdc
, git-commit-format.mdc
).mdc
extensionEach rule file follows a specific format with three main components:
YAML frontmatter - Contains metadata about the rule:
description
: A concise explanation of the rule's purposeglobs
: Optional path patterns to automatically apply the rule to matching filesalwaysApply
: Boolean flag determining if the rule should always be activeRule title - A clear heading identifying the rule
Main content - The detailed instructions, formatted with markdown, which may include:
A simplified example structure:
---
description: Short description of the rule's purpose
globs: optional/path/pattern/**/*
alwaysApply: false
---
# Rule Title
Main rule content with instructions...
The "Create Rules" rule itself is defined in a file named create-rules.mdc
and serves as a meta-guide for creating other rules. Since this rule doesn't appear to have a glob pattern, it's likely intended to be manually invoked when you need guidance on creating new rules.
To use this rule:
@create-rules
in the Cmd-K prompt or chat interfaceThis rule is particularly useful when setting up project-specific guidelines or when you're new to creating Cursor rules and need a reference for the proper structure and location.
When creating new rules for your project:
code-style-javascript.mdc
, code-style-python.mdc
)By following the guidelines in the Create Rules rule, you'll ensure consistent rule implementation across your project, making it easier for team members to understand and follow your project's standards.