agentleFS
Prorise-coolProrise-cool/claude-code-plugins/.cursor/rules/cursor-rules-best-practices.mdc

claude-code-plugins / rules

Cursor rule1 starsChanged 11 months agoMITView on GitHub

Guidelines for creating and modifying Cursor rules in .cursor/rules

The file

We split this cursor-rules-best-practices.mdc into the rules it gives an agent

8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    alwaysApply: Use true sparingly - only for universal rules

    line 30
  2. Distinctive:

    Keep under 500 lines - split large rules

    line 50
  3. Very specific:

    Use @filename to reference actual codebase files

    line 53
  4. Very specific:

    Avoid alwaysApply: true unless truly universal

    line 58
  5. Distinctive:

    Use nested rules in subdirectories for module-specific guidance

    line 59
  6. Distinctive:

    Verify glob patterns match intended files

    line 76
  7. Distinctive:

    Check rule applies when expected (and doesn't when it shouldn't)

    line 77
  8. Distinctive:

    Test that Agent follows the guidance

    line 78

≈ “Common” is an estimate: at least 1 in 5 of the 7,111 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
cursor-rules-best-practices.mdc
---
description: Guidelines for creating and modifying Cursor rules in .cursor/rules
globs:
  - ".cursor/rules/**/*.mdc"
alwaysApply: false
---

# Cursor Rules Best Practices

## Rule Format (MDC)

```markdown
---
description: Clear description of what this rule does
globs:
  - "pattern/**/*.ts"
alwaysApply: false
---

# Rule Title

Rule content...
```

### Metadata

**Required fields**:
- **`description`**: Helps Agent decide when to apply (be specific)
- **`globs`**: File patterns for scoped application
- **`alwaysApply`**: Use `true` sparingly - only for universal rules

**Optional fields** (for advanced use):
- **`tags`**: Categorization keywords for AI discovery
- **`priority`**: 1-5 for conflict resolution (1 = highest)
- **`version`**: Semantic versioning for rule changes

## Rule Types

| Type | Configuration | Use Case |
|------|--------------|----------|
| Always Apply | `alwaysApply: true` | Universal, project-wide guidance |
| Apply Intelligently | `alwaysApply: false` + clear description | Agent decides based on context |
| Apply to Files | `globs` patterns | Triggers when matching files referenced |
| Apply Manually | Minimal description | Only when @-mentioned |

## Best Practices

### Content

- Keep under 500 lines - split large rules
- Be specific and actionable (not "write good code")
- Include concrete examples with do's and don'ts
- Use `@filename` to reference actual codebase files

### Scoping

- Be specific: `"src/api/**/*.ts"` over `"**/*.ts"`
- Avoid `alwaysApply: true` unless truly universal
- Use nested rules in subdirectories for module-specific guidance

### Structure

- Clear headings and logical sections
- Context about when/why the rule applies
- Code examples showing correct patterns

## Anti-Patterns

- Overly broad rules covering everything
- Vague descriptions ("code style" vs "TypeScript interfaces for API responses")
- Duplicate guidance across rules
- Rules without examples

## Testing

1. Verify glob patterns match intended files
2. Check rule applies when expected (and doesn't when it shouldn't)
3. Test that Agent follows the guidance
4. Refine based on actual usage

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.