Przejdź do głównej zawartości

Large Codebase Strategies: Tips 76-90

Ta treść nie jest jeszcze dostępna w Twoim języku.

Working with codebases containing hundreds of thousands or millions of lines requires specialized strategies. These 15 tips will help you maintain productivity and accuracy when dealing with enterprise-scale projects.

Tip 76: Enable Advanced Project Structure Indexing

Section titled “Tip 76: Enable Advanced Project Structure Indexing”

Configure Cursor for optimal large codebase understanding:

{
"cursor.indexing.strategy": "smart",
"cursor.indexing.includeProjectStructure": true,
"cursor.indexing.priorityPatterns": [
"**/src/core/**",
"**/src/api/**",
"**/src/services/**"
],
"cursor.indexing.merkleTree": {
"enabled": true,
"updateInterval": "3m",
"maxDepth": 10
}
}

Master the @codebase symbol for intelligent searches:

// Find by functionality, not text
"@codebase how is user authentication implemented"
"@codebase payment processing flow"
"@codebase error handling patterns"

Use chat to build mental models:

// Architecture overview
"Create a high-level architecture diagram of our system based on
@src analyzing the main components and their interactions"
// Dependency graph
"Map out the dependency relationships between our core services
in @src/services"
// Data flow analysis
"Trace the data flow for a user registration request through
our entire system"

Optimize indexing with intelligent exclusions:

{
"cursor.indexing.exclude": {
"patterns": [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/.next/**",
"**/coverage/**",
"**/*.min.js",
"**/*.bundle.js"
],
"sizeThreshold": "10MB",
"generatedFilePatterns": [
"**/*.generated.ts",
"**/schema.graphql",
"**/migrations/*.sql"
]
}
}

Guide AI focus with priority configurations:

{
"cursor.codebase.priorityFiles": [
{
"pattern": "**/index.{ts,js}",
"weight": 1.5,
"reason": "Entry points"
},
{
"pattern": "**/routes/**",
"weight": 1.3,
"reason": "API definitions"
},
{
"pattern": "**/*.service.{ts,js}",
"weight": 1.4,
"reason": "Business logic"
}
]
}

Tip 81: Use Incremental Indexing Strategies

Section titled “Tip 81: Use Incremental Indexing Strategies”

Maintain performance with smart indexing:

  1. Initial index: Full scan on project open
  2. File watch: Real-time updates on changes
  3. Periodic refresh: Background re-indexing every 5 minutes
  4. Manual trigger: Force re-index when needed

Commands for index management:

Terminal window
Ctrl+Shift+P "Cursor: Rebuild Index"
Ctrl+Shift+P "Cursor: Clear Index Cache"
Ctrl+Shift+P "Cursor: Show Indexing Status"

Tip 82: Master Cross-Repository Navigation

Section titled “Tip 82: Master Cross-Repository Navigation”

Work efficiently across multiple related repositories:

Multi-Root Setup

Terminal window
workspace/
├── frontend/
├── backend/
├── shared/
└── infrastructure/

Shared Context

Reference across repos:

@frontend/src/api/client.ts
@backend/src/routes/user.ts

Navigate complex dependency chains:

// Trace usage
"Show me all the places where UserRepository.findById is called,
including indirect usage through other services"
// Impact analysis
"If I change the signature of AuthService.validateToken,
what files would be affected?"
// Circular dependency detection
"Check for circular dependencies in @src/services"

Set up efficient navigation patterns:

{
"cursor.navigation.bookmarks": [
{
"name": "API Routes",
"pattern": "**/routes/**/*.ts"
},
{
"name": "Database Models",
"pattern": "**/models/**/*.ts"
},
{
"name": "Test Files",
"pattern": "**/*.{test,spec}.{ts,js}"
}
]
}

Tip 85: Combine Multiple Search Strategies

Section titled “Tip 85: Combine Multiple Search Strategies”

Layer different search approaches for comprehensive results:

