-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.clinerules-code
More file actions
174 lines (119 loc) · 5.21 KB
/
Copy path.clinerules-code
File metadata and controls
174 lines (119 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Roo Agent Rules for Code Modification
Constraint: Do NOT add comments explaining import statements, type definitions derived from schemas/models, or basic code structure. Focus ONLY on the 'why' for non-obvious logic
Zero Tolerance Rule: "Code comments are FORBIDDEN unless they explain the 'why' behind a piece of non-obvious logic. Comments explaining the 'what' of the code are never allowed. If in doubt, DO NOT add a comment."
Explicit Review Step: "Before submitting any code (via write_to_file or apply_diff), perform a final check: read every comment and delete it if it merely describes the code below it or the task at hand."
Keyword Ban: "Do not use comments like '// Import ...', '// Define ...', '// Call ...', '// Return ...', '// Instantiate ...', '// Map ...', '// Access ...', '// Create ...', '// Use foo directly', etc."
STRICT Requirement for ALL edits: Read your edit before writing it to a file. Ensure it complies with the comment rules above. If it does not, revise it until it does.
Do NOT add comments solely to describe the change being made in a diff or to explain standard code patterns (like defining a method). Comments must strictly adhere to explaining the 'why' of non-obvious logic.
## 1. Pre-Edit Analysis Requirements
BEFORE making any code changes, MUST:
- Use `mcp__get_document_symbols` on the target file to understand its structure
- Use `mcp__find_usages` on any symbol being modified to identify all affected locations
- Use `mcp__get_type_definition` and/or `mcp__go_to_definition` for any types or symbols being modified
- Use `mcp__get_hover_info` to verify function signatures and type information
## 2. Impact Analysis Rules
BEFORE proceeding with changes:
1. If `mcp__find_usages` reveals usage in multiple files:
- Must analyze each usage context
- Must verify type compatibility across all uses
- Must plan changes for all affected locations
2. If modifying interfaces or types:
- Must use `mcp__find_implementations` to locate all implementations
- Must ensure changes won't break implementing classes
- Must verify backward compatibility or plan updates for all implementations
## 3. Type Safety Rules
MUST maintain type safety by:
1. Using `mcp__get_type_definition` for:
- All modified parameters
- Return types
- Interface members
- Generic constraints
2. Using `mcp__get_hover_info` to verify:
- Function signatures
- Type constraints
- Optional vs required properties
## 4. Code Modification Sequence
When making changes:
1. First gather context:
```typescript
// Example sequence
await mcp__get_document_symbols(file)
await mcp__find_usages(symbol)
await mcp__get_type_definition(symbol)
await mcp__get_hover_info(symbol)
```
2. Then analyze impact:
```typescript
// For each usage found
await mcp__get_hover_info(usage)
await mcp__get_type_definition(relatedTypes)
```
3. Only then use `edit_file`
## 5. Post-Edit Verification
After making changes:
1. Use `mcp__get_document_symbols` to verify file structure remains valid
2. Use `mcp__find_usages` to verify all usages are still compatible
3. Use `mcp__get_hover_info` to verify new type signatures
## 6. Special Cases
### When Modifying React Components:
1. Must use `mcp__find_usages` to:
- Find all component instances
- Verify prop usage
- Check for defaultProps and propTypes
2. Must use `mcp__get_type_definition` for:
- Prop interfaces
- State types
- Context types
### When Modifying APIs/Functions:
1. Must use `mcp__get_call_hierarchy` to:
- Understand the call chain
- Identify dependent functions
- Verify changes won't break callers
### When Modifying Types/Interfaces:
1. Must use `mcp__find_implementations` to:
- Locate all implementing classes
- Verify compatibility
- Plan updates if needed
## 7. Error Prevention Rules
1. NEVER modify a symbol without first:
```typescript
await mcp__find_usages(symbol)
await mcp__get_type_definition(symbol)
```
2. NEVER modify a type without:
```typescript
await mcp__find_implementations(type)
await mcp__get_hover_info(type)
```
3. NEVER modify a function signature without:
```typescript
await mcp__get_call_hierarchy(function)
await mcp__find_usages(function)
```
## 8. Documentation Requirements
When explaining changes, must reference:
1. What tools were used to analyze the code
2. What usages were found
3. What type information was verified
4. What impact analysis was performed
Example:
```markdown
I analyzed the code using:
1. mcp\_\_find_usages to locate all 5 usages of handleSubmit
2. mcp\_\_get_type_definition to verify the function signature
3. mcp\_\_get_hover_info to check parameter types
4. mcp\_\_get_document_symbols to understand the component structure
```
## 9. Change Abort Conditions
Must ABORT changes if:
1. `mcp__find_usages` reveals unexpected usages
2. `mcp__get_type_definition` shows incompatible types
3. `mcp__find_implementations` shows breaking changes
4. Unable to verify full impact using available tools
## 10. Tool Priority Order
When analyzing code, use tools in this order:
1. `mcp__get_document_symbols` (understand structure)
2. `mcp__find_usages` (understand impact)
3. `mcp__get_type_definition` (verify types)
4. `mcp__get_hover_info` (verify signatures)
5. Additional tools as needed