Cursor Rules System - Complete Guide¶
The Cursor Rules System is the heart of AI Velocity's intelligent development experience. It transforms Cursor from a simple AI assistant into a knowledgeable development partner that understands your entire project structure, patterns, and workflows.
What Are Cursor Rules?¶
Cursor Rules are intelligent guidelines stored in .cursor/rules/ that teach your AI about:
- Your project architecture and tech stack
- Code patterns and conventions
- Development workflows and best practices
- Template-driven code generation
Think of them as AI memory that persists across all your development sessions.
Rule Types Overview¶
1. Always-Applied Rules¶
| Text Only | |
|---|---|
When Active: Always
Contains: Architecture overview, tech stack, routing patterns
2. Auto-Attached Rules¶
| Text Only | |
|---|---|
When Active: Automatically when working in matching files
Contains: File-specific patterns, conventions, best practices
3. Manual/Requestable Rules¶
| Text Only | |
|---|---|
When Active: Explicitly requested with
@ruleNameContains: Step-by-step processes, command sequences
4. Template System¶
| Text Only | |
|---|---|
When Active: Referenced by other rules or requested directly
Contains: Complete code templates with proper patterns
How Each Rule Type Works¶
Always-Applied Rules in Action¶
File: .cursor/rules/project-overview.mdc
Impact: AI always knows your tech stack and can make contextual suggestions.
Auto-Attached Rules in Action¶
When you open a React component file:
Automatically activates: frontend/frontend-patterns.mdc
- AI knows to use TypeScript interfaces
- Suggests MUI components and styling patterns
- Follows StandardButton system
- Includes proper error handling patterns
When you open a Python service file:
Automatically activates: backend/backend-patterns.mdc
- AI knows to use dependency injection
- Suggests proper service layer patterns
- Includes error handling and logging
- Follows FastAPI conventions
Manual Rules in Action¶
Usage: Type @api-workflow in Cursor
AI Response:
Template System in Action¶
Usage: Ask AI to create a new service using templates
AI generates:
Practical Usage Examples¶
Example 1: Creating a New Feature¶
You: "Create a new Article feature with CRUD operations"
AI (using multiple rules):
- project-overview.mdc: Understands this is FastAPI + React + SQLModel
- @api-workflow: Follows complete development process
- @templates/service-template.py: Generates service with proper patterns
- @templates/component-template.tsx: Creates React components
- backend-patterns.mdc: Ensures proper dependency injection
- frontend-patterns.mdc: Uses StandardButton and MUI patterns
Result: Complete feature with consistent patterns across entire stack.
Example 2: Database Migration¶
You: @database-migration I need to add a new field to User model
AI Response:
Example 3: Deployment Guidance¶
You: @deployment I want to deploy to Railway
AI provides: Complete Railway deployment guide with:
- Step-by-step commands
- Environment variable setup
- Database configuration
- Troubleshooting tips
Rule File Structure¶
Standard Rule Format¶
| YAML | |
|---|---|
Auto-Attached Rule Example¶
Success Indicators¶
β
AI suggests code following your patterns
β
Manual rules respond when requested
β
Templates are used in generated code
β
Context-specific rules activate correctly
Best Practices¶
Rule Organization¶
- Keep rules focused: One concern per rule file
- Use clear descriptions: Help AI understand purpose
- Reference templates: Link to reusable code patterns
- Update regularly: Keep rules current with code changes
Template Design¶
- Include complete examples: Full working code
- Add extensive comments: Explain patterns and decisions
- Cover edge cases: Error handling, validation, logging
- Use TypeScript interfaces: Ensure type safety
Testing Rules¶
- Test after changes: Verify rules work as expected
- Use multiple scenarios: Different file types and contexts
- Check rule interactions: Ensure rules work together
- Document discoveries: Note what works best
Customizing Rules¶
Adding New Rules¶
1. Create Rule File
2. Add Metadata
| YAML | |
|---|---|
3. Add Content
- Code examples
- Best practices
- Template references
- Usage patterns
Modifying Existing Rules¶
1. Update Rule Content
- Edit existing
.mdcfiles - Add new patterns or examples
- Update best practices
2. Test Changes
- Verify rule activation
- Check AI responses
- Test with real development scenarios
Advanced Usage¶
Rule Combinations¶
Rules work together intelligently:
- Always-applied + Auto-attached = Context-aware assistance
- Manual rules + Templates = Guided code generation
- Multiple auto-attached = Comprehensive pattern coverage
Workflow Integration¶
| Bash | |
|---|---|
Team Adoption¶
- Share rules: Consistent patterns across team
- Document patterns: Rules serve as living documentation
- Update together: Evolve rules with project needs
- Train newcomers: Rules help onboard new developers
Next Steps¶
- Verify AI integration in your boilerplate β
/development/TEST_CURSOR_RULES.md - Master AI-assisted development
- Try the complete feature creation process using Cursor (@api-workflow)
The Cursor Rules system transforms your AI from assistant to partner.
Instead of explaining your project every time, your AI already knows your patterns, conventions, and workflows. This is the future of developmentβintelligent, consistent, and fast. β¨