-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcursor-rules-location.mdc
More file actions
289 lines (225 loc) · 10.4 KB
/
cursor-rules-location.mdc
File metadata and controls
289 lines (225 loc) · 10.4 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
---
description: Cursor Rules organization and file structure standards
globs: ["**/*.mdc", ".cursorrules"]
alwaysApply: true
---
# Cursor Rules Organization - Modern Standards
Implement effective organization and file structure standards for Cursor AI rules and configuration files in the repository.
## When to Apply
Use these guidelines when:
- Organizing cursor rules for a new project
- Restructuring existing cursor configuration
- Adding new domain-specific rule files
- Updating rules for better AI understanding
- Migrating from legacy cursor rule patterns
## Core Principles
- ✅ **Clear Hierarchy**: Primary rules in root, specialized rules in subdirectories
- ✅ **Single Responsibility**: Each rule file has a focused purpose
- ✅ **Consistent Structure**: Standardized format across all rule files
- ✅ **Actionable Content**: Rules provide implementation guidance, not just documentation
- ✅ **Maintainable**: Easy to update and extend as project evolves
- ✅ **AI-Friendly**: Structured for optimal Cursor AI understanding
## Implementation Guide
### Step 1: File Structure Setup
Organize cursor rules following modern 2024/2025 best practices:
```
stream-feeds-flutter/
├── .cursorrules # Primary development rules
├── .cursor/
│ └── rules/ # Supplementary documentation
│ ├── project-overview.mdc # Development context & architecture
│ ├── stream-feeds-sdk.mdc # SDK implementation patterns
│ ├── stream-feeds-api.mdc # Stream Feeds API overview
│ ├── planit-mode.mdc # Structured development methodology
│ ├── cursor-rules-location.mdc # This file - organization docs
│ └── patterns/ # Implementation pattern rules
│ ├── data-models.mdc # @freezed data class guidelines
│ ├── query-specifications.mdc # Query class patterns
│ ├── repository-pattern.mdc # Repository implementation
│ ├── data-mapping.mdc # Extension function mapping
│ └── state-management.mdc # StateNotifier patterns
└── ...
```
### Step 2: Primary Configuration
Create the main `.cursorrules` file in project root:
```
# Stream Feeds Dart SDK - Cursor Rules
You are an expert Dart developer working on the Stream Feeds Dart SDK, a professional real-time activity feeds SDK. Follow these guidelines strictly.
## Project Context
This is a pure Dart SDK that implements the Stream Feeds API for real-time social feeds and activity streams. The SDK:
- Provides activity feeds, social interactions, and real-time updates
- Works across all Dart environments (Flutter, Dart VM, Dart Web)
- Uses WebSocket for real-time updates and OpenAPI-generated HTTP client for API communication
- Implements StateNotifier-based reactive state management with automatic notifications
- Uses @freezed models for immutable data structures
## Architecture & Design Patterns
### Project Structure
- Follow the existing structure: `lib/src/` for implementation details
- Keep public API in `lib/` root files (main entry point: `stream_feeds.dart`)
- Use `@includeInBarrelFile` to mark classes/functions for public API export
- Generated barrel files automatically export public elements from `lib/src/`
- Tests mirror the lib structure in `test/`
- Use clear layer separation: core, data, presentation, client, state_objects
// ... more specific guidelines
```
### Step 3: Supplementary Rules Structure
Create specialized `.mdc` files for complex contexts:
```yaml
---
description: Brief description of rule purpose
globs: ["**/*.dart", "**/*.swift"] # File patterns to apply to
alwaysApply: true/false # Whether to apply automatically
---
# Rule Title - Action-Oriented Description
Brief description of what this rule accomplishes and when to use it.
## When to Apply
Use these guidelines when:
- Specific trigger condition 1
- Specific trigger condition 2
- Specific trigger condition 3
## Core Principles
- ✅ **Principle 1**: Clear, actionable guidance
- ✅ **Principle 2**: Specific implementation approach
- ✅ **Principle 3**: Measurable outcome
## Implementation Guide
### Step 1: Title
Detailed implementation instructions...
### Step 2: Title
More implementation steps...
## Best Practices Checklist
When implementing, ensure:
- [ ] Checklist item 1
- [ ] Checklist item 2
- [ ] Checklist item 3
## Success Criteria
A well-implemented solution should:
- ✅ Measurable criterion 1
- ✅ Measurable criterion 2
- ✅ Measurable criterion 3
```
### Step 4: Naming Conventions
Apply consistent naming standards:
#### File Naming
- **`.cursorrules`**: Always this exact filename in root
- **`.mdc files`**: Use kebab-case, descriptive names (e.g., `stream-feeds-api.mdc`)
- **Subdirectories**: Use lowercase, functional grouping (e.g., `patterns/`, `testing/`)
#### Content Naming
- **Descriptive**: Names should indicate purpose clearly
- **Action-Oriented**: Use active verbs in titles ("Implement X", "Build Y", "Create Z")
- **Consistent**: Follow established patterns across all rule files
## Organization Strategy
### Top-Level Rules (`.cursor/rules/`)
- **Project Overview**: High-level architecture and context
- **SDK Documentation**: Main SDK explanation and features
- **API Documentation**: External API and service information
- **Organization Guidelines**: This file and meta-documentation
### Patterns Subdirectory (`.cursor/rules/patterns/`)
- **Component-Specific**: Rules for specific code component types
- **Implementation Focus**: Detailed coding patterns and best practices
- **Architectural Layers**: Organized by responsibility (data, state, mapping)
- **Code Examples**: Rich examples and implementation guidelines
### Content Guidelines
#### For .cursorrules (Primary)
- Focus on general development patterns
- Include language/framework specific guidelines
- Define code style and architecture preferences
- Keep concise but comprehensive
#### For .mdc files (Supplementary)
- Use YAML frontmatter for metadata
- Include detailed context and examples
- Focus on specific domains or complex scenarios
- Use action-oriented structure (When to Apply, Implementation Guide, Success Criteria)
## Code Generation & Barrel Files
### Barrel Files Strategy
- Use `barrel_files` package for automated public API management
- Place `@includeInBarrelFile` annotation on public classes, enums, and functions
- Keep implementation details in `lib/src/` without annotations
- Generate barrel files with `build_runner` alongside other code generation
### Dependencies Setup
```yaml
dependencies:
barrel_files_annotation: ^0.1.1
dev_dependencies:
barrel_files: ^0.1.1
build_runner: ^2.4.7
```
### Public API Guidelines
- Mark only classes/functions intended for external package usage
- Internal SDK components should remain in `lib/src/` without annotations
- Repository classes, mappers, and internal state objects are not public
- Only client interfaces, data models, queries, and exceptions are public
## Maintenance Strategy
### Integration from Legacy Patterns
1. **Primary rules** → Move to `.cursorrules` in root
2. **Complex rules** → Keep as `.mdc` files in `.cursor/rules/`
3. **Update metadata** → Add proper YAML frontmatter
4. **Consolidate overlaps** → Avoid duplication between files
### Ongoing Maintenance
- Keep `.cursorrules` as the primary entry point
- Use `.mdc` files for specialized contexts only
- Review rules quarterly for framework updates
- Update based on framework/language evolution
- Tag rule versions in git for change tracking
- Document rule changes in commit messages
### Quality Standards
- **Specificity**: Rules should be specific to project needs
- **Clarity**: Clear, actionable guidelines
- **Currency**: Updated for latest framework versions
- **Completeness**: Cover common development scenarios
- **Validation**: Rules should be testable and verifiable
## Best Practices Checklist
When organizing cursor rules, ensure:
- [ ] Used clear file structure with `.cursorrules` in root
- [ ] Applied consistent naming conventions (kebab-case for .mdc)
- [ ] Added proper YAML frontmatter to .mdc files
- [ ] Organized by functional responsibility
- [ ] Used action-oriented language throughout
- [ ] Included implementation guides and success criteria
- [ ] Avoided duplication between files
- [ ] Made rules specific to project needs
- [ ] Updated content for latest framework versions
- [ ] Documented organization decisions
## Common Organization Patterns
### Basic Project Setup
```
PROJECT_ROOT/
├── .cursorrules # Primary rules (REQUIRED)
├── .cursor/
│ └── rules/ # Supplementary rules (OPTIONAL)
│ ├── project-context.mdc # Project-specific context
│ ├── architecture-rules.mdc # Architecture guidelines
│ └── domain-specs.mdc # Domain-specific patterns
└── ...
```
### Advanced Multi-Domain Setup
```
PROJECT_ROOT/
├── .cursorrules # Primary development rules
├── .cursor/
│ └── rules/ # Specialized contexts
│ ├── project-overview.mdc # High-level context
│ ├── sdk-patterns.mdc # SDK-specific patterns
│ ├── api-integration.mdc # External API patterns
│ └── patterns/ # Implementation patterns
│ ├── data-models.mdc # Data structure patterns
│ ├── state-mgmt.mdc # State management patterns
│ └── testing.mdc # Testing strategies
└── ...
```
### Rule Validation in CI
- Validate YAML frontmatter syntax
- Check for broken internal links
- Verify code examples compile
- Test rule consistency across files
## Success Criteria
A well-organized cursor rules system should:
- ✅ Provide clear, actionable guidance for AI and developers
- ✅ Follow consistent structure and naming conventions
- ✅ Scale effectively as project complexity grows
- ✅ Support easy maintenance and updates
- ✅ Include proper validation and quality checks
- ✅ Focus on implementation guidance over documentation
- ✅ Use modern 2024/2025 best practices
- ✅ Support both general and specialized development contexts
- ✅ Include automated rule validation in CI/CD
- ✅ Balance simplicity with flexibility for complex scenarios