Skip to content

Context Management & Development

Context management is the secret to getting great results from Cursor. This 15-minute guide will teach you to wield @ symbols like a pro, manage large codebases efficiently, and develop features with surgical precision.

Token Limits

Standard: 128k tokens (~10,000 lines) Max Mode: Up to 1M tokens (~80,000 lines)

Smart Selection

More context isn’t always better - focused, relevant context produces superior results

Cost Impact

Every token costs money - efficient context management saves significant budget

Performance

Smaller, focused context = faster responses and better accuracy

SymbolPurposeBest Used For
@FilesReference specific filesImplementation details, bug fixes
@FoldersInclude entire directoriesFeature development, refactoring
@CodeSemantic code searchFinding implementations, understanding flow
@DocsAccess documentationLearning libraries, checking APIs
@WebSearch online resourcesLatest updates, solutions
@DefinitionsFind symbol definitionsUnderstanding code structure
@GitVersion control contextHistory, changes, blame
@Recent-changesLatest modificationsContinuing work, debugging
@Linter-errorsCurrent errorsFixing issues, improving quality
# Single file
@auth.service.ts
# Multiple files
@auth.service.ts @auth.controller.ts @auth.module.ts
# With path
@src/services/auth.service.ts

When to Use @Folders

Use for feature-wide changes, understanding module structure, or refactoring entire components.

  1. Feature Development:

    "Implement user authentication using @src/auth/"
  2. Module Understanding:

    "Explain how the payment system works @src/payments/"
  3. Refactoring:

    "Refactor to use dependency injection @src/services/"

The most powerful @ symbol for understanding codebases:

# Find where a function is implemented
@Code "validateUser implementation"
# Locate usage patterns
@Code "where is Redis cache used"
# Understand data flow
@Code "how user data flows through the system"

Indexed Docs

Access your project’s documentation instantly

External Docs

Combined with MCP servers like Context7 for library docs

Usage patterns:

# Project documentation
@Docs "API authentication"
# With Context7 MCP
"How do I use Stripe webhooks? @Docs with context7"
# Architecture decisions
@Docs "database schema design"
# Recent changes
@Git "changes in last week"
# Feature history
@Git "commits related to authentication"
# Bug introduction
@Git "when was this bug introduced"
  1. Start Broad:

    "Explain the current user system @src/users/"
  2. Zoom In:

    "Focus on user creation @user.service.ts @user.dto.ts"
  3. Related Context:

    "Show similar patterns @Code 'entity creation'"
  4. Implementation:

    "Implement user preferences with @user.model.ts @preferences.dto.ts"

Debugging Context Stack

Layer context from specific to general for effective debugging.

# Layer 1: Error location
@src/api/users/users.controller.ts
@Linter-errors
# Layer 2: Related files
@src/api/users/users.service.ts
@src/api/users/dto/
# Layer 3: Recent changes
@Recent-changes
@Git "recent changes to users module"
# Layer 4: System understanding
@Code "user data flow"

Use Ask mode with broad context:

"Analyze the impact of changing our ORM
@src/models/ @src/repositories/ @Code 'database queries'"

Build context incrementally for complex tasks:

# Base layer
@auth.service.ts
# Add tests
@auth.service.ts @auth.service.spec.ts
# Add dependencies
@auth.service.ts @auth.service.spec.ts @jwt.service.ts
# Add configuration
@auth.service.ts @auth.service.spec.ts @jwt.service.ts @config/auth.config.ts

Create reusable context patterns:

# Feature Context Template
@src/features/[feature]/
@src/features/[feature]/dto/
@src/features/[feature]/tests/
@Code "[feature] implementation"
@Docs "[feature] requirements"

Context Switching

Use keyboard shortcuts to quickly adjust context without breaking flow.

ActionShortcutWhen to Use
Add file@ then filenameNeed specific file
Remove from contextClick ✕ on pillToo much context
Clear all context/Reset ContextStarting fresh
Add open files/Add Open FilesWorking across multiple files
  1. Enable Smart Indexing:

    • Settings → Indexing & Docs
    • Enable “Include Project Structure”
    • Set appropriate ignore patterns
  2. Optimize .gitignore:

    # Cursor-specific ignores
    node_modules/
    dist/
    build/
    *.log
    .env*
    coverage/
  3. Use .cursorignore:

    # Additional Cursor-only ignores
    test-data/
    migrations/data/
    docs/legacy/

Chunk Large Tasks

Break down into smaller, focused operations

Progressive Context

Start minimal, add context as needed

Clear Regularly

Reset context between major tasks

Use Specific Paths

Full paths are faster than fuzzy search

❌ BAD: @src/ "Fix the authentication bug"
✅ GOOD: @src/auth/auth.service.ts @logs/auth-error.log
"Fix the JWT expiration bug on line 47"
Step 1: Understand existing patterns
@Code "POST endpoint implementations" @src/api/
Step 2: Focus on specific module
@src/api/products/ @src/api/products/dto/
Step 3: Implementation with examples
"Create POST /api/products/review endpoint"
@src/api/products/products.controller.ts
@src/api/products/products.service.ts
@src/api/products/dto/create-review.dto.ts
Step 4: Testing
@src/api/products/products.controller.spec.ts
"Add tests for the review endpoint"
Step 1: Identify slow areas
@Code "database queries" @logs/performance.log
Step 2: Focus on bottleneck
@src/services/report.service.ts
@Code "functions calling generateReport"
Step 3: Optimization
@src/services/report.service.ts @src/db/queries/
"Optimize the report generation using batch queries"
  1. Tokens per task - Aim for < 50k tokens
  2. Context switches - Fewer is better
  3. AI accuracy - Should improve with better context
  4. Time to solution - Faster with optimal context

Continue to First Feature

Now let’s put all your skills together and build your first AI-assisted feature.

First Feature →

Time: 15 minutes