Git worktrees let agents work in separate checkouts, run commands in isolation, and open pull requests. Cursor’s original feature also needed code for worktree creation and cleanup, setup scripts, judging, and safeguards to keep agents inside their checkouts.
Replacing 12K LoC with a 200 LoC Skill
Speaker
David Gomes of Cursor describes to AI Engineer how Cursor replaced its Git worktrees and Best of N feature implementations with lightweight commands powered by agent prompts.
Cursor combined agent instructions with subagents to recreate worktree and Best of N workflows. The /worktree command guides an agent to create and use an isolated checkout; /best-of-N starts multiple subagents, each with its own worktree, then compares their results. Gomes says the Best of N prompt is about 40 lines, while the previous implementation was around 4,000 lines of code. These prompts are delivered as commands so Cursor can update them on its servers.
The change removes much of the maintenance burden and lets users switch into a worktree mid-conversation. It also supports projects with multiple repositories and lets users combine useful parts of different model outputs. The tradeoffs include weaker enforcement of checkout boundaries, lower discoverability, and a workflow that can feel slower even though Gomes says it is not actually slower.
Gomes says Cursor is working on evals, prompt improvements, and training to reduce agents’ tendency to modify the primary checkout. His initial evals use the headless Cursor CLI and separate scorers to check whether work happened in the intended worktree and whether the primary checkout stayed untouched. In early tests, Haiku deviated more often, while Composer and Grok did better.
Cursor plans to build a more complete native worktrees experience in its newer agent-focused interface, while continuing to improve the commands through evals and training. Gomes also says the team is exploring local parallelization options that are faster, use less disk space, and work beyond Git repositories.
Takeaways
- Prompt-based workflows can replace substantial feature code when they reuse existing agent and subagent capabilities.
- A lighter implementation can add flexibility, such as switching to a worktree mid-chat and handling multiple repositories.
- Instructions alone do not enforce isolation; evaluate whether agents modify the intended checkout and whether they touch the primary one.
- Expect prompt-driven tools to vary across models and over long sessions, and use evals and training to find and address failure patterns.
- A prompt-based command can help validate a workflow while a more native interface remains a longer-term product direction.
Mentioned in this talk
Search inside this talk
What was claimed 4
- feature
Cursor: Agents can work in isolated checkouts in parallel.
Agents can work in isolated checkouts in parallel.“they allow you to work in parallel”
YouTube Unverified2 sources· Talk
- feature
Cursor: Run the same task on different models and compare their implementations.
Run the same task on different models and compare their implementations.“different models compete on the same task”
YouTube Unverified2 sources· Talk
- metric
Cursor: About 15,000 lines of code deleted in the new implementation.
“around 15,000 lines of code were deleted”
YouTube Unverified1 source· Talk
- feature
Cursor: Worktree and Best of N behavior is implemented through Markdown instructions and subagents.
Worktree and Best of N behavior is implemented through Markdown instructions and subagents.“reimplement both the Cursor worktrees feature as well as the Cursor best-of-N feature with just Markdown”
YouTube Unverified1 source· Talk









