Advanced Cursor IDE rules system for intelligent code generation with context-aware routing and specialized workflows
This repository contains a production-ready Cursor rules system that transforms your AI-assisted development workflow. Unlike simple .cursorrules files, this system implements intelligent context routing with specialized rules for different development scenarios.
β
Smart Classification: Automatically detects request intent (bugfix, feature, cleanup, etc.)
β
Context-Aware Routing: Routes to specialized rules based on file patterns and user intent
β
SOLID Principles Enforcement: Built-in architectural constraints and validation
β
Evidence-Based Decisions: No assumptions, everything backed by measurable criteria
β
Self-Healing Redirects: Intelligent fallbacks when rules conflict
β
Production Ready: Used in real projects with proven results
.cursor/rules/
βββ main-router.mdc # π― Smart classification & routing hub
βββ cleanup-rules.mdc # π§½ Technical debt reduction
βββ feature-rules.mdc # β¨ New functionality (SOLID-compliant)
βββ bugfix-rules.mdc # π οΈ Minimal error correction
βββ exploration-rules.mdc # π§ͺ POC development & validation
βββ migration-rules.mdc # π Technology migration strategies
βββ optimization-rules.mdc # β‘ Performance improvements
βββ compliance-rules.mdc # π Legal & security requirements
flowchart TD
A[π₯ User Request] --> B[π― Main Router]
B --> C{π§© Intent Classification}
C -->|High Confidence >80%| D[Direct Routing]
C -->|Medium 50-80%| E[Confirm with User]
C -->|Low <50%| F[Ask Clarification]
E --> G[User Confirmation]
F --> H[Targeted Questions]
G --> D
H --> D
D --> I{π Specialized Rules}
I -->|Priority 1| J1[π οΈ Bugfix Rules]
I -->|Priority 2| J2[π Compliance Rules]
I -->|Priority 3| J3[π§ͺ Exploration Rules]
I -->|Priority 4| J4[β‘ Optimization Rules]
I -->|Priority 5| J5[π Migration Rules]
I -->|Priority 6| J6[π§½ Cleanup Rules]
I -->|Default| J7[β¨ Feature Rules]
J1 --> K[π Smart Validation]
J2 --> K
J3 --> K
J4 --> K
J5 --> K
J6 --> K
J7 --> K
K --> L{π¨ Rule Violation?}
L -->|Yes| M[Intelligent Redirect]
L -->|No| N[Execute Specialized Workflow]
M --> I
N --> O[β
Success with Evidence]
# Clone this repository
git clone https://github.com/fxbravo/Cursor_Rules.git
# Navigate to your project
cd your-project/
# Copy the rules structure
cp -r Cursor_Rules/.cursor .
# Verify installation
ls -la .cursor/rules/- Open your project in Cursor IDE
- Go to Settings β General β Project Rules
- Confirm all rules appear with correct status:
- β
main-router.mdc- Always Applied - π Other rules - Auto Attached/Agent Requested
- β
# Try a test request in Cursor
"I want to add a login feature to my app"
# Expected response:
π― **CATΓGORIE:** FEATURE - New functionality request - Confiance: 95%
Routing to @feature-rules.mdc for SOLID-compliant implementation...
- π οΈ BUGFIX - Critical: Malfunction or existing error
- π COMPLIANCE - Legal/audit/security requirements
- π§ͺ EXPLORATION - POC development and technical validation
- β‘ OPTIMIZATION - Performance improvements with evidence
- π MIGRATION - Technology changes and upgrades
- π§½ CLEANUP - Technical debt reduction
- β¨ FEATURE - New functionality (default fallback)
- Multiple matches: Choose highest priority + confirm
- No clear match: Offer 3 specific options
- Context needed: Ask targeted questions
- Mission: Reduce technical debt without breaking functionality
- Constraints: Never create files, user approval for deletions
- Success Metrics: Unused imports removed, duplications merged, tests passing
- Mission: Add functionality while preserving architecture
- Constraints: Extend before create, maintain SOLID principles
- Success Metrics: Working feature, maximum reuse, zero duplication
- Mission: Fix errors with minimal changes
- Constraints: Max 5 lines changed, no improvements, regression prevention
- Success Metrics: Bug fixed, no regression, minimal code impact
- Mission: Validate technical approaches quickly
- Constraints: Mark TEMP, mandatory cleanup, validation criteria
- Success Metrics: Question answered, decision made, cleanup completed
- Mission: Change technology without breaking production
- Constraints: Risk-based approach, rollback ready, phased execution
- Success Metrics: Migration complete, performance maintained, old code removed
- Mission: Improve performance with evidence
- Constraints: Profiler required, 20% minimum improvement, measure before/after
- Success Metrics: Proven gains, functionality intact, evidence documented
- Mission: Meet legal/security requirements minimally
- Constraints: Document requirements, minimal implementation
- Success Metrics: Compliance achieved, minimal impact, audit-ready
- Debt Prevention: Clear problem statement, modify > create
- Quality Gates: File β€800 lines, class β€300, function β€50
- Operations: Run lint/test/build after changes
- Types: No explicit
anyin production code
- Strict Mode: Production code, zero tolerance
- Flexible Mode: Exploration/prototypes, justified exceptions
- Context Adaptation: Adjusts based on urgency and category
Instead of hard stops, provides intelligent guidance:
β Old: "Error: Cannot create files during cleanup"
β
New: "I detected you need to CREATE [specific thing]. This requires
@feature-rules.mdc. Should I switch and help you implement
[specific thing] properly?"
CategoryDetection: {
category: "bugfix|feature|cleanup|exploration|migration|optimization|compliance",
justification: "string β€100 chars",
confidence: "percentage",
keywords_found: ["array"]
}ActionPlan: {
actions: ["specific steps"],
file_impact: "decrease|same|increase_justified|increase_temporary",
risk_level: "low|medium|high",
success_metrics: ["measurable outcomes"]
}The system includes specialized workshops for non-technical stakeholders:
- Feature Feasibility POC: Validate new functionality with technical constraints
- User Journey Validation: Test user workflows with real data
- Data-Driven Decisions: Analyze business metrics with technical context
- Integration Feasibility: Assess system compatibility and performance
# Add to any .mdc file for project-specific context
---
description: "Your custom rule description"
globs: ["your/**/*.{extensions}"]
alwaysApply: false
---
# Your Custom Rule
@your-template-file.ts # Reference project templates- Rules are scoped by file patterns (globs) for efficient context loading
- Only relevant rules activate based on current file and intent
- Main router uses
alwaysApply: true, specialized rules usefalse
- Check file structure: Must be
.cursor/rules/*.mdc - Verify YAML frontmatter: Required
description,globs,alwaysApply - Restart Cursor: Sometimes required after adding new rules
- Check Settings: Settings β General β Project Rules
- Check confidence system: Low confidence requires user clarification
- Verify glob patterns: Ensure patterns match your file types
- Test classification: Ask "What category is this request?"
- Check context window: Overly complex rules may be pruned
# Issue: Rules appear but aren't followed
# Solution: Check if using deprecated .cursorrules format
# Issue: Router not classifying correctly
# Solution: Verify main-router.mdc has alwaysApply: true
# Issue: Specialized rules not triggered
# Solution: Check glob patterns match your project structure- 40% faster initial code generation
- 60% fewer manual corrections needed
- 80% better consistency across team members
- 90% reduction in architectural violations
- Automatic SOLID principles enforcement
- Built-in technical debt prevention
- Evidence-based optimization decisions
- Zero-hallucination POC development
- Create new
.mdcfile in.cursor/rules/ - Add appropriate metadata (description, globs, alwaysApply)
- Reference from main-router.mdc if needed
- Test in your project before submitting PR
- Maintain backward compatibility
- Update success metrics appropriately
- Document changes in commit messages
- Include test scenarios
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by BMAD methodology for modular prompt engineering
- Built on Cursor's MDC rule system
- Community feedback from real-world usage
- SOLID principles and clean architecture concepts
Ready to transform your AI-assisted development workflow?
β Star this repo if it helped you
π Report issues
π‘ Request features
π€ Contribute improvements