Skip to content

Working with Large Codebases

Strategies for using Cursor effectively with enterprise-scale repositories.


Overview

Large codebases present unique challenges:

  • Indexing takes longer
  • Context windows fill quickly
  • Finding relevant code is harder
  • Performance can suffer

This guide covers techniques to work efficiently at scale.


Indexing Strategy

Configure .cursorignore

Exclude non-essential directories:

gitignore
# Dependencies
node_modules/
vendor/
.venv/
packages/*/node_modules/

# Build outputs
dist/
build/
out/
target/
*.bundle.js

# Generated files
generated/
.next/
coverage/

# Large assets
*.zip
*.tar.gz
*.mp4
media/

Use .cursorindexingignore

Keep files accessible but not indexed:

gitignore
# Don't index but allow access
docs/
examples/
scripts/

Monitor Indexing Status

  1. Open Cursor Settings
  2. Go to Features > Codebase Indexing
  3. Check indexing progress
  4. Reindex if needed

Context Management

Be Selective with @ Mentions

Instead of @Codebase, use specific references:

# Good - specific
@src/auth/AuthService.ts how does login work?

# Less efficient - broad
@Codebase how does authentication work?

Use Folder References

Reference directories for scoped context:

@src/components/ What button variants do we have?

Leverage @Recent Changes

Focus on active work:

@Recent Changes summarize what's been changed today

Project Organization

Create Focused Rules

Split rules by domain:

.cursor/rules/
  auth/RULE.md           # Authentication patterns
  database/RULE.md       # Database conventions
  api/RULE.md           # API design patterns
  frontend/RULE.md      # UI component rules

Use Rule Globs

Apply rules to specific file types:

markdown
---
description: Database access patterns
globs: ["**/repositories/**", "**/models/**"]
---

- Use the Repository pattern
- Never raw SQL in controllers
- Always use transactions for writes

Performance Optimization

Split Large Files

Break up files over 500 lines:

  • Extract components
  • Separate utilities
  • Use module pattern

Use Workspaces

For monorepos, open specific packages:

bash
# Instead of opening root
cursor packages/web-app

# Or use workspace file
cursor workspace.code-workspace

Close Unused Tabs

Each open file consumes memory:

  • Close files not actively editing
  • Use Cmd+W to close
  • Use Cmd+K Cmd+W to close all

Search Strategies

For conceptual questions:

@Codebase how do we handle rate limiting?

For specific code:

Find all usages of AuthService.login()

Combine Approaches

@Codebase @src/auth/ explain the authentication flow
and show where tokens are validated

Monorepo Tips

Package-Specific Rules

Create rules per package:

packages/
  web/
    .cursor/rules/RULE.md    # Web-specific
  api/
    .cursor/rules/RULE.md    # API-specific
  shared/
    .cursor/rules/RULE.md    # Shared lib rules

Cross-Package References

Reference related packages:

Using patterns from @packages/shared, create a new
utility in @packages/api

Dependency Awareness

Include package.json for context:

@package.json @packages/web/package.json
What versions of React are we using?

Team Collaboration

Share Ignore Patterns

Commit .cursorignore to version control:

bash
git add .cursorignore
git commit -m "Add Cursor ignore patterns"

Standardize Rules

Use Team Rules for organization-wide patterns:

  • Dashboard > Team Content > Rules
  • Enforce critical standards
  • Make optional ones opt-in

Document Conventions

Create an AGENTS.md in root:

markdown
# Project Guidelines

## Code Style
- TypeScript for all new code
- Functional components in React

## Architecture
- Follow repository pattern
- Services in /services directory

Debugging at Scale

Narrow the Scope

Debug the payment processing error in
@src/payments/ - focus on webhook handling

Use Git Context

@Git what changed in the auth module recently?

Reference Logs

Here's the error log:
[paste log]

Find the source in @src/

For Large Projects

SettingRecommendation
IndexingEnable, use ignore files
ModelClaude Sonnet for balance
ContextUse specific @ mentions
RulesSplit by domain

Codebase Indexing Settings

  1. Cursor Settings > Features > Codebase Indexing
  2. Enable smart indexing
  3. Set appropriate file limits
  4. Monitor memory usage

Common Issues

ProblemSolution
Slow indexingAdd more to .cursorignore
Context too largeUse specific @ mentions
Memory issuesClose tabs, restart Cursor
Stale resultsReindex codebase
Wrong suggestionsAdd domain-specific rules

See Also

Built with VitePress | Powered by Claude AI