Feature Implementation
Building new features that touch multiple files and require understanding existing patterns
Each of Cursor’s modes represents a different AI personality, optimized for specific types of tasks. Understanding when and how to use each mode is the difference between fighting the tool and flowing with it.
Mode | Best For | Capabilities | Tools Available |
---|---|---|---|
Agent | Complex features, refactoring | Autonomous exploration, multi-file edits | All tools enabled |
Ask | Learning, planning, questions | Read-only exploration, no automatic changes | Search tools only |
Manual | Precise, targeted edits | Direct file editing with explicit control | Edit tools only |
Custom | Specialized workflows | User-defined capabilities | Configurable |
Agent mode is Cursor’s most powerful feature. It’s like having a senior developer who can explore your codebase, understand complex requirements, and implement solutions across multiple files.
Feature Implementation
Building new features that touch multiple files and require understanding existing patterns
Large Refactoring
Renaming across the codebase, changing interfaces, updating dependency patterns
Bug Fixing with Investigation
When you need to find and fix issues that span multiple components
Test Generation
Creating comprehensive test suites that understand your code’s behavior
Instead of jumping straight into implementation, use Agent’s planning capabilities:
"First, analyze the authentication system and create a detailed plan for adding OAuth 2.0 support.Write the plan to plan.md, then wait for my approval before implementing."
This approach:
With Cursor v1.2+, you can queue multiple agent tasks:
Task 1: "Analyze the current payment processing flow"Task 2: "Add Stripe integration alongside existing PayPal"Task 3: "Update all payment-related tests"Task 4: "Add monitoring and error handling"
The agent will execute these sequentially, maintaining context between tasks.
Before giving Agent a complex task, prime it with context:
"Look at our existing API patterns in /src/api, especially how we handle authentication and error responses.Now, create a new user management API following these same patterns."
Enable these settings for optimal Agent performance:
{ "cursor.agent.yoloMode": true, "cursor.agent.yoloPrompt": "Run tests after changes. Create directories as needed. Use TypeScript.", "cursor.agent.yoloAllowList": ["npm test", "mkdir", "tsc"], "cursor.agent.yoloDenyList": ["rm -rf", "git push"]}
{ "cursor.performance.memoryLimit": "8GB", "cursor.performance.cacheSize": "2GB", "cursor.agent.maxContextTokens": 200000}
Here’s how a senior developer used Agent mode to extract a service from a monolith:
Context Gathering
"Analyze the order processing logic in our monolith.Identify all dependencies, database tables, and API endpoints related to orders."
Planning
"Create a detailed plan for extracting order processing into a microservice.Include: API design, data migration strategy, and rollback plan."
Implementation
"Following the approved plan, create the new order-service with:- RESTful API matching our standards- Database migrations- Docker configuration- Integration tests"
Integration
"Update the monolith to use the new order-service API.Implement feature flags for gradual rollout."
Background Agents revolutionize development by allowing you to spawn cloud-based AI agents that work autonomously on separate tasks while you continue coding. Think of them as AI developers working in parallel on different branches of your project.
Parallel Feature Development
Work on multiple features simultaneously - one agent per feature branch
Time-Consuming Tasks
Delegate refactoring, test generation, or documentation while you focus on core logic
Bug Fix Automation
Assign agents to investigate and fix bugs from issue trackers
Code Review Preparation
Have agents prepare PRs with proper formatting, tests, and documentation
Background Agents require a .cursor/environment.json
file to configure the cloud environment:
{ "snapshot": "POPULATED_FROM_SETTINGS", "install": "npm install", "start": "sudo service docker start", "terminals": [ { "name": "Dev Server", "command": "npm run dev" }, { "name": "Test Watcher", "command": "npm run test:watch" } ]}
For complex dependencies, use a Dockerfile:
# .cursor/DockerfileFROM ubuntu:22.04
# Install system dependenciesRUN apt-get update && apt-get install -y \ build-essential \ python3-pip \ nodejs \ npm \ docker.io
# Set up Python environmentRUN pip3 install pytest black flake8
# Custom tools your project needsRUN npm install -g typescript eslint prettier
WORKDIR /workspace
Cmd+Shift+P
(Mac) or Ctrl+Shift+P
(Windows/Linux)Access background agents from any device:
@Cursor implement the user dashboard feature from issue #234- Use our existing design system- Add proper error handling- Include unit tests- Create a PR when done
The agent will:
// Launch 3 agents simultaneously for different features
// Agent 1: Payment Integration"Implement Stripe payment integration:- Add payment processing to /api/payments- Create checkout flow components- Add webhook handlers for payment events- Include comprehensive error handling- Write integration tests"
// Agent 2: Email Notifications"Add email notification system:- Set up email templates- Create notification service- Add user preference settings- Implement queue for bulk emails- Test with different email providers"
// Agent 3: Analytics Dashboard"Build analytics dashboard:- Create dashboard layout- Implement data visualization components- Add export functionality- Cache expensive queries- Make it responsive"
Cost: ~$4-6 per agent for moderate complexity tasks
// Assign agent to fix a reported bug"Investigate and fix issue #456:1. Reproduce the bug using the steps provided2. Identify root cause in the codebase3. Implement a fix following our patterns4. Add regression tests5. Update relevant documentation6. Create PR with detailed explanation"
Typical completion time: 10-30 minutes depending on complexity
// Refactor legacy code to modern patterns"Refactor the legacy authentication system:- Analyze current implementation in /src/auth- Migrate from callbacks to async/await- Update to use JWT tokens- Maintain backward compatibility- Update all dependent services- Ensure all tests still pass- Document breaking changes if any"
{ "snapshot": "node-18-typescript", "install": "npm ci --prefer-offline", "start": "npm run build:watch", "terminals": [ { "name": "TypeScript Compiler", "command": "tsc --watch --preserveWatchOutput" } ], "cache": { "node_modules": true, "build": true }, "resources": { "cpu": 4, "memory": "8GB" }}
{ "snapshot": "secure-base", "secrets": [ "DATABASE_URL", "API_KEY", "JWT_SECRET" ], "install": "npm audit fix && npm ci", "security": { "disableNetworkAccess": false, "allowedDomains": [ "api.mycompany.com", "github.com" ] }}
{ "snapshot": "pnpm-monorepo", "install": "pnpm install --frozen-lockfile", "workspaces": [ "packages/*", "apps/*" ], "terminals": [ { "name": "Frontend Dev", "command": "pnpm --filter frontend dev" }, { "name": "Backend Dev", "command": "pnpm --filter backend dev" } ]}
Background Agents use MAX mode models exclusively, which can accumulate costs:
Task Complexity | Typical Cost | Duration | Best For |
---|---|---|---|
Simple (bug fix, small feature) | $2-4 | 5-10 min | Quick iterations |
Medium (feature implementation) | $4-8 | 10-30 min | Standard development |
Complex (refactoring, architecture) | $8-15 | 30-60 min | Major changes |
Coordinating Multiple Agents via Slack:
# Launch multiple agents for a complex feature@Cursor [branch=feature/api] implement backend API- Design RESTful endpoints- Add authentication- Implement data validation- Write API tests
@Cursor [branch=feature/ui] build frontend interface- Create responsive components- Add state management- Connect to API- Implement error handling
@Cursor [branch=feature/tests] create integration tests- Test API endpoints- Test UI components- Add E2E scenarios- Check performance
After agents complete, integrate the branches:
@Cursor merge feature branches and create final PR- Combine api, ui, and tests branches- Resolve any conflicts- Run full test suite- Create PR with comprehensive description
Automated Issue Processing with GitHub Actions:
name: Auto Process Issues
on: issues: types: [labeled]
jobs: process: if: github.event.label.name == 'auto-fix' runs-on: ubuntu-latest steps: - name: Trigger Cursor Agent via Slack uses: slackapi/slack-github-action@v1.24.0 with: channel-id: 'cursor-automation' slack-message: | @Cursor fix issue ${{ github.event.issue.html_url }} - Analyze the issue - Implement solution - Add tests - Create PR linked to issue
Create reusable templates for common tasks:
{ "name": "Bug Fix Template", "steps": [ "Reproduce the bug using provided steps", "Add failing test that demonstrates the bug", "Implement minimal fix to make test pass", "Check for similar issues in codebase", "Add regression tests", "Update changelog and documentation" ], "validation": [ "All tests pass", "No new linting errors", "Code coverage maintained or improved" ], "pr_template": "bug_fix"}
Monitor all active agents in real-time:
You can seamlessly take over from a background agent:
Feature | Background Agent | Foreground Agent |
---|---|---|
Runs Where | Cloud (Ubuntu VM) | Your local machine |
Command Approval | Auto-runs all (YOLO mode) | Requires approval |
Parallel Work | Yes, multiple agents | No, single instance |
Access Method | IDE, Web, Slack | IDE only |
Cost | Usage-based pricing | Included in subscription |
Internet Access | Yes | Depends on your setup |
Git Integration | Auto-creates PRs | Manual git operations |
Best For | Delegated tasks | Interactive development |
Security Best Practices:
Common issues and solutions:
Issue | Solution |
---|---|
Agent fails to start | Check environment.json syntax and ensure all dependencies are specified |
Slow performance | Optimize install command, use caching, reduce terminal processes |
Git push failures | Verify repository permissions and SSH keys are configured |
High costs | Break tasks into smaller chunks, set spending limits, use specific instructions |
Environment errors | Use Dockerfile for complex dependencies, test locally first |
Ask mode is read-only but incredibly powerful for understanding and planning. It’s your codebase encyclopedia that never makes unwanted changes.
Don’t just ask one question. Approach from multiple angles:
"How does the authentication system work from these perspectives:1. User flow (from login to authenticated request)2. Security measures (token handling, session management)3. Database structure4. API endpoints involved5. Error handling and edge cases"
Use Ask mode to identify patterns and anti-patterns:
"Analyze our React components and identify:- Common patterns we use for state management- Inconsistencies in component structure- Opportunities for creating shared abstractions"
Before making changes, use Ask to understand impact:
"If I change the User interface to add a 'role' field,what parts of the codebase would be affected?List all files, functions, and tests that would need updates."
Ask mode becomes even more powerful with MCP servers:
// With context7 MCP enabled"How do I implement infinite scrolling in Next.js 14?Use context7 to get the latest documentation."
// With GitHub MCP"What changes were made to authentication in the last 10 PRs?Check both merged PRs and comments for context."
Manual mode is for when you know exactly what needs to change and want full control.
Be Specific with File Selection
@file
references for clarityProvide Clear Instructions
"In the login function starting at line 45:1. Add input validation for email format2. Add rate limiting check before authentication3. Update the error response to match our API standards"
Use for Teaching Manual mode is excellent for onboarding:
"Update the calculatePrice function to include tax.Follow our existing pattern in calculateShipping."
Custom modes let you create specialized AI personalities for your team’s unique needs.
{ "name": "Security Audit", "tools": ["codebase_search", "read_file", "terminal"], "instructions": "Focus on finding security vulnerabilities. Check for: SQL injection, XSS, hardcoded secrets, missing authentication. Create security_report.md with findings and fixes.", "model": "claude-4.1-opus"}
{ "name": "Documentation", "tools": ["codebase_search", "read_file", "edit_file"], "instructions": "Generate comprehensive documentation. Include: purpose, parameters, return values, examples, edge cases. Follow JSDoc standards.", "model": "claude-4-sonnet"}
{ "name": "Performance", "tools": ["all_search", "terminal", "read_file"], "instructions": "Identify performance bottlenecks. Look for: N+1 queries, unnecessary loops, missing indexes, large payloads. Suggest optimizations with benchmarks.", "model": "o3"}
A team created a custom mode for database migrations:
// Custom Migration Mode Configuration{ "name": "DB Migration", "tools": ["read_file", "edit_file", "terminal"], "instructions": ` When creating migrations: 1. Always create up and down migrations 2. Test rollback before marking complete 3. Update schema documentation 4. Create migration guide for other devs `}
For consistent API design across teams:
{ "name": "API Designer", "tools": ["codebase_search", "edit_file"], "instructions": ` Follow REST principles and our API standards: - Consistent naming (kebab-case) - Proper HTTP status codes - Pagination for lists - Standard error format - OpenAPI documentation `}
Start with Ask Mode
Switch to Agent Mode
Finish with Manual Mode
When switching modes, preserve context:
// In Ask Mode"Analyze the payment processing flow and identify where we calculate taxes"
// Switch to Agent Mode"Based on the tax calculation you just found, update it to handle international taxes"
// Switch to Manual Mode"In the tax configuration file, add specific rates for EU countries"
Mode | Memory Usage | Token Consumption | Best Model Choice |
---|---|---|---|
Agent | High (explores many files) | Very High | Claude 4 Sonnet (balance) |
Ask | Medium (searches codebase) | Medium | Gemini 2.5 Pro (long context) |
Manual | Low (specific files) | Low | Any fast model |
Custom | Varies by configuration | Varies | Task-specific |
The 80/20 Rule
“80% of the time, I’m in Ask mode learning. 20% in Agent mode implementing. This ratio gives me the best results.” - Senior Dev at TechCorp
Mode Macros
Create keyboard shortcuts for common mode switches. Map Ctrl+Shift+A
for Agent, Ctrl+Shift+Q
for Ask (Q = Question).
Custom Mode Library
Build a library of custom modes for your team. Share them via Git for consistency across developers.
Problem: Agent mode is powerful but can over-engineer simple changes. Solution: Use Manual mode for straightforward edits. Save Agent for complex, multi-file work.
Problem: Developers try to understand code by reading it manually. Solution: Ask mode with good questions is 10x faster. Practice asking comprehensive questions.
Problem: Teams don’t invest in creating custom workflows. Solution: Start with one custom mode for your most common task. Expand gradually.
Now that you understand the nuances of each mode:
Remember: Modes are tools. The best developers know when to use each one. Master this, and you’ll work at a completely different level of efficiency.