Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions .cursor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
# .cursor Folder Guide

This directory contains rules and plans that help Cursor AI understand your project better and provide more accurate assistance.

## Directory Structure

```
.cursor/
├── rules/ # AI assistant rules and guidelines
├── plans/ # Project plans and feature documentation
├── templates/ # Code templates for reuse
└── README.md # This file
```

## Rules Directory (`rules/`)

Rules are markdown files (`.mdc`) that guide the AI assistant's behavior. Each rule file has frontmatter metadata:

### Frontmatter Options

```yaml
---
description: Brief description of what this rule covers
globs: ["**/*.dart"] # File patterns this rule applies to
alwaysApply: false # Whether to always apply this rule
---
```

### Rule File Examples

1. **Language-Specific Rules** (`example-language-specific.mdc`)
- Apply to specific file types using glob patterns
- Example: Dart-specific conventions

2. **Always Apply Rules** (`example-always-apply.mdc`)
- Rules that apply to every conversation
- Use `alwaysApply: true`
- Good for project-wide conventions

3. **Conditional Rules** (`example-conditional-rules.mdc`)
- Apply to specific directories or patterns
- Example: Core package rules, feature module rules

4. **Testing Rules** (`example-testing-rules.mdc`)
- Rules for test files
- Testing conventions and best practices

5. **API/Service Rules** (`example-api-rules.mdc`)
- Rules for service layer code
- Interface/implementation patterns

6. **UI Rules** (`example-ui-rules.mdc`)
- Widget and UI development guidelines
- Page structure conventions

7. **Complex Globs** (`example-complex-globs.mdc`)
- Advanced glob pattern examples
- Inclusion and exclusion patterns

8. **Shortcuts** (`example-shortcuts.mdc`)
- Quick reference for common tasks
- Build commands, testing commands, etc.

9. **Reusable Patterns** (`example-reusable-patterns.mdc`)
- Common code patterns the AI can reference
- Service, page, test, repository patterns

### Glob Pattern Examples

```yaml
# Single pattern
globs: ["**/*.dart"]

# Multiple patterns
globs: ["**/*.dart", "**/*.ts"]

# Directory-specific
globs: ["packages/core/**"]

# Exclude patterns (use !)
globs:
- "**/*.dart"
- "!**/*.g.dart" # Exclude generated files
- "!**/test/**" # Exclude test directories

# Multiple file types
globs: ["**/*.{dart,ts,js}"]
```

## Plans Directory (`plans/`)

Plans are markdown files that document features, refactoring efforts, or project goals.

### Plan File Examples

1. **Feature Plan** (`example-feature-plan.mdc`)
- Structure for planning new features
- Includes goals, requirements, implementation steps

2. **Refactoring Plan** (`example-refactoring-plan.mdc`)
- Structure for refactoring efforts
- Includes current state, target state, migration strategy

### Plan Frontmatter

```yaml
---
title: Plan Title
status: planning | in-progress | completed | cancelled
priority: low | medium | high
tags: [tag1, tag2, tag3]
---
```

## Templates Directory (`templates/`)

Template files are complete code files you can copy and customize.

### Available Templates

1. **Service Template** (`example-service-template.dart`)
- Service interface + implementation structure
- Includes dependency injection setup

2. **Page Template** (`example-page-template.dart`)
- Flutter page with Scaffold structure
- Follows project conventions

3. **Test Template** (`example-test-template.dart`)
- Test file structure with setup/teardown
- Arrange-Act-Assert pattern

4. **Freezed Model Template** (`example-freezed-model-template.dart`)
- Freezed model with JSON serialization
- Ready for code generation

5. **Snippets Examples** (`example-snippets.json`)
- Example snippets for `.vscode/snippets.code-snippets`
- Service, page, widget, model snippets

## Best Practices

1. **Keep Rules Focused**
- One rule file per concern or domain
- Don't mix unrelated guidelines

2. **Use Descriptive Names**
- Name files clearly: `testing-rules.mdc`, `ui-guidelines.mdc`
- Use kebab-case for file names

3. **Organize by Domain**
- Group related rules together
- Use subdirectories if needed (e.g., `rules/ui/`, `rules/testing/`)

4. **Keep Plans Updated**
- Update plan status as work progresses
- Add notes and learnings

5. **Use Always Apply Sparingly**
- Only use `alwaysApply: true` for critical, universal rules
- Most rules should be context-specific

## Creating Your Own Rules

1. Create a new `.mdc` file in `rules/`
2. Add frontmatter with appropriate metadata
3. Write clear, actionable guidelines
4. Use code examples when helpful
5. Reference existing patterns in your codebase

## Creating Your Own Plans

1. Create a new `.mdc` file in `plans/`
2. Add frontmatter with title, status, priority, tags
3. Document the plan following the examples
4. Update status as work progresses

## Reusable Content

For information on creating reusable code snippets, templates, and patterns, see:
- **[REUSABLE-CONTENT-GUIDE.md](REUSABLE-CONTENT-GUIDE.md)** - Complete guide on all reusable content options

### Quick Summary

1. **Code Snippets** (`.vscode/snippets.code-snippets`) - Fast code insertion
2. **Templates** (`.cursor/templates/`) - Complete file templates
3. **Reusable Patterns** (`.cursor/rules/example-reusable-patterns.mdc`) - AI-referenced patterns
4. **Example Snippets** (`.cursor/templates/example-snippets.json`) - More snippet examples