// 1. Semantic search for concept
"@codebase authentication middleware"
// 2. Grep for specific patterns
"Search for: req.user across all routes"
// 3. Symbol search
"@definitions AuthMiddleware"

Tip 86: Use Scoped Searches for Performance

Section titled “Tip 86: Use Scoped Searches for Performance”

Limit search scope intelligently:

// Scope by directory
"@folder:src/api search for rate limiting"
// Scope by file type
"In all TypeScript files: find async functions without try-catch"
// Scope by recent changes
"@recent-changes review error handling in modified files"
// Combine scopes
"@folder:src/services @git:last-week find new database queries"

Use Agent for codebase-wide quality checks:

// Security scan
"Scan the codebase for potential security vulnerabilities:
- SQL injection risks
- XSS vulnerabilities
- Exposed secrets or API keys
- Missing authentication checks"
// Performance audit
"Identify performance bottlenecks:
- N+1 query problems
- Missing database indexes references
- Synchronous operations that should be async
- Large bundle imports"
// Technical debt assessment
"Find areas of technical debt:
- TODO/FIXME comments
- Deprecated API usage
- Code duplication
- Complex functions (cyclomatic complexity > 10)"

Tip 88: Maintain Architectural Consistency

Section titled “Tip 88: Maintain Architectural Consistency”

Use AI to enforce architectural patterns:

Layer Validation

Ensure proper separation:

"Verify that controllers only call services,
never repositories directly"

Pattern Enforcement

Check implementation patterns:

"Ensure all services follow our
standard error handling pattern"

Dependency Rules

Validate dependencies:

"Check that domain layer doesn't
depend on infrastructure layer"

Tip 89: Generate Architecture Documentation

Section titled “Tip 89: Generate Architecture Documentation”

Keep documentation synchronized with code:

// Component documentation
"Generate a README for @src/services explaining:
- Purpose of each service
- Key methods and their usage
- Dependencies and interactions
- Configuration requirements"
// API documentation
"Create OpenAPI documentation for all routes in @src/api
based on the actual implementation"
// Dependency visualization
"Create a Mermaid diagram showing the relationships
between all major components in our system"

Example output:

graph TD A[API Gateway] --> B[Auth Service] A --> C[User Service] C --> D[Database] B --> E[Redis Cache] C --> E

Refactor large codebases systematically:

  1. Identify boundaries: “Analyze @src/monolith and suggest module boundaries”
  2. Create interfaces: “Define interfaces between proposed modules”
  3. Extract incrementally: “Extract UserModule maintaining all tests passing”
  4. Verify isolation: “Ensure UserModule has no circular dependencies”
  5. Update imports: “Update all imports to use the new module structure”

Configure Cursor for large projects:

{
"cursor.performance.largeFiles": {
"threshold": "1MB",
"strategy": "stream",
"maxInMemory": 50
},
"cursor.performance.maxOpenTabs": 20,
"cursor.performance.gcInterval": "5m"
}

Important Large codebases can quickly exceed context limits

Strategies:

  1. Focused context: Reference specific files, not entire folders
  2. Progressive disclosure: Start broad, then narrow
  3. Clear regularly: Reset context between unrelated tasks
  4. Use summaries: Create compressed documentation files

Setup shared index:

Terminal window
# Generate shareable index
cursor index --export ./shared-index
# Import on team member's machine
cursor index --import ./shared-index

Solutions:

  • Pre-configure exclusions before opening
  • Use priority patterns for critical paths
  • Enable incremental indexing
  • Share team indexes

Solutions:

  • Work with file subsets
  • Create summary documents
  • Use scoped searches
  • Break tasks into smaller chunks

Solutions:

  • Combine semantic and grep search
  • Maintain good documentation
  • Use consistent naming conventions
  • Create codebase maps

With large codebase strategies mastered, explore Advanced Techniques to leverage expert-level features like custom MCP servers, advanced rules, and automation workflows.