|
| 1 | +# Cursor Rules - Optimized Structure |
| 2 | + |
| 3 | +This directory contains optimized Cursor rules that follow the latest specification and best practices, including an **auto-improvement system** that automatically detects patterns and suggests rule enhancements. |
| 4 | + |
| 5 | +## Rule Structure |
| 6 | + |
| 7 | +### Core Rules |
| 8 | +- **[cursor_rules.mdc](mdc:.cursor/rules/cursor_rules.mdc)** - Main specification and formatting guidelines |
| 9 | +- **[self_improve.mdc](mdc:.cursor/rules/self_improve.mdc)** - Continuous improvement and pattern recognition |
| 10 | +- **[auto_improvement.mdc](mdc:.cursor/rules/auto_improvement.mdc)** - **NEW**: Automatic rule improvement system |
| 11 | + |
| 12 | +### Domain-Specific Rules |
| 13 | +- **[authentication_best_practices.mdc](mdc:.cursor/rules/authentication/authentication_best_practices.mdc)** - Security and authentication guidelines |
| 14 | +- **[hotchocolate_best_practices.mdc](mdc:.cursor/rules/hotchocolate/hotchocolate_best_practices.mdc)** - GraphQL and HotChocolate best practices |
| 15 | + |
| 16 | +### Workflow Rules |
| 17 | +- **[development_workflow.mdc](mdc:.cursor/rules/development_workflow.mdc)** - Development process and project organization |
| 18 | + |
| 19 | +### Automation Tools |
| 20 | +- **[pattern_detector.ps1](mdc:.cursor/rules/pattern_detector.ps1)** - **NEW**: PowerShell script for automatic pattern detection |
| 21 | + |
| 22 | +## 🚀 Auto-Improvement System |
| 23 | + |
| 24 | +### What It Does |
| 25 | +The auto-improvement system automatically detects when the same patterns appear multiple times in your codebase and suggests rule improvements: |
| 26 | + |
| 27 | +- **Pattern Detection**: Identifies recurring code patterns across 3+ files |
| 28 | +- **Rule Suggestions**: Automatically generates new rule suggestions |
| 29 | +- **Quality Metrics**: Assesses rule completeness and effectiveness |
| 30 | +- **Cross-Referencing**: Maintains rule relationships and dependencies |
| 31 | + |
| 32 | +### How It Works |
| 33 | +1. **Automatic Detection**: Monitors code for recurring patterns |
| 34 | +2. **Threshold Triggers**: Suggests improvements when patterns appear 3+ times |
| 35 | +3. **Rule Generation**: Creates comprehensive rule suggestions |
| 36 | +4. **Quality Assessment**: Evaluates rule effectiveness and completeness |
| 37 | + |
| 38 | +### Pattern Categories Detected |
| 39 | +- **Architectural Patterns**: Service registration, DI, middleware |
| 40 | +- **Code Quality**: Error handling, logging, validation |
| 41 | +- **Performance**: Database queries, caching, async patterns |
| 42 | +- **Security**: Authentication, authorization, input validation |
| 43 | + |
| 44 | +### Usage |
| 45 | +```powershell |
| 46 | +# Run pattern detection (PowerShell) |
| 47 | +.\pattern_detector.ps1 -ProjectRoot . -PatternThreshold 3 |
| 48 | +
|
| 49 | +# Customize detection |
| 50 | +.\pattern_detector.ps1 -PatternThreshold 5 -OutputFile "custom_analysis.json" |
| 51 | +``` |
| 52 | + |
| 53 | +## Rule Format |
| 54 | + |
| 55 | +All rules follow this standardized format: |
| 56 | + |
| 57 | +```markdown |
| 58 | +--- |
| 59 | +description: Clear, one-line description of what the rule enforces |
| 60 | +globs: path/to/files/*.ext, other/path/**/* |
| 61 | +alwaysApply: boolean |
| 62 | +--- |
| 63 | + |
| 64 | +# Rule Title |
| 65 | + |
| 66 | +## Section |
| 67 | + |
| 68 | +- **Key Point in Bold** |
| 69 | + - Sub-points with details |
| 70 | + - Examples and explanations |
| 71 | +``` |
| 72 | + |
| 73 | +## Usage |
| 74 | + |
| 75 | +1. **Always Apply Rules**: These rules are automatically applied to all relevant files |
| 76 | +2. **Domain Rules**: Apply to specific file types or directories |
| 77 | +3. **Cross-References**: Rules reference each other for consistency |
| 78 | +4. **Auto-Improvement**: Rules automatically improve based on detected patterns |
| 79 | + |
| 80 | +## Optimization Benefits |
| 81 | + |
| 82 | +- **Eliminated Duplication**: Consolidated similar rules into comprehensive files |
| 83 | +- **Standardized Format**: All rules follow the same structure and metadata |
| 84 | +- **Proper Cross-Referencing**: Rules link to each other for maintainability |
| 85 | +- **Focused Scope**: Each rule file has a clear, specific purpose |
| 86 | +- **Latest Specification**: Follows current Cursor rules best practices |
| 87 | +- **🚀 Auto-Improvement**: Rules automatically evolve based on codebase patterns |
| 88 | + |
| 89 | +## Maintenance |
| 90 | + |
| 91 | +- **Automatic**: The auto-improvement system detects and suggests updates |
| 92 | +- **Manual**: Update rules when new patterns emerge |
| 93 | +- **Examples**: Add examples from actual codebase |
| 94 | +- **Cross-Reference**: Rules automatically maintain references |
| 95 | +- **Quality**: Follow the self-improvement guidelines in [self_improve.mdc](mdc:.cursor/rules/self_improve.mdc) |
| 96 | + |
| 97 | +## Auto-Improvement Workflow |
| 98 | + |
| 99 | +1. **Pattern Detection**: System monitors code for recurring patterns |
| 100 | +2. **Threshold Trigger**: When pattern appears 3+ times, system suggests improvement |
| 101 | +3. **Rule Suggestion**: Generates comprehensive rule or update suggestion |
| 102 | +4. **Quality Assessment**: Evaluates rule completeness and effectiveness |
| 103 | +5. **Implementation**: Apply approved rule improvements |
| 104 | +6. **Continuous Monitoring**: System continues to detect new patterns |
| 105 | + |
| 106 | +## Backup |
| 107 | + |
| 108 | +A complete backup of all rules is available in `cursor-rules-backup-YYYYMMDD-HHMMSS.zip` in the project root. |
| 109 | + |
| 110 | +## Next Steps |
| 111 | + |
| 112 | +1. **Run Pattern Detection**: Execute `.\pattern_detector.ps1` to analyze your codebase |
| 113 | +2. **Review Suggestions**: Check generated rule suggestions in `pattern_analysis.json` |
| 114 | +3. **Implement Improvements**: Apply high-priority rule enhancements |
| 115 | +4. **Monitor Quality**: Use the auto-improvement system for continuous enhancement |
0 commit comments