Skip to content

Agent & Chat Optimization: Tips 61-75

Agent and Chat represent Cursor’s most powerful capabilities for complex development tasks. These 15 tips will transform you from a user into an AI development orchestrator, handling everything from multi-file refactoring to autonomous feature implementation.

Tip 61: Choose the Right Mode for Your Task

Section titled “Tip 61: Choose the Right Mode for Your Task”

Know when to use Agent vs Ask mode:

Agent Mode

For Implementation:

  • Multi-file changes
  • Creating new features
  • Refactoring across files
  • Running tests & fixing errors

Ask Mode

For Exploration:

  • Understanding code
  • Asking questions
  • Planning approaches
  • Getting suggestions

Quick mode switching:

Terminal window
Ctrl+I # Opens chat (defaults to last mode)
Ctrl+. # Quick mode switcher
@mode:agent # Switch to Agent in chat
@mode:ask # Switch to Ask in chat

Tip 62: Master the Test-Driven Agent Workflow

Section titled “Tip 62: Master the Test-Driven Agent Workflow”

Leverage Agent’s YOLO mode for automated test-driven development:

  1. Enable YOLO Mode in settings
  2. Start with test prompt: “Create comprehensive tests for a user authentication service”
  3. Let Agent write tests first
  4. Follow with: “Now implement the code to make all tests pass”
  5. Agent iterates until tests succeed

Example prompt sequence:

// First prompt:
"Create unit tests for a Redis cache service with get, set, delete,
and TTL functionality. Include edge cases."
// Agent creates test file with comprehensive tests
// Second prompt:
"Implement the RedisCacheService to pass all tests"
// Agent implements, runs tests, fixes issues automatically

Agent automatically gathers context, but you can guide it:

// Explicit context references
"Update the UserService to match the pattern used in OrderService,
referencing @OrderService for the structure"
// Directory-scoped context
"Refactor all controllers in @src/controllers to use the new
error handling middleware"
// Cross-file relationships
"Update all files that import @utils/logger to use the new
logging format"

Tip 64: Orchestrate Complex Multi-File Operations

Section titled “Tip 64: Orchestrate Complex Multi-File Operations”

Break down large changes into Agent-friendly chunks:

// Prompt 1: Analysis
"Analyze the current authentication flow across all files
and create a plan to migrate from JWT to session-based auth"
// Prompt 2: Implementation
"Implement the session-based auth following the plan,
updating all affected endpoints and middleware"
// Prompt 3: Testing
"Update all auth-related tests to work with sessions
instead of JWT tokens"

Tip 65: Use Agent for Intelligent Refactoring

Section titled “Tip 65: Use Agent for Intelligent Refactoring”

Agent excels at consistent refactoring across codebases:

// Example: Extract common patterns
"Identify all API endpoints that don't have proper error handling
and wrap them with our standard try-catch error middleware"
// Example: Update imports project-wide
"Change all imports from 'lodash' to use specific imports like
'lodash/get' for better tree-shaking"
// Example: Standardize patterns
"Find all React components using class syntax and convert them
to functional components with hooks"

Tip 66: Leverage Agent’s Search and Replace Intelligence

Section titled “Tip 66: Leverage Agent’s Search and Replace Intelligence”

Agent’s search isn’t just text matching—it understands code:

// Semantic search and replace
"Find all functions that make database queries without using
transactions and wrap them in proper transaction blocks"
// Pattern-based updates
"Locate all console.log statements in production code (not tests)
and replace with appropriate logger calls based on context"

Tip 67: Manage Multiple Chat Tabs Effectively

Section titled “Tip 67: Manage Multiple Chat Tabs Effectively”

Use tabs for parallel workflows:

Tab 1: Feature Dev

Main feature implementation

Tab 2: Bug Fixes

Debugging and fixes

Tab 3: Documentation

Docs and comments

Tab 4: Research

Ask mode exploration

Shortcuts:

Terminal window
Ctrl+T # New chat tab
Ctrl+W # Close current tab
Ctrl+Tab # Cycle through tabs
Ctrl+[1-9] # Jump to specific tab

Tip 68: Use Checkpoints for Safe Experimentation

Section titled “Tip 68: Use Checkpoints for Safe Experimentation”