## Tips

- Start with a few key rules and expand as needed
- Review and update rules regularly
- Remove outdated or conflicting rules
- Use plans to track complex features or refactoring
- Reference existing code patterns in your rules
- Use snippets for frequently used code blocks
- Use templates for complete file structures
Empty file added .cursor/commands/create-pr.md
Empty file.
Empty file.
46 changes: 46 additions & 0 deletions .cursor/plans/example-feature-plan.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Example Feature Plan
status: planning
priority: high
tags: [feature, ui, backend]
---

# Example Feature Plan

This is an example of how to structure a feature plan in the `.cursor/plans/` directory.

## Overview
Brief description of what this feature will accomplish.

## Goals
- Primary goal 1
- Primary goal 2
- Secondary goal 1

## Requirements
1. Requirement 1
2. Requirement 2
3. Requirement 3

## Implementation Steps
- [ ] Step 1: Setup and preparation
- [ ] Step 2: Core implementation
- [ ] Step 3: Testing
- [ ] Step 4: Documentation
- [ ] Step 5: Review and merge

## Technical Considerations
- Consideration 1
- Consideration 2

## Dependencies
- Package/feature dependency 1
- Package/feature dependency 2

## Testing Strategy
- Unit tests for business logic
- Widget tests for UI components
- Integration tests for user flows

## Notes
Additional notes, questions, or concerns about this feature.
29 changes: 29 additions & 0 deletions .cursor/plans/example-refactoring-plan.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Example Refactoring Plan
status: in-progress
priority: medium
tags: [refactoring, technical-debt]
---

# Example Refactoring Plan

This demonstrates how to plan a refactoring effort.

## Current State
Description of the current implementation and its issues.

## Target State
Description of the desired state after refactoring.

## Risks
- Risk 1 and mitigation strategy
- Risk 2 and mitigation strategy

## Migration Strategy
1. Phase 1: Preparation
2. Phase 2: Incremental changes
3. Phase 3: Cleanup

## Success Criteria
- Criterion 1
- Criterion 2
27 changes: 27 additions & 0 deletions .cursor/rules/example-always-apply.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
description: Rules that always apply to all conversations
globs:
alwaysApply: true
---

# Always Apply Rules Example

This rule file demonstrates how to create rules that **always apply** to every conversation, regardless of context.

## Usage
- `alwaysApply: true` - Makes these rules active in every conversation
- `globs` can be empty when using `alwaysApply: true`
- Use this for project-wide conventions and critical guidelines

## Project-Wide Rules
1. **Never commit secrets or API keys** - Always use environment variables
2. **Write tests for new features** - Maintain at least 80% coverage
3. **Follow conventional commits** - Use format: `type(scope): message`
4. **Run linter before committing** - Fix all warnings and errors
5. **Document public APIs** - Add doc comments for exported functions/classes

## Code Quality Standards
- All code must pass static analysis
- All tests must pass before merging
- Code reviews are required for all PRs
- Keep functions under 50 lines when possible
36 changes: 36 additions & 0 deletions .cursor/rules/example-api-rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
description: API and service layer conventions
globs: ["**/services/**", "**/api/**", "**/repositories/**"]
alwaysApply: false
---

# API and Service Rules Example

This rule file demonstrates rules for API and service layer code.

## Service Layer Conventions

### Interface Requirements
- Every service implementation must have an interface
- Interface files: `i_<service_name>_service.dart`
- Implementation files: `<service_name>_service.dart`
- Interfaces in `interfaces/` directory
- Implementations in `implementations/` directory

### Error Handling
- Always handle network errors gracefully
- Return `Result<T>` or `Either<Error, T>` types
- Log errors appropriately
- Never expose internal error details to UI

### Async Operations
- Use `Future` for async operations
- Always handle timeouts
- Use proper cancellation tokens
- Document expected response times

### Testing Services
- Mock external dependencies
- Test error scenarios
- Test timeout handling
- Verify proper error propagation
46 changes: 46 additions & 0 deletions .cursor/rules/example-complex-globs.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
description: Example of complex glob patterns
globs:
- "packages/**/*.dart"
- "apps/**/lib/features/**/*.dart"
- "!**/*.g.dart"
- "!**/*.freezed.dart"
- "!**/*.mocks.dart"
alwaysApply: false
---

# Complex Glob Patterns Example

This demonstrates advanced glob pattern usage.

## Glob Pattern Features

### Inclusion Patterns
- `packages/**/*.dart` - All Dart files in packages directory
- `apps/**/lib/features/**/*.dart` - All Dart files in feature directories

### Exclusion Patterns (using `!`)
- `!**/*.g.dart` - Exclude generated files
- `!**/*.freezed.dart` - Exclude Freezed generated files
- `!**/*.mocks.dart` - Exclude mock files

## Use Cases
- Apply rules to source files but not generated files
- Target specific directory structures
- Exclude test files or build artifacts
- Create rules for specific package types

## Pattern Examples
```yaml
globs:
# Include patterns
- "**/*.dart" # All Dart files
- "packages/core/**" # Everything in core package
- "apps/**/lib/**" # All lib directories in apps
- "**/*.{dart,ts,js}" # Multiple file extensions

# Exclude patterns (must come after includes)
- "!**/test/**" # Exclude test directories
- "!**/*.g.dart" # Exclude generated files
- "!**/node_modules/**" # Exclude dependencies
```
Loading