Indexing Performance
Initial indexing can take 15+ minutes for very large projects
Working with large codebases (100K+ lines of code) in Cursor requires specific strategies to maintain performance and productivity. This guide covers proven techniques from teams managing millions of lines of code.
Indexing Performance
Initial indexing can take 15+ minutes for very large projects
Context Window Limits
Even with 200K tokens, you can’t fit everything
Memory Usage
Large projects can consume 8GB+ RAM during heavy operations
Search Accuracy
Finding relevant code becomes harder as codebases grow
Configure Cursor to index only what matters:
# .cursorignore - Exclude from indexing
# Build artifactsdist/build/out/.next/target/
# Dependenciesnode_modules/vendor/packages/*/node_modules/
# Generated files*.generated.ts*.pb.goschema.graphql
# Large data files*.csv*.json > 1MBfixtures/
# Documentationdocs/api/*.pdf
# Test snapshots__snapshots__/*.snap
{ "cursor.indexing.enabled": true, "cursor.indexing.exclude": [ "**/node_modules/**", "**/dist/**", "**/*.min.js", "**/coverage/**" ], "cursor.indexing.include": [ "src/**", "lib/**", "packages/*/src/**" ], "cursor.indexing.incrementalUpdate": true, "cursor.indexing.updateInterval": "5m"}
For monorepos or multi-service architectures:
// workspace.code-workspace{ "folders": [ { "name": "Frontend", "path": "./packages/frontend" }, { "name": "Backend API", "path": "./packages/api" }, { "name": "Shared Libraries", "path": "./packages/shared" }, { "name": "Infrastructure", "path": "./infrastructure" } ], "settings": { "cursor.workspacePriority": { "Frontend": 1, "Backend API": 2, "Shared Libraries": 3, "Infrastructure": 4 } }}
Strategies for working within token limits:
// Level 1: Immediate context (current file + direct dependencies)"@current @imports Update this authentication logic"
// Level 2: Module context (related files in same module)"@folder:src/auth Refactor the entire auth module"
// Level 3: Subsystem context (broader architectural view)"@folder:src/auth @folder:src/users @docs:architecture.mdImplement SSO across auth and user systems"
// Level 4: Full system (use sparingly)"Analyze the entire codebase for security vulnerabilities"
Start Narrow Begin with the most specific context possible
Expand Gradually Add context only when the AI needs more information
Use Semantic Boundaries Include whole modules rather than random files
Leverage Ask Mode First Use Ask mode to understand before including context
Clean Up After Tasks Start fresh chats for new tasks to avoid context pollution
// Cursor performance settings{ "cursor.performance.memoryLimit": "8GB", "cursor.performance.maxWorkers": 4, "cursor.performance.cacheSize": "2GB", "cursor.performance.enableLazyLoading": true, "cursor.performance.garbageCollection": "aggressive"}
Task Type | Recommended Model | Why |
---|---|---|
Quick edits | Claude 4 Sonnet | Fast, efficient for small changes |
Large refactoring | Claude 4 Sonnet | Good balance of capability and speed |
Complex analysis | Gemini 2.5 Pro | Handles massive context windows |
Architecture planning | Claude 4 Opus | Best reasoning for complex decisions |
Bug hunting | o3 | Deep reasoning for tricky issues |
// Semantic search for concepts"Where is user authentication implemented?"
// Combined with regex for precision"@search('function.*Auth') Show all auth functions"
// Scoped searches for performance"@folder:src/payments Find payment processing logic"
// Historical search for context"@git What changes were made to auth in the last month?"
Create and maintain high-level documentation:
# System Architecture Map
## Core Services- **Auth Service** - `/src/auth` - Handles all authentication- **User Service** - `/src/users` - User management and profiles- **Payment Service** - `/src/payments` - Stripe integration- **Analytics Service** - `/src/analytics` - Event tracking
## Key Patterns- All services use dependency injection- Authentication via JWT tokens- Database access through repositories- Events published via message queue
A fintech company successfully manages their massive Java monolith:
banking-system/├── core/ (500K LOC)├── modules/ (800K LOC)│ ├── accounts/│ ├── transactions/│ ├── compliance/│ └── reporting/├── integrations/ (400K LOC)├── shared/ (200K LOC)└── tests/ (300K LOC)
{ "workspaces": [ // Only open modules being worked on {"path": "./core", "active": false}, {"path": "./modules/accounts", "active": true}, {"path": "./shared", "active": true} ], "rules": [ "Focus on module boundaries", "Use interface contracts", "Minimize cross-module deps" ]}
Managing a distributed system with Cursor:
// Custom workspace manager scriptclass WorkspaceManager { async switchContext(feature: string) { const requiredServices = await this.getFeatureDependencies(feature);
// Close unneeded workspaces await this.closeWorkspaces( this.openWorkspaces.filter(w => !requiredServices.includes(w)) );
// Open required services await this.openWorkspaces(requiredServices);
// Prime Cursor context await this.primeContext(feature); }
async primeContext(feature: string) { // Create a context document const context = ` Working on: ${feature} Services involved: ${this.openWorkspaces.join(', ')} Key files: ${await this.getKeyFiles(feature)} Recent changes: ${await this.getRecentChanges(feature)} `;
// Save to .cursor/context.md await fs.writeFile('.cursor/context.md', context); }}
Strategies used by contributors:
Component Focus
Work on one component at a time (e.g., just the scheduler)
Interface Contracts
Understand interfaces before implementations
Test-Driven Exploration
Use tests to understand behavior
Documentation Integration
Keep design docs in Cursor context
// Don't load everything at onceclass LazyContextLoader { private loaded = new Set<string>();
async getContext(query: string) { const relevant = await this.findRelevantModules(query);
for (const module of relevant) { if (!this.loaded.has(module)) { await this.loadModule(module); this.loaded.add(module); } }
return this.buildContext(relevant); }}
Divide your codebase into logical partitions:
partitions: frontend: paths: [src/ui, src/components, src/styles] rules: frontend-rules.md
backend: paths: [src/api, src/services, src/db] rules: backend-rules.md
infrastructure: paths: [deploy, terraform, k8s] rules: infra-rules.md
shared: paths: [src/shared, src/utils] rules: shared-rules.md
# Use partitions in prompts:# "@partition:frontend Update the user dashboard"
Build understanding incrementally:
Map the Territory
"Create a high-level map of this codebase's architecture"
Identify Entry Points
"What are the main entry points for this application?"
Trace Key Flows
"Trace the user login flow from start to finish"
Understand Patterns
"What patterns are used consistently across this codebase?"
Document Findings
"Create an architecture guide based on our exploration"
// Monitor Cursor performanceinterface PerformanceMetrics { indexingTime: number; // Initial indexing searchLatency: number; // Average search time tokenUsage: number; // Tokens per task memoryUsage: number; // RAM consumption responseTime: number; // AI response latency}
// Log and analyzeclass PerformanceMonitor { logMetric(metric: keyof PerformanceMetrics, value: number) { console.log(`[Cursor Perf] ${metric}: ${value}`);
// Alert on degradation if (this.isDegraded(metric, value)) { this.alert(`Performance degradation in ${metric}`); } }}
Slow Indexing
Solution: Check .cursorignore, reduce indexed paths, restart Cursor
Out of Memory
Solution: Increase memory limit, close unused workspaces, use exclusions
Inaccurate Suggestions
Solution: Improve context selection, update documentation, use specific modes
Token Limit Exceeded
Solution: Break into smaller tasks, use targeted context, leverage Ask mode
Master these large codebase techniques:
Remember: The goal isn’t to load everything into Cursor, but to load the right things at the right time. Master this, and even million-line codebases become manageable.