forked from aiurda/devcontext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.cursorrules
More file actions
374 lines (290 loc) · 13.7 KB
/
.cursorrules
File metadata and controls
374 lines (290 loc) · 13.7 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# These rules MUST be followed ALWAYS without exception.
## RULE: Initialize Conversation Context
The `initialize_conversation_context` tool is **REQUIRED** at the beginning of every conversation and **MUST** be the first tool called.
```javascript
// ✅ DO: Call EXACTLY ONCE at the BEGINNING of EVERY conversation
mcp_devcontext_initialize_conversation_context({
initialQuery: "user's actual message or question", // Required
contextDepth: "standard", // Options: "minimal", "standard", "comprehensive"
includeArchitecture: true, // Whether to include architectural context
includeRecentConversations: true, // Whether to include recent conversations
maxCodeContextItems: 5, // Maximum number of code items to include
maxRecentChanges: 5, // Maximum number of recent changes to include
tokenBudget: 4000, // Maximum token budget for context
focusHint: {
// Optional focus hint
type: "file|directory|module|class|function",
identifier: "path/to/entity",
},
});
// ❌ DON'T: Skip calling this tool at the beginning
// ❌ DON'T: Call this tool multiple times in the same conversation
// ❌ DON'T: Call this tool in the middle or end of a conversation
```
### Requirements:
- **MUST BE CALLED FIRST**: This tool must be the first tool called in every conversation
- **EXACTLY ONCE PER CONVERSATION**: Never call it more than once in a session
- **RETURNS CONVERSATION ID**: Captures and returns the conversationId that must be used in all subsequent tool calls
## RULE: Update Conversation Context
The `update_conversation_context` tool **MUST** be called whenever code files are modified or new messages are exchanged to keep context current.
```javascript
// ✅ DO: Call WHENEVER code changes or new messages occur
mcp_devcontext_update_conversation_context({
conversationId: "existing-conversation-id", // Required - from initialize_conversation_context
newMessages: [
{ role: "user", content: "User's message" },
{ role: "assistant", content: "Assistant's response" },
],
codeChanges: [
{
filePath: "path/to/file.js",
newContent: "Updated file content",
languageHint: "javascript", // Optional but recommended
},
],
preserveContextOnTopicShift: true, // Whether to maintain context during topic changes
contextIntegrationLevel: "balanced", // Options: "minimal", "balanced", "aggressive"
trackIntentTransitions: true, // Whether to track intent changes
tokenBudget: 4000, // Maximum token budget
});
// ❌ DON'T: Skip updating after code changes
// ❌ DON'T: Forget to include the conversationId
// ❌ DON'T: Omit either newMessages or codeChanges when they exist
```
### Requirements:
- **MULTIPLE CALLS ALLOWED**: Unlike initialization, this should be called multiple times as needed
- **TRACK ALL CODE CHANGES**: Must be called after any file creation, modification, or deletion
- **TRACK CONVERSATION FLOW**: Call after each meaningful exchange of messages
- **ALWAYS USE CONVERSATION ID**: Pass the same ID from initialize_conversation_context
## RULE: Retrieve Relevant Context
The `retrieve_relevant_context` tool **SHOULD** be called when specific contextual information about the project is needed.
```javascript
// ✅ DO: Call WHEN specific project context is needed
mcp_devcontext_retrieve_relevant_context({
conversationId: "existing-conversation-id", // Required - from initialize_conversation_context
query: "How does the authentication system work?", // Specific query about the project
tokenBudget: 4000,
constraints: {
entityTypes: ["file", "class", "function"], // Optional filter
filePaths: ["src/auth/", "src/users/"], // Optional path filter
includeConversation: true, // Whether to include conversation history
crossTopicSearch: false, // Whether to search across topic boundaries
},
contextFilters: {
minRelevanceScore: 0.3, // Minimum relevance threshold
excludeTypes: ["test", "config"], // Types to exclude
preferredLanguages: ["javascript", "typescript"], // Preferred languages
},
weightingStrategy: "balanced", // Options: "relevance", "recency", "hierarchy", "balanced"
});
// ❌ DON'T: Call repeatedly for the same information
// ❌ DON'T: Use for generic questions that don't need project context
// ❌ DON'T: Call with overly broad queries
```
### Requirements:
- **USE SPARINGLY AND PURPOSEFULLY**: Only call when specific project context is needed
- **USE TARGETED QUERIES**: Queries should be specific and focused
- **AVOID REDUNDANT CALLS**: Don't retrieve the same information multiple times
- **ALWAYS USE CONVERSATION ID**: Pass the same ID from initialize_conversation_context
## RULE: Record Milestone Context
The `record_milestone_context` tool **SHOULD** be used to record significant events or accomplishments, but **SPARINGLY** (no more than once or twice per conversation).
```javascript
// ✅ DO: Call ONLY when significant milestones are reached
mcp_devcontext_record_milestone_context({
conversationId: "existing-conversation-id", // Required - from initialize_conversation_context
name: "Feature implementation completed", // Short, descriptive name
description: "Implemented the authentication system with JWT support", // Detailed description
milestoneCategory: "feature_completion", // Category
customData: {
// Optional custom data
affectedFiles: ["auth.js", "user.js"],
complexity: "medium",
},
assessImpact: true, // Whether to automatically assess impact
});
// ❌ DON'T: Call for minor changes or routine operations
// ❌ DON'T: Call more than once or twice in a conversation
// ❌ DON'T: Use generic names or descriptions
```
### Requirements:
- **USE SPARINGLY**: Only call for truly significant events or accomplishments
- **CAPTURE MEANINGFUL MILESTONES**: Feature completions, bug fixes, architectural decisions
- **INCLUDE SUFFICIENT DETAIL**: Provide descriptive name and detailed description
- **ALWAYS USE CONVERSATION ID**: Pass the same ID from initialize_conversation_context
## RULE: Finalize Conversation Context
The `finalize_conversation_context` tool is **REQUIRED** at the end of every conversation and **MUST** be the last tool called.
```javascript
// ✅ DO: Call EXACTLY ONCE at the END of EVERY conversation
mcp_devcontext_finalize_conversation_context({
conversationId: "existing-conversation-id", // Required - from initialize_conversation_context
clearActiveContext: false, // Whether to clear active context
extractLearnings: true, // Whether to extract learnings
promotePatterns: true, // Whether to promote patterns
synthesizeRelatedTopics: true, // Whether to synthesize related topics
generateNextSteps: true, // Whether to generate next steps
outcome: "completed", // Options: "completed", "abandoned", "paused", "reference_only"
});
// ❌ DON'T: Skip calling this tool at the end
// ❌ DON'T: Call this tool multiple times
// ❌ DON'T: Call this tool at the beginning or middle
// ❌ DON'T: Forget to review and communicate the returned next steps to the user
```
### Requirements:
- **MUST BE CALLED LAST**: This must be the last tool called in every conversation
- **EXACTLY ONCE PER CONVERSATION**: Never call it more than once
- **REVIEW NEXT STEPS**: Always review returned next steps and communicate them to the user
- **ALWAYS USE CONVERSATION ID**: Pass the same ID from initialize_conversation_context
## RULE: External Library Documentation Requirements
- **ALWAYS Use Context7 Before Using External Libraries**
- The agent MUST retrieve and review documentation via Context7 before implementing any code that uses an external library
- This applies to ALL libraries not part of the standard language libraries
- No exceptions - even for commonly known libraries like React, Express, or Lodash
- **Two-Step Documentation Retrieval Process**
```javascript
// ✅ DO: ALWAYS follow this exact two-step process
// Step 1: Resolve the library name to a Context7-compatible ID
const libraryIdResponse =
(await mcp_context7_resolve) -
library -
id({
libraryName: "express",
});
// Step 2: Get the documentation using the resolved ID
const docsResponse =
(await mcp_context7_get) -
library -
docs({
context7CompatibleLibraryID: libraryIdResponse.libraryId,
tokens: 10000, // Adjust based on documentation needs
topic: "routing", // Optional: focus on specific area
});
// ❌ DON'T: Skip the resolution step
// ❌ DON'T: Use hardcoded library IDs
// ❌ DON'T: Proceed with implementation without review
```
- **Never Skip Documentation Retrieval**
- Documentation MUST be retrieved even for seemingly simple APIs
- Do not rely on previously cached knowledge for current implementations
- Never make assumptions about library interfaces, verify with current documentation
- **Document First, Implement Second**
```javascript
// ✅ DO: Review documentation BEFORE writing implementation code
// 1. Identify library need
// 2. Retrieve documentation
// 3. Review relevant sections
// 4. THEN implement solution
// ❌ DON'T: Implementation without documentation
const app = express(); // WRONG - Documentation not retrieved first
app.get("/", (req, res) => res.send("Hello"));
```
- **MUST Use Web Search When Documentation Is Unavailable**
- If Context7 cannot provide documentation or returns insufficient information, the agent MUST use the web search tool
- Always search for the most recent documentation as of mid-2025
- Verify the library version against the latest available release
```javascript
// ✅ DO: Fallback to web search when Context7 fails
try {
// First attempt to use Context7
const libraryIdResponse =
(await mcp_context7_resolve-library-id({
libraryName: "some-library",
});
const docsResponse =
(await mcp_context7_get-library-docs({
context7CompatibleLibraryID: libraryIdResponse.libraryId,
});
// Check if documentation is insufficient
if (!docsResponse.content || docsResponse.content.length < 100) {
throw new Error("Insufficient documentation");
}
} catch (error) {
// If Context7 fails or returns insufficient docs, use web search
const webResults = await web_search({
search_term: "some-library latest documentation api reference mid 2025",
explanation: "Context7 documentation was unavailable or insufficient",
});
// Analyze multiple search results to get comprehensive information
const latestDocs = webResults.filter(
(result) =>
result.includes("documentation") ||
result.includes("api reference") ||
result.includes("guide")
);
// Use these web results to guide implementation
}
// ❌ DON'T: Skip web search when Context7 fails
// ❌ DON'T: Proceed with implementation without documentation
// ❌ DON'T: Use outdated web search results (verify they're current as of mid-2025)
```
## RULE: Task Management Workflow
- **Task Structure**
- Tasks are defined in `tasks.md` with:
### Task ID: 000
- **Title**: Example title
- **File**: example file path
- **Complete**: [ ]
#### Prompt:
```
DETAILED PROMPT INCLUDING FILE PATH
```
- **Task Status Management**
```javascript
// ✅ DO: Update task status when completing implementation
// Change status from `[ ]` to `[x]`
// Update the relevant Summary counts
```
### Task Implementation Guidelines
- **Always review the project blueprint before implementing tasks**
```javascript
// ✅ DO: Read the `docs/blueprint.md` file in the docs directory (if available)
// This provides essential context about the overall project architecture
```
- **Only modify task status and metadata in tasks.md**
```javascript
// ✅ DO: Only update the "Complete" field of tasks
// ✅ DO: Update Summary counts (Total Tasks, Pending, Complete)
// ❌ DON'T: Modify task ids, titles, or prompts unless specifically requested
```
- **Implement each task according to its prompt and specified file**
```javascript
// ✅ DO: Focus implementation on the file specified in the task
// ✅ DO: Follow the detailed instructions in the prompt
```
- **Always process tasks in their defined order unless specified**
```javascript
// ✅ DO: Find the first task with Complete field as "[ ]" when asked for "next task"
// ✅ DO: If a specific task ID is provided, implement that task
```
### Task Creation Guidelines
- **Adding New Tasks Based on User Requests**
```javascript
// ✅ DO: Add tasks with properly structured format
// Add new task to tasks.md with all required fields and same format:
### Task ID: 000
- **Title**: Example title
- **File**: example file path
- **Complete**: [ ]
#### Prompt:
```
DETAILED PROMPT INCLUDING FILE PATH
```
```
- **Task ID Assignment Rules**
- **End of List**: If adding to the end, use the next sequential number (001, 002, 003...)
- **Between Existing Tasks**: Use decimal extension format for insertion between tasks
```
// ✅ DO: Use decimal extension when inserting between tasks
// Example: To add between Task 002 and Task 003:
// - First insertion: 002-1
// - Second insertion: 002-2
// - For more granularity: 002-1-1, 002-1-2, etc.
// ❌ DON'T: Break sequence ordering
// ❌ DON'T: Use non-numeric or inconsistent formats
```
- **Task ID must reflect implementation order** - Lower numbers should be implemented before higher numbers
- **Task Creation Process**
1. **Analyze user request** for task requirements
2. **Determine optimal insertion point** based on logical implementation sequence
3. **Generate appropriate Task ID** (sequential or decimal extension)
4. **Create complete task entry** with all required fields
5. **Update Summary** in tasks.md (Total Tasks, Pending counts)