Agent Mode
For Implementation:
- Multi-file changes
- Creating new features
- Refactoring across files
- Running tests & fixing errors
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.
Know when to use Agent vs Ask mode:
Agent Mode
For Implementation:
Ask Mode
For Exploration:
Quick mode switching:
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
Leverage Agent’s YOLO mode for automated test-driven development:
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 newerror handling middleware"
// Cross-file relationships"Update all files that import @utils/logger to use the newlogging format"
Break down large changes into Agent-friendly chunks:
// Prompt 1: Analysis"Analyze the current authentication flow across all filesand 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 sessionsinstead of JWT tokens"
// Prompt 1: Schema"Create a migration to add soft delete functionalityto all existing models"
// Prompt 2: Model Updates"Update all Sequelize/Prisma models to includedeletedAt timestamps and scopes"
// Prompt 3: API Updates"Modify all DELETE endpoints to perform soft deletesand add restore endpoints"
Agent excels at consistent refactoring across codebases:
// Example: Extract common patterns"Identify all API endpoints that don't have proper error handlingand 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 themto functional components with hooks"
Agent’s search isn’t just text matching—it understands code:
// Semantic search and replace"Find all functions that make database queries without usingtransactions 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"
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:
Ctrl+T # New chat tabCtrl+W # Close current tabCtrl+Tab # Cycle through tabsCtrl+[1-9] # Jump to specific tab
Create restore points during complex changes:
Checkpoint commands in chat:
/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 conversationsCtrl+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.tsLet's work on user authentication"
// Use context groups"@folder:src/api for all API-related context"
Context management strategies:
/reset context
to clear accumulated contextCreate 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 implementationUpdate the current code to handle the edge cases from the PR"
// Mix exploration and implementation"@codebase getUserPermissions@docs RBAC documentationImplement 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
// Complete frontend feature"Build a task management dashboard with:- React component with TypeScript- Custom hooks for data fetching- Proper error boundaries- Loading and error states- Unit tests with React Testing Library- Storybook stories- Responsive design with Tailwind"
Use Agent’s analytical capabilities:
// Debugging workflow"I'm getting intermittent 500 errors in production.Analyze the logs in @logs/error.log, check the relatedcode 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 includingdatabase query optimization and caching"
// Memory leak hunting"Our Node.js app memory usage grows over time. Analyzethe code for potential memory leaks, focusing on eventlisteners, closures, and global variables"
Create reusable Agent workflows:
// Create a macro-like prompt"For each model in @src/models:1. Add TypeScript interfaces if missing2. Create a repository class with standard CRUD3. Add validation schemas4. Generate basic unit tests5. 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 practicesRefactor our routing structure to follow these patterns"
// Reference documentation"@web Stripe API documentation for subscriptionsImplement a complete subscription system with webhooks"
// Apply framework updates"@web React 18 migration guideUpdate 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
// Check token usageCtrl+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.