Token Limits
Standard: 128k tokens (~10,000 lines) Max Mode: Up to 1M tokens (~80,000 lines)
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
Symbol | Purpose | Best Used For |
---|---|---|
@Files | Reference specific files | Implementation details, bug fixes |
@Folders | Include entire directories | Feature development, refactoring |
@Code | Semantic code search | Finding implementations, understanding flow |
@Docs | Access documentation | Learning libraries, checking APIs |
@Web | Search online resources | Latest updates, solutions |
@Definitions | Find symbol definitions | Understanding code structure |
@Git | Version control context | History, changes, blame |
@Recent-changes | Latest modifications | Continuing work, debugging |
@Linter-errors | Current errors | Fixing 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
# Fuzzy matching@auth # Finds auth-related files
# Multiple selectionType @, then hold Shift and click multiple files
# Recent files@<Tab> shows recently opened files
When to Use @Folders
Use for feature-wide changes, understanding module structure, or refactoring entire components.
Feature Development:
"Implement user authentication using @src/auth/"
Module Understanding:
"Explain how the payment system works @src/payments/"
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"
# Design patterns@Code "repository pattern implementations"
# Cross-cutting concerns@Code "error handling strategy"
# Integration points@Code "external API calls"
# Find related code@Code "functions that call sendEmail"
# Trace execution@Code "authentication flow from login to dashboard"
# Locate similar patterns@Code "similar validation logic"
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"
# Who wrote this@Git "who last modified auth.service.ts"
# Understanding decisions@Git "why was caching added here"
# Team patterns@Git "most active contributors to payments module"
# Feature branches@Git "differences between main and feature/oauth"
# Release planning@Git "what's new in release/2.0"
# Conflict resolution@Git "merge conflicts with main branch"
Start Broad:
"Explain the current user system @src/users/"
Zoom In:
"Focus on user creation @user.service.ts @user.dto.ts"
Related Context:
"Show similar patterns @Code 'entity creation'"
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'"
Use Agent mode with focused context:
"Migrate UserRepository to new ORM pattern@src/repositories/user.repository.ts@src/models/user.model.ts@migrations/"
Test-driven context:
"Verify all tests pass after refactoring@src/repositories/user.repository.spec.ts@Linter-errors"
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"
# Debug Context Template@[error-file]@Linter-errors@Recent-changes@Git "recent commits touching [error-file]"@Code "functions calling [error-function]"
# Refactor Context Template@[target-directory]/@Code "[old-pattern] usage"@Code "[new-pattern] examples"@Git "previous refactoring commits"
Context Switching
Use keyboard shortcuts to quickly adjust context without breaking flow.
Action | Shortcut | When to Use |
---|---|---|
Add file | @ then filename | Need specific file |
Remove from context | Click ✕ on pill | Too much context |
Clear all context | /Reset Context | Starting fresh |
Add open files | /Add Open Files | Working across multiple files |
Enable Smart Indexing:
Optimize .gitignore:
# Cursor-specific ignoresnode_modules/dist/build/*.log.env*coverage/
Use .cursorignore:
# Additional Cursor-only ignorestest-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"
❌ BAD: @user.service.ts "Add validation"
✅ GOOD: @user.service.ts @user.dto.ts @validation/"Add validation matching our patterns"
❌ BAD: "Why doesn't this work?"
✅ GOOD: @feature.ts @Git "recent changes""Why doesn't this work after recent changes?"
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"
Continue to First Feature
Now let’s put all your skills together and build your first AI-assisted feature.
Time: 15 minutes