Large Codebase Strategies: Tips 76-90
Your project hit 200,000 lines of code. Cursor’s indexing takes 20 minutes, agent responses reference files from two years ago, and Tab suggestions pull patterns from deprecated modules. The tool that made you faster on small projects is now slowing you down on the project that matters. These 15 tips solve the scaling problem.
What You Will Walk Away With
Section titled “What You Will Walk Away With”- An indexing strategy that keeps Cursor fast on codebases over 500k lines
- Context budget management that prevents the agent from drowning in irrelevant files
- Multi-root workspace configurations for monorepos and multi-repo setups
- Scoped search and navigation techniques that find the right code in seconds, not minutes
- Architectural analysis prompts that help you understand unfamiliar areas of a large codebase
Indexing Strategy
Section titled “Indexing Strategy”Tip 76: Configure Exclusions Before Opening a Large Project
Section titled “Tip 76: Configure Exclusions Before Opening a Large Project”The first time you open a large project, Cursor indexes everything. If your node_modules has 100,000 files, that is 100,000 files consuming memory and CPU before you write a single line of code. Configure exclusions first:
Create or update .cursorignore in your project root (works like .gitignore):
# Build artifactsdist/build/.next/out/coverage/
# Dependenciesnode_modules/vendor/.pnp/
# Generated code*.generated.ts*.generated.jsprisma/generated/graphql/generated/
# Large binary files*.wasm*.map*.min.js*.min.css*.bundle.js
# Lock files (huge, rarely useful for AI)package-lock.jsonpnpm-lock.yamlyarn.lockTip 77: Open Specific Packages Instead of the Monorepo Root
Section titled “Tip 77: Open Specific Packages Instead of the Monorepo Root”In a monorepo with 20 packages, opening the root directory forces Cursor to index everything. Instead, open only the packages you are actively working on:
# Instead of:cursor ~/projects/big-monorepo
# Open specific packages as a multi-root workspace:cursor ~/projects/big-monorepo/packages/web \ ~/projects/big-monorepo/packages/api \ ~/projects/big-monorepo/packages/sharedOr create a workspace file for common combinations:
// web-api.code-workspace{ "folders": [ { "path": "packages/web", "name": "Web App" }, { "path": "packages/api", "name": "API Server" }, { "path": "packages/shared", "name": "Shared Types" }, { "path": "packages/config", "name": "Config" } ]}Tip 78: Monitor and Manage Indexing Health
Section titled “Tip 78: Monitor and Manage Indexing Health”Check indexing status regularly in Settings > Indexing and Docs. Healthy benchmarks:
| Codebase Size | Expected Index Time | Index Size |
|---|---|---|
| Under 10k files | 1-3 minutes | Under 500 MB |
| 10k-50k files | 3-10 minutes | 500 MB - 2 GB |
| 50k-200k files | 10-30 minutes | 2-5 GB |
| Over 200k files | Use exclusions aggressively | Target under 5 GB |
If indexing exceeds these times, your exclusions need work. The most common culprits: node_modules not excluded, large generated files, or binary assets in the source tree.
Context Budget Management
Section titled “Context Budget Management”Tip 79: Think in Context Budgets
Section titled “Tip 79: Think in Context Budgets”Every agent conversation has a finite context window. In a large codebase, you will hit this limit quickly if you reference too many files. Think of context as a budget:
- Budget: ~200k tokens per conversation (varies by model and mode)
- Cost per file: A typical 200-line TypeScript file costs ~1,000-2,000 tokens
- Cost per directory: Referencing
@src/on a 500-file project costs your entire budget
The discipline: reference the minimum number of files needed for the task. Start narrow and expand only if the agent says it needs more context.
Tip 80: Use Summary Files for Large Modules
Section titled “Tip 80: Use Summary Files for Large Modules”For modules too large to reference directly, create a summary file that the agent can reference instead:
# Payments Module Architecture
## Key Files- `service.ts` - Core payment processing (Stripe integration)- `webhook.ts` - Webhook handlers for payment events- `types.ts` - TypeScript interfaces for payment entities- `repository.ts` - Database operations (PostgreSQL via Drizzle)
## Data Flow1. Client calls POST /api/payments/checkout2. service.ts creates Stripe session3. Stripe sends webhook to webhook.ts4. webhook.ts updates payment status via repository.ts5. WebSocket notifies client of status change
## Key Constraints- All amounts in cents (integer, never float)- Idempotency keys required for all Stripe calls- Webhook verification must happen before processingNow instead of @src/payments/ (which might consume 50k tokens), reference @src/payments/ARCHITECTURE.md (2k tokens) and only pull in specific files as needed.
Tip 81: Use Scoped Agent Conversations
Section titled “Tip 81: Use Scoped Agent Conversations”For large codebases, scope every agent conversation to a specific area:
The explicit scope prevents the agent from wandering into unrelated modules and consuming your context budget on irrelevant code.
Navigation at Scale
Section titled “Navigation at Scale”Tip 82: Combine Semantic Search with Grep for Precision
Section titled “Tip 82: Combine Semantic Search with Grep for Precision”In a large codebase, neither semantic search nor text search alone is sufficient:
- Semantic search finds conceptually related code but may return results from deprecated modules
- Text search (grep) finds exact matches but misses code that does the same thing with different names
The combined workflow:
Find all code that handles subscription renewal. Use semantic searchto identify the relevant modules, then grep for specific function callsto 'renewSubscription', 'processRenewal', and 'handleRenewalWebhook'.Show me results only from the active codebase -- ignore anything insrc/legacy/ or src/deprecated/.Tip 83: Use @codebase Search for Cross-Module Understanding
Section titled “Tip 83: Use @codebase Search for Cross-Module Understanding”When you need to understand how a concept spans multiple modules:
This prompt triggers Cursor’s semantic understanding of the entire indexed codebase. It is slower than scoped searches but gives you the full picture when you need to understand cross-cutting concerns.
Tip 84: Build Mental Maps of Unfamiliar Code
Section titled “Tip 84: Build Mental Maps of Unfamiliar Code”When onboarding to a large codebase, use the agent to build a structured understanding:
- “What are the top-level directories and what is each one responsible for?”
- “Show me the main entry points — where do HTTP requests arrive, and where do scheduled jobs start?”
- “What are the core domain models and how do they relate to each other?”
- “What external services does this application depend on? (databases, APIs, message queues)”
- “Where are the most complex parts of the codebase? Which files have the most dependencies?”
Each question builds on the previous answers, giving you a structured mental map within 30 minutes.
Monorepo-Specific Techniques
Section titled “Monorepo-Specific Techniques”Tip 85: Use Workspace-Specific Rules for Monorepos
Section titled “Tip 85: Use Workspace-Specific Rules for Monorepos”In a monorepo, different packages often have different conventions. Create package-specific rules:
packages/web/.cursor/rules/web.md # React conventionspackages/api/.cursor/rules/api.md # Express conventionspackages/shared/.cursor/rules/shared.md # Pure TypeScript rulespackages/mobile/.cursor/rules/mobile.md # React Native conventionsWhen the agent edits files in packages/web/, it picks up the React-specific rules. When it edits packages/api/, it gets the Express-specific rules. This prevents the agent from applying React patterns to your API code or vice versa.
Tip 86: Handle Cross-Package Dependencies Explicitly
Section titled “Tip 86: Handle Cross-Package Dependencies Explicitly”When a change in one package requires updates in another, be explicit about the dependency chain:
Tip 87: Use Targeted Refactoring Across Packages
Section titled “Tip 87: Use Targeted Refactoring Across Packages”When refactoring a shared type or interface, the blast radius can span the entire monorepo. Control it:
Rename the "UserRole" type to "AccountRole" in @packages/shared/src/types.ts.Then find and update every import and usage across all packages. Runpnpm run typecheck at the monorepo root after the rename to verifythere are no broken references.With YOLO mode enabled, the agent does the rename, runs TypeScript, sees any remaining broken references, and fixes them iteratively.
Performance Optimization
Section titled “Performance Optimization”Tip 88: Close Files You Are Not Actively Editing
Section titled “Tip 88: Close Files You Are Not Actively Editing”Cursor uses open files as high-priority context. In a large codebase, you can easily accumulate 30+ open tabs, most of which are irrelevant to your current task. This degrades:
- Tab prediction quality (too much noisy context)
- Agent response time (more files to consider)
- Memory usage (Cursor holds open files in memory)
Close tabs aggressively. Use Cmd+P to jump to files when you need them instead of keeping them permanently open.
Tip 89: Use Max Mode Selectively for Large File Analysis
Section titled “Tip 89: Use Max Mode Selectively for Large File Analysis”Max Mode gives extended context windows at higher cost. In a large codebase, it is tempting to keep it always on. Do not. Enable Max Mode only for:
- Analyzing individual files over 3,000 lines
- Understanding complex dependency chains that span 10+ files
- Planning architectural changes that require holding the entire module structure in context
For everything else — implementing features, fixing bugs, writing tests — standard mode is sufficient and significantly cheaper.
Tip 90: Create a “Quick Context” Cheat Sheet for Your Project
Section titled “Tip 90: Create a “Quick Context” Cheat Sheet for Your Project”For codebases you work on daily, create a quick-reference file that gives the agent instant context:
Reference this file at the start of complex agent conversations to give instant, token-efficient context.
When This Breaks
Section titled “When This Breaks”Indexing is stuck at a percentage and not progressing: Usually a single large file is blocking the indexer. Check for generated files (GraphQL codegen, Prisma client, compiled assets) that slipped past your exclusions. Add them to .cursorignore and restart the index.
Agent gives answers about the wrong part of the codebase: In a monorepo, the agent sometimes confuses similarly named files across packages. Be explicit about which package: “@packages/api/src/users.ts — not the one in packages/web.”
Tab suggestions are slow on large projects: Reduce the number of open tabs, close irrelevant files, and verify your exclusions are working. Tab’s speed is directly proportional to how much context it needs to process.
Agent response quality drops mid-conversation: Context saturation. Start a new conversation. In large codebases, agent conversations should be shorter and more focused than on small projects. Aim for 5-10 exchanges maximum before starting fresh.
What is Next
Section titled “What is Next”You can now handle codebases at any scale. Move to Advanced Techniques (Tips 91-105) for MCP server integration, background agents, custom automations, and the expert-level features that push Cursor to its limits.