How to Add Cursor Rules
Method 1: Using Cursor IDE Interface (Recommended)
Step 1: Access Cursor Settings
# Open Cursor IDE and navigate to:
# Settings (gear icon in top-right) → Rules
# OR use keyboard shortcut: Cmd+Shift+J (Mac) or Ctrl+Shift+J (Windows)
Step 2: Create Project Rules
Click "Add Rule" under Project Rules section
Choose Rule Type:
Always: Always included in AI context (recommended for core rules)
Auto Attached: Applied when specific files are referenced
Agent Requested: AI decides when to use based on description
Manual: Only when explicitly mentioned with @rulename
Enter your StressLess rules (use the complete rules from the document)
Method 2: Manual File Creation (Advanced)
Step 1: Create Project Structure
# Navigate to your StressLess project root
cd /path/to/StressLess-Android
# Create Cursor rules directory
mkdir -p .cursor/rules
# Verify structure
ls -la .cursor/
Step 2: Create Main Rules File
# Create the main rules file
touch .cursor/rules/stressless-core.mdc
Step 3: Add the Complete Rules
.cursor/rules/stressless-core.mdc
---
description: "Core StressLess Android MVP development rules for TDD, privacy, and performance"
alwaysApply: true
---
# Complete Cursor Rules for StressLess Android MVP
## 1. Project Setup & Privacy
### 1.1 Privacy Mode Configuration
MANDATORY: Enable Privacy Mode before opening StressLess project
Settings → Privacy Mode → Enable
Verify "Don't send code to AI" is checked
Never expose encryption keys, model weights, or user voice data in prompts
### 1.2 Secure Development Practices
// ❌ NEVER: Expose sensitive data in prompts // "Fix this encryption using key: StressLessSecureKey2025"
// ✅ ALWAYS: Use placeholders and abstractions // "Optimize encryption implementation with proper key management"
# [Continue with the complete rules from the document]
Method 3: Modular Rules Setup (Recommended for Large Projects)
Create Separate Rule Files by Domain
# Create domain-specific rules
touch .cursor/rules/tdd-gherkin.mdc
touch .cursor/rules/ml-performance.mdc
touch .cursor/rules/ui-compose.mdc
touch .cursor/rules/privacy-security.mdc
touch .cursor/rules/testing.mdc
.cursor/rules/tdd-gherkin.mdc
---
description: "TDD and Gherkin testing rules for StressLess"
globs: ["**/test/**", "**/androidTest/**", "**/features/**"]
alwaysApply: false
---
# TDD & Gherkin Integration Rules
## Test-First Development
For every feature request, follow this sequence:
"Create Gherkin scenarios for [feature] in features/[feature_name].feature"
"Generate step definitions for the scenarios"
"Implement failing tests based on step definitions"
"Write minimal code to make tests pass"
"Refactor while maintaining test coverage"
# [Include relevant TDD sections from the complete rules]
.cursor/rules/ml-performance.mdc
---
description: "ML inference and performance optimization rules"
globs: ["**/ml/**", "**/ECAPAStressEngine.kt", "**/AudioPipeline.kt"]
alwaysApply: false
---
# ML/AI Specific Rules
## Performance Targets
// All AI-generated code must meet these targets: // - Voice analysis: <3 seconds end-to-end // - Memory usage: <200MB peak
// - Battery impact: <2% per analysis // - NPU acceleration when available
# [Include ML sections from complete rules]
Method 4: Auto-Generation from Package Dependencies
# Install the cursor-rules CLI
pip install cursor-rules
# Navigate to your StressLess project
cd /path/to/StressLess-Android
# Auto-generate rules based on your dependencies
cursor-rules
# This will scan your build.gradle.kts and create relevant .mdc files
# in .cursor/rules/ directory automatically
Method 5: Legacy .cursorrules File (Not Recommended)
For Backwards Compatibility Only
# Create legacy file (only if needed for older Cursor versions)
touch .cursorrules
# Add rules directly to this file
# Note: This method is deprecated and will be removed
Verification Steps
Step 1: Verify Rules Are Active
# In Cursor IDE, open any Kotlin file
# Type a comment: // Test Cursor rules
# Press Ctrl+K (Cmd+K on Mac) and ask: "Generate a simple function following project rules"
# Verify the AI response follows your StressLess conventions
Step 2: Check Rules in Chat
# Open Cursor Chat panel
# Type: "What are the current project rules for this StressLess project?"
# Verify it lists your configured rules
Step 3: Test with TDD Prompt
# In chat, try: "Create a Gherkin scenario for voice recording with error handling"
# Verify it follows your TDD methodology and includes proper Given/When/Then structure
Directory Structure After Setup
StressLess-Android/
├── .cursor/
│ └── rules/
│ ├── stressless-core.mdc # Core rules (always applied)
│ ├── tdd-gherkin.mdc # TDD rules (auto-attached to tests)
│ ├── ml-performance.mdc # ML rules (auto-attached to ML files)
│ ├── ui-compose.mdc # UI rules (auto-attached to composables)
│ ├── privacy-security.mdc # Security rules
│ └── testing.mdc # Testing patterns
├── app/
├── features/ # Gherkin feature files
├── build.gradle.kts
└── settings.gradle.kts
Rule Management Tips
1. Version Control
# Add rules to git
git add .cursor/
git commit -m "Add Cursor rules for StressLess MVP development"
# Share with team
git push origin main
2. Rule Testing
# Test rules with specific prompts
# "@tdd-gherkin create a scenario for model loading"
# "@ml-performance optimize this inference method"
3. Rule Updates
# Rules are automatically reloaded when files change
# No need to restart Cursor IDE
# Use /Generate Cursor Rules command after successful AI interactions
4. Rule Debugging
# If rules aren't working:
1. Check file syntax (YAML frontmatter must be valid)
2. Verify file extension is .mdc
3. Check globs patterns match your files
4. Ensure alwaysApply is set correctly
5. Restart Cursor IDE if needed
07 September 2025