Skip to content

How to Use Cursor’s Parallel Agents for Large Refactors

6 min read

How to Use Cursor's Parallel Agents for Large Refactors
Photo by Mikhail Nilov on Pexels

Why Large Refactors Break Single-Agent Workflows

Ask a single Cursor agent to rename a module used in 400 files and it will start strong — then stall, lose context, or quietly skip edge cases around turn 80. The problem is not the model; it is the architecture. One agent, one context window, one sequential thread of execution does not scale to the kind of structural refactors real codebases need.

Cursor 2.5, released on February 17, 2026, addressed this directly. Parallel cloud agents let you run up to eight agents simultaneously, each in an isolated Ubuntu VM with its own git worktree, each independently working on a different slice of the same codebase. Cursor 2.6 (March 3, 2026) went further by making subagents asynchronous — the parent agent no longer blocks while children execute, cutting latency and enabling genuinely concurrent work.

This guide covers how to configure and run parallel agents for multi-file refactors, what to expect from the architecture, and where it still falls short.

How Cursor’s Parallel Agent Architecture Works

Cursor’s multi-agent system uses three distinct roles. Planner agents explore your codebase, break down the task into discrete work units, and spawn child planners for particularly large sub-problems. Worker agents execute those units independently — they do not coordinate with each other, they just complete their task and push changes. A judge agent then evaluates whether the combined output meets the goal and decides whether to iterate.

Isolation is provided by git worktrees — a Git feature that lets multiple branches of a repository exist simultaneously on disk without interfering. Each agent gets its own worktree, so agents can write to the same logical files without file-lock conflicts. When you are happy with a result, clicking Apply merges changes back into your primary branch. Cursor handles conflict resolution if multiple agents modified the same file, offering either full overwrite or native merge.

On the compute side, parallel cloud agents run in remote VMs — so they do not compete for CPU on your laptop and can run while you are doing other work, or even away from your machine. Cursor’s internal experiments using this architecture include rewriting a web browser (1 million lines of code across 1,000 files) in roughly 7 days and completing a Solid-to-React migration with +266,000 / -193,000 line edits.

Setting Up Worktrees for Your Project

Before running parallel agents, tell Cursor how to initialize each isolated worktree. Without this, agents start in an environment missing your dependencies, env files, or database migrations — and will fail silently.

Create or edit `.cursor/worktrees.json` in your project root:

{
  "setup-worktree-unix": ["npm ci", "cp $ROOT_WORKTREE_PATH/.env .env"],
  "setup-worktree-windows": ["npm ci", "copy %ROOT_WORKTREE_PATH%\\.env .env"]
}

The $ROOT_WORKTREE_PATH variable points to your primary working tree, so you can copy environment files or secrets from it into each agent’s isolated copy without committing them. For Python projects, you might run pip install -r requirements.txt and cp $ROOT_WORKTREE_PATH/.env .env. For monorepos with database state, add your migration command here.

Two settings are worth knowing: cursor.worktreeMaxCount caps the number of active worktrees (default 20) and cursor.worktreeCleanupIntervalHours controls how often stale ones are pruned (default every 6 hours). For most teams, the defaults are fine.

Running a Parallel Refactor: Step by Step

The single most important habit before launching parallel agents is using Plan Mode. Press Shift+Tab to switch the agent into planning mode. Instead of writing code immediately, the agent will read your codebase, ask clarifying questions, and produce a structured task breakdown. This step is not optional — without a clear plan, the planner agents will either overlap work or miss files entirely.

A practical sequence for a large refactor:

  1. Define the scope precisely. “Migrate all REST calls in src/api/ from axios to the native fetch API, preserving error handling” is actionable. “Modernize the API layer” is not.
  2. Run Plan Mode. Review what the agent proposes before approving. Push back on any subtask that seems too broad for a single agent.
  3. Launch parallel agents. Once you approve the plan, Cursor spawns worker agents for each subtask. You can watch progress in the parallel agents panel — each agent streams its diff in real time.
  4. Write tests first, or verify them early. Cursor’s best-practice recommendation is to have agents write failing tests before implementing changes, then confirm the implementation passes them. This gives the judge agent a concrete signal to evaluate.
  5. Review and Apply selectively. Do not apply all worktrees at once. Review the diff from each agent individually. For conflicts, Cursor’s merge interface handles most cases automatically.

For very large projects — the kind where even the planning phase is complex — you can spawn sub-planners. A top-level planner handles the domain split (e.g., frontend vs. backend), then each sub-planner handles its domain independently, recursively breaking down work until individual tasks are small enough for a single worker agent to complete reliably.

If you are running this as a background job — a migration you want to happen overnight — use cloud agents rather than local parallel agents. Cloud agents run on Cursor’s infrastructure, require no open laptop, and send you a PR to review when done. The BugBot autofix workflow follows this same model for automated bug fixes on open PRs.

Picking the Right Model for Each Role

Model choice matters more than most teams realize in long-running agent runs. According to Cursor’s own research on their scaling architecture, GPT-5.2 outperforms the alternatives for extended autonomous work — it stays on task longer and is less likely to shortcut hard subtasks. Claude Opus 4.5 “tends to stop earlier and take shortcuts” in extended runs, which makes it better suited to focused, bounded worker tasks than open-ended planning.

Cursor’s multi-model comparison feature — running the same prompt across two or three models in separate worktrees simultaneously — is worth using when the refactor touches core business logic. You get different architectural approaches in parallel and can pick the one that handles edge cases better, rather than discovering the gaps after merging.

The tooling does not eliminate the need for judgment. The prompt engineering behind each subtask is what Cursor’s own team calls the most important variable: “The harness and models matter, but the prompts matter more.” Agents that receive vague instructions produce vague outputs regardless of how many of them you run in parallel.

Adoption of AI coding agents is growing fast — nearly 90% of engineering teams now have some form of AI agent in their workflow — but delivery metrics have not improved at the same rate. Parallel agents are not a shortcut around careful task design; they are a force multiplier on whatever you put into them.

Further Reading

Don’t miss on Ai tips!

We don’t spam! We are not selling your data. Read our privacy policy for more info.

Don’t miss on Ai tips!

We don’t spam! We are not selling your data. Read our privacy policy for more info.

Enjoyed this? Get one AI insight per day.

Join engineers and decision-makers who start their morning with vortx.ch. No fluff, no hype — just what matters in AI.