Steve Kinney

Using Cursor Background Agents for Asynchronous Coding

Background agents are asynchronous remote agents in Cursor that operate in a remote environment, allowing you to spawn tasks that edit and run code independently in the background. They function like an AI “multiplier,” enabling developers to offload specific, repetitive, or time-consuming tasks and focus their time and mental cycles on more important roadmap items. Unlike traditional AI tools, Cursor integrates directly with your local project and understands your entire codebase contextually.

How Background Agents Work

Background agents effectively operate in Agent Mode without maximum tool calls, allowing for multiple parallel tasks at once. They run in an isolated, Ubuntu-based machine by default, with internet access and the ability to install packages.

The typical workflow involves:

  • Cloning the Repository: Background agents clone your repository from GitHub.
  • Branch Management: They work on a separate branch to make changes and then push to your repository for easy handoff. This ensures PRs remain small and focused, simplifying code review and reducing merge conflicts.
  • Autonomous Execution: Once instructed, the agent autonomously handles iterations, testing, linting, and formatting without direct supervision. This includes making file changes, running commands, and searching the web for resources.
  • Pull Request Generation: Upon completion, the agent generates a pull request (PR), along with a summary of its work, including changes and features. You can then review and merge these changes into your main codebase. An automated code review can even be performed by another AI agent.
  • Remote Access: You can access and manage these agents from anywhere, including desktop, tablet, or mobile browsers, or as a Progressive Web App (PWA).
  • Parallel Processing: You can create and run multiple background agents in parallel to tackle different tasks or compare results from various models simultaneously. This dramatically parallelizes your work.

Setup and Configuration

To use Cursor’s background agents, you generally need to:

  1. Disable Privacy Mode: In Cursor’s settings, you’ll need to turn off Privacy Mode. While Cursor claims isolated environments and doesn’t train on your code or retain it beyond agent operation when Privacy Mode is enabled, some advanced features like background agents require sending code to remote environments.
  2. Enable Usage-Based Spending: Background agents always use usage-based spending, even if you haven’t exhausted included requests. You’ll need to fund your account with a minimum of $10 or $20.
  3. Connect to GitHub: Grant read-write privileges to your GitHub repository (and any dependent repos or submodules) so the agent can clone and push changes. Cursor supports GitHub connection, with plans for other providers like GitLab and BitBucket.
  4. Configure Environment: Background agents run in a configurable environment. You can specify a Dockerfile for the base environment (e.g., Ruby, Node, Postgres, Redis versions) and a setup.sh script for post-checkout installations and configurations. The environment.json file can specify snapshot settings, install commands (e.g., npm install), and terminal commands to run (e.g., npm run dev).
  5. Select a Model: Only Max Mode-compatible models are available for background agents. Cursor often recommends using a Max model, which can be pricier but provides a larger context window for complex tasks.

Real-World Use Cases and Applications

Background agents are ideal for tasks you don’t want to “babysit”.

  • Codebase Analysis and Documentation: An agent can go through every page of your codebase and add detailed comments at the top of files, explaining what the file does, why it exists, how it works, what other files it references, and opportunities for refactoring or security considerations. This helps in understanding the codebase and provides more context for the AI.
  • Codebase-Wide Chores and Maintenance: Perfect for tedious tasks such as updating documentation, fixing typos, or standardizing comments across a monorepo, as agents leverage full repository context without demanding active developer attention.
  • Bug Fixes and Design Tweaks: Delegate smaller, more predictable bug fixes, simple design adjustments (e.g., button styling, centering text), or accessibility tasks (e.g., adding dark mode support).
  • Automated Testing Workflows: Background agents can autonomously handle tasks that result in merge-ready PRs, including running tests, linting, and formatting. The future roadmap aims for a self-correcting test loop where the AI edits, runs tests, and fixes until green.
  • Feature Development: They can build new features, such as creating a multi-step sign-up form, from scratch.
  • Continuous Integration/Delivery: They can be used for automating support tickets (bug reports, change requests), pulling tickets, attempting fixes, and making pull requests with MCP. There’s a strong community desire for programmatic API access to trigger agents for full SWE automation.
  • Refactoring and Migrations: Initiate code refactors, test suites, or migrations and let the agent work in the background.

Advantages and Benefits

  • Increased Productivity: By offloading tasks, developers can massively parallelize their work, focusing on complex problems while agents handle background tasks. This can make a developer 2-3x faster.
  • Efficiency Gains: Delegating easier, smaller, more predictable tasks allows for significant efficiency gains as these tasks can be “crushed in one shot” by the agent, freeing up developer time for higher-value work.
  • Seamless Collaboration: Team members can review agent-generated diffs and pull requests, and even create pull requests directly from the web interface. Slack integration allows for notifications on task completion and triggering agents via @Cursor.
  • Always-On Capability: Agents can run tasks while you’re away, accessible from any device.
  • Deep Context Awareness: Cursor’s agents benefit from deep context awareness due to codebase indexing, which allows them to understand local variables, imported libraries, and project structure. You can also provide specific context using @ symbols (files, folders, code, documentation, web searches, past chats, rules).

Limitations and Considerations

  • Cost: Background agents are generally pricier than using a normal AI agent because they use Max Mode-compatible models. An easy PR might cost around $4.63 during the preview phase.
  • Task Complexity: While powerful, it’s advised to delegate easier, smaller, more predictable tasks to background agents. Larger, more complex tasks are less likely to be 100% perfect in one shot and might still require foreground agent feedback and manual tweaks.
  • Privacy Trade-offs: For advanced features like background agents, Privacy Mode needs to be temporarily turned off, meaning your code is sent to remote environments. This presents a balance between maximum privacy and full functionality. Cursor is SOC 2 Type II certified for security.
  • Inconsistent Edits: Some users report inconsistent code edits with certain models, requiring multiple retries or manual intervention, or the AI claiming completion when it hasn’t.
  • Human Oversight Still Needed: Despite automation, human oversight is still crucial for proper PR formatting and adherence to project-specific conventions. It’s like having a fast junior developer who needs supervision; you remain responsible for ensuring the code works correctly.
  • No Official API (Currently): While there’s a strong community demand for an official API to programmatically trigger background agents and integrate with other systems like Jira or custom MCP servers, it is not currently planned. Unofficial reverse-engineered solutions exist but may be unstable.

Management and Interaction

  • Control Panel: You can access the background agent control panel (by pressing Ctrl+Shift+B or ⌘B) to list agents, spawn new ones, and view their status.
  • Monitoring Progress: You can monitor the agent’s progress, reasoning, and “to-do list” by observing the workflow_state.md file (in specific autonomous setups).
  • Intervention: You can send follow-up instructions, or even “take over” the agent’s work at any time. If an agent goes astray, you can stop or correct it.
  • Review and Merge: Once a task is complete, you can review the generated pull request and merge the changes into your project. Cursor provides a built-in diff viewer for every AI suggestion.

Future Outlook

Cursor’s roadmap indicates a clear trajectory toward even more powerful and autonomous AI agents. Future enhancements include:

  • Structured Planning: Improved “to-do lists” and planning capabilities for the agents.
  • Enhanced Context Management: Features like “Memories” and PR indexing for better continuity and understanding across tasks.
  • Deeper Workflow Integrations: Potential for automated merge conflict resolution and triggering agents via Slack or other CI/CD hooks.
  • Self-Correcting Test Loops: An anticipated feature where the AI can iteratively fix errors by running tests and refining code until all tests pass.

Last modified on .