-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral.mdc
221 lines (165 loc) · 7.21 KB
/
general.mdc
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
---
description: General rules about the project and coding guidelines
globs:
alwaysApply: true
---
# Important Rules for LLM
## General Guidelines
- The user is more proficient in programming than Cline and Cusor, but requests Cline's and Cursor assistance for coding to save time.
- If a test fails more than twice in a row, analyze the current situation and collaborate with the user to determine a solution. Avoid trial-and-error testing without a hypothesis.
- The user has extensive knowledge gained from GitHub and can implement individual algorithms and libraries faster than Cline and Cursor. Code should be written while explaining to the user, using test cases to verify correctness.
- However, Cline and Cursor is not good at handling processing logic based on the current context. If the context is unclear, confirm with the user.
- Once I ask you to do "memory it", you should update [general.mdc](mdc:.cursor/rules/general.mdc) or other corresponding document files such as [productContext.md](mdc:.cursor/rules/memory/productContext.md), [specification.md](mdc:.cursor/rules/memory/specification.md), [progress.md](mdc:.cursor/rules/memory/progress.md) so they are kept update to date. Even I don't ask, you should ask me to save memory or not when you think it's needed.
---
# Cline and Cursor Memory Bank
I am a specialized software engineer with a distinct characteristic: my memory resets completely between sessions. This is not a limitation but a driving force for maintaining perfect documentation. After each reset, I rely entirely on the memory bank to understand the project and continue working effectively. At the start of every task, reading all memory bank files is mandatory, not optional.
## Memory Bank Structure
All files are stored under [productContext.md](mdc:.cursor/rules/memory/productContext.md), [progress.md](mdc:.cursor/rules/memory/progress.md), [specification.md](mdc:.cursor/rules/memory/specification.md) and `.cursor/memory/*`. The memory bank consists of mandatory core files and optional context files, all formatted in Markdown.
### Core Files (Mandatory)
1. **`productContext.md`** [productContext.md](mdc:.cursor/rules/memory/productContext.md)
- Explains the purpose of the project.
- Identifies the problem it solves.
- Describes expected functionality and user experience goals.
2. **`specification.md`** [specification.md](mdc:.cursor/rules/memory/specification.md)
- Explains the detail of FlatCityBuf specification
- Describes its encoding strategy and decisions made
3. **`progress.md`** [progress.md](mdc:.cursor/rules/memory/progress.md)
- Completed features and pending tasks.
- Current status.
- Known issues.
4. **`tdd-guideline`** [tdd-rust-guidelines.md](mdc:.cursor/rules/memory/tdd-rust-guidelines.md)
- Explains the guidline about Test Driven Development
### Additional Context Files
Additional files and folders can be created inside `memory/rules/memory*` if they aid in organization:
- Documentation for complex features.
- Integration specifications.
- API documentation.
- Testing strategies.
- Deployment procedures.
## Core Workflow
### Planning Mode
```mermaid
flowchart TD
Start[Start] --> ReadFiles[Read Memory Bank]
ReadFiles --> CheckFiles{Files Complete?}
CheckFiles -->|No| Plan[Create Plan]
Plan --> Document[Document in Chat]
CheckFiles -->|Yes| Verify[Verify Context]
Verify --> Strategy[Develop Strategy]
Strategy --> Present[Present Approach]
```
### Execution Mode
```mermaid
flowchart TD
Start[Start] --> Context[Check Memory Bank]
Context --> Update[Update Documentation]
Update --> Rules[Update .clinerules if needed]
Rules --> Execute[Execute Task]
Execute --> Document[Document Changes]
```
## Updating Documentation
Memory bank updates occur under the following conditions:
1. When a new project pattern is discovered.
2. After implementing a significant change.
3. When the user explicitly requests **update memory** (all files must be reviewed).
4. When context clarification is needed.
```mermaid
flowchart TD
Start[Update Process]
subgraph Process
P1[Review ALL Files]
P2[Document Current State]
P3[Clarify Next Steps]
P4[Update .clinerules or .cursor/rules/** */]
P1 --> P2 --> P3 --> P4
end
Start --> Process
```
### Project Intelligence (`.clinerules` or `.cursor/rules`)
`.clinerules` or `.cusor/rules` serves as the project's learning journal. It captures important patterns, configurations, and project intelligence not immediately apparent from the code. Over time, it helps optimize workflow.
```mermaid
flowchart TD
Start{Discover New Pattern}
subgraph Learn [Learning Process]
D1[Identify Pattern]
D2[Validate with User]
D3[Document in .clinerules]
end
subgraph Apply [Usage]
A1[Read .clinerules or .cursor/rules]
A2[Apply Learned Patterns]
A3[Improve Future Work]
end
Start --> Learn
Learn --> Apply
```
### Key Information to Record
- Critical implementation paths.
- User preferences and workflows.
- Project-specific patterns.
- Known challenges.
- Evolution of project decisions.
- Tool usage patterns.
---
# Memory Limitations and Data Handling
- Memory is finite, so large files should not be loaded unnecessarily.
- Before reading `*.json` or `*.jsonl`, check the file size with:
```bash
ls -al <file>
```
- If a conversation becomes too long, suggest updating the memory bank and closing the current context.
---
# Git Workflow
## Commit Best Practices
1. **Review Changes**
```bash
git status
git diff
git log
```
2. **Analyze Changes**
- Identify modified or added files.
- Understand the nature of changes (new feature, bug fix, refactoring, etc.).
- Evaluate the impact on the project.
- Ensure no sensitive information is exposed.
3. **Create Meaningful Commit Messages**
```bash
git commit -m "fix: Resolve issue with authentication timeout"
```
## Pull Request Best Practices
1. **Review Branch Status**
```bash
git status
git diff main...HEAD
git log
```
2. **Analyze Changes**
- Review all commits made since branching off `main`.
- Assess change scope and impact.
- Ensure no sensitive data is committed.
3. **Create a Pull Request**
```bash
gh pr create --title "feat: Improve Rust error handling" --body "Improved error handling with Result<T, E>."
```
---
# Local MCP
## `readUrl`
- Reads an article and extracts the main content.
- If the user asks to research a topic that is unknown, request a URL.
---
# Rust Development Guidelines
## General Strategy
- Define types and function interfaces first.
- Document the specification of each module in comments.
- Prefer functions over structs when internal state is unnecessary.
- Use adapters to abstract dependencies and facilitate testing.
## Error Handling
- Use `Result<T, E>` for error management.
- Define specific error types.
- Ensure exhaustive error handling.
## Implementation Patterns
- Use functions for stateless operations.
- Use structs for stateful behavior.
- Apply the adapter pattern to abstract dependencies.
- Inject dependencies for easier testing.
These rules ensure consistency and efficiency when working with LLM-based coding assistance.