Create restore points during complex changes:

  1. Before major refactoring: “Create checkpoint: pre-auth-refactor”
  2. Make experimental changes with Agent
  3. If successful: Continue development
  4. If problematic: “Restore from checkpoint: pre-auth-refactor”

Checkpoint commands in chat:

Terminal window
/checkpoint create <name> # Create named checkpoint
/checkpoint list # Show all checkpoints
/checkpoint restore <name> # Restore to checkpoint
/checkpoint delete <name> # Remove checkpoint

Leverage chat history for complex workflows:

// Reference previous conversations
"Continue from our previous discussion about caching strategy"
// Export important conversations
Ctrl+Shift+P"Export conversation to markdown"
// Search through history
"@past-chats authentication implementation"

Pro Tip Star important messages for quick reference later

Manage context efficiently in long conversations:

// Clear irrelevant context
"/clear context except @src/services"
// Add specific context
"@src/models/User.ts @src/controllers/AuthController.ts
Let's work on user authentication"
// Use context groups
"@folder:src/api for all API-related context"

Context management strategies:

  • Start new chats for unrelated tasks
  • Use /reset context to clear accumulated context
  • Be explicit about needed files
  • Close unnecessary file references

Create powerful context combinations:

// Combine different context types
"@web React hooks best practices
@docs our coding standards
@src/hooks analyze our custom hooks and suggest improvements"
// Layer historical context
"@git recent changes to auth
@pr #234 implementation
Update the current code to handle the edge cases from the PR"
// Mix exploration and implementation
"@codebase getUserPermissions
@docs RBAC documentation
Implement role inheritance in our permission system"

Use Agent for complete feature development:

// Single prompt for complete endpoint
"Create a complete CRUD API for a Task model with:
- TypeScript interfaces
- Express routes with validation
- Service layer with business logic
- Repository pattern for database
- Comprehensive error handling
- Full test coverage
- OpenAPI documentation"
// Agent creates all files and runs tests

Use Agent’s analytical capabilities:

// Debugging workflow
"I'm getting intermittent 500 errors in production.
Analyze the logs in @logs/error.log, check the related
code paths, and add defensive programming to prevent crashes"
// Performance investigation
"The /api/users endpoint is slow. Profile the code path,
identify bottlenecks, and implement optimizations including
database query optimization and caching"
// Memory leak hunting
"Our Node.js app memory usage grows over time. Analyze
the code for potential memory leaks, focusing on event
listeners, closures, and global variables"

Create reusable Agent workflows:

// Create a macro-like prompt
"For each model in @src/models:
1. Add TypeScript interfaces if missing
2. Create a repository class with standard CRUD
3. Add validation schemas
4. Generate basic unit tests
5. Update the index exports"
// Batch updates
"Find all API endpoints and ensure they have:
- Input validation using Joi/Zod
- Proper TypeScript types
- Error handling middleware
- Rate limiting
- API documentation comments"

Combine Agent with external resources:

// Use web search for latest practices
"@web latest Next.js 14 app router best practices
Refactor our routing structure to follow these patterns"
// Reference documentation
"@web Stripe API documentation for subscriptions
Implement a complete subscription system with webhooks"
// Apply framework updates
"@web React 18 migration guide
Update our codebase to React 18, handling all breaking changes"

Be Specific

Include exact requirements, constraints, and expected outcomes

Provide Context

Reference relevant files, patterns, and coding standards

Break Down Tasks

Divide complex features into manageable chunks

Verify Results

Always review and test Agent’s changes

  1. Over-broad prompts: “Fix all the bugs” → Be specific
  2. Missing context: Always include relevant files
  3. Skipping tests: Let Agent write and run tests
  4. Ignoring suggestions: Agent might propose better approaches
  5. Not using checkpoints: Save state before major changes
  • Scope changes: Use @folder to limit search scope
  • Clear context: Start fresh chats for new features
  • Sequential prompts: Break large tasks into steps
  • Explicit files: Reference specific files when possible
// Check token usage
Ctrl+Shift+J → Usage tab
// Optimize prompts
- Remove redundant context
- Use precise file references
- Clear chat history when done
- Disable Max mode when not needed

You’ve mastered orchestrating complex development with Agent and Chat. Continue to Large Codebase Strategies to learn how to apply these techniques to enterprise-scale projects.