|
1 | 1 | --- |
2 | | -versionNum: 7a0e5aab |
3 | | -description: How to Edit Cursor Rules and their appropriate location in the repository |
4 | | -globs: |
| 2 | +versionNum: b2fe3ee5 |
| 3 | +description: Editing Cursor Project Rules |
| 4 | +globs: *.mdc |
5 | 5 | source: https://gist.github.com/codekiln/242b572c64c1097277fd4c831db91c10 |
6 | 6 | --- |
7 | 7 | # Cursor Project Rule Editor Rule |
8 | 8 |
|
9 | | -`.mdc` files stand for Mark Down Cursor, and are meant to give the Cursor IDE AI Agent context on how to operate in the codebase. |
| 9 | +`.mdc` files stand for MarkDown Cursor, and are meant to give the Cursor IDE AI Agent context on how to operate in the codebase. |
10 | 10 | This particular rule is about using the AI to author and edit `.mdc` files, so as to update the rules. |
11 | 11 | This rule ensures `.mdc` files are correctly placed within a repository and adhere to standard formatting conventions. |
12 | 12 |
|
@@ -61,11 +61,20 @@ actions: |
61 | 61 | └── ... |
62 | 62 | ``` |
63 | 63 |
|
64 | | - 4. Never place rule files: |
| 64 | + 4. VERY IMPORTANT - NEVER EVER place rule files: |
65 | 65 | - In the project root |
66 | 66 | - In subdirectories outside .cursor/rules |
67 | 67 | - In any other location |
68 | 68 |
|
| 69 | + 5. ⚠️ CRITICAL WARNING - File Initialization Bug: |
| 70 | + When the AI creates or edits a .mdc file, DO NOT open the file in the editor |
| 71 | + until the changes are committed to the repository. There is currently a bug |
| 72 | + where opening a newly created or edited .mdc file in the editor will cause |
| 73 | + it to be initialized/erased. To avoid this: |
| 74 | + - Wait for the AI to finish making changes |
| 75 | + - Commit the changes to the repository |
| 76 | + - Only then open the file in the editor if needed |
| 77 | + |
69 | 78 | examples: |
70 | 79 | - input: | |
71 | 80 | # Bad: Rule file in wrong location |
@@ -100,28 +109,32 @@ actions: |
100 | 109 | message: | |
101 | 110 | Markdown `.mdc` files should: |
102 | 111 |
|
103 | | - 1. **Include a frontmatter block** at the top with a `description` field: |
| 112 | + 1. **Include a frontmatter block** at the top with `description` and `globs` fields: |
104 | 113 | ``` |
105 | 114 | --- |
106 | | - description: "Description of the rule" |
107 | | - globs: "*.mdc" |
| 115 | + description: <REQUIRED: RULE_DESCRIPTION_HERE> |
| 116 | + globs: <OPTIONAL: COMMA_SEPARATED_GLOBS_HERE> |
108 | 117 | --- |
109 | 118 | ``` |
| 119 | + RULE_DESCRIPTION_HERE: the phrase placed here is like a "wake word" for the AI agent to use this agent. This is required of all cursor rules. |
| 120 | + COMMA_SEPARATED_GLOBS_HERE: if a file is being edited that matches the given glob relative to the project root (.gitignore syntax), then this rule will be activated. This acts as a gate - globs are filled in, then the rule likely won't be activated unless it matches a glob. If the globs are not filled in, then it may be activated if the description sounds like a relevant tool to the current task to the AI agent. |
110 | 121 |
|
111 | | - 2. **Use `mdc:` links** for file references, constructing a relative link from the PROJECT_ROOT to the file |
| 122 | + 2. **Use `mdc:` links** for file references, constructing a relative link from the PROJECT_ROOT to the file. The following is a link to a file at PROJECT_ROOT/src/folder/example.txt |
112 | 123 | ``` |
113 | | - [example.mdc](mdc:.cursor/rules/example.mdc) |
| 124 | + [example.txt](mdc:src/folder/example.txt) |
114 | 125 | ``` |
115 | 126 |
|
116 | 127 | 3. **Use proper headers** (`#`, `##`, `###`) and avoid inconsistent formatting. |
117 | 128 |
|
118 | 129 | examples: |
119 | 130 | - input: | |
120 | 131 | --- |
121 | | - description: "Example rule for formatting" |
| 132 | + description: Example rule for formatting |
| 133 | + globs: *.mdc |
122 | 134 | --- |
123 | 135 | # Sample Rule |
124 | 136 | This rule enforces correct `.mdc` formatting. |
| 137 | + (...) |
125 | 138 | output: "Correctly formatted `.mdc` file" |
126 | 139 |
|
127 | 140 | metadata: |
|
0 commit comments