Replacing Complex Feature Implementation with Prompt-Based Skills: Git Worktrees in Production

cursor · Tech · 2026 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: AI coding agent worktree orchestration and product feature maintenance

Cursor's original git worktrees feature enabled parallel isolated agent work, best-of-N model comparison, judging, setup scripts, and cleanup, but it required a large codebase and maintenance burden for an advanced power-user feature.

Constraints:

Architecture

Cursor replaced much of the programmatic worktree and best-of-N implementation with prompt-controlled commands that behave like skills. A user invokes /worktree or best-of-N-style commands; the prompt is loaded from Cursor's backend, tells the agent how to create worktrees, run setup scripts, stay in the checkout, spawn subagents for multiple models, wait for them, compare outputs, and optionally stitch pieces together. This removed around 15,000 lines from one feature and replaced a prior 4,000-line best-of-N implementation with roughly 40 lines of markdown, while leaving isolation correctness to model behavior plus eval/RL improvements.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  A["Cursor user command"] --> B["Backend-controlled prompt"]
  B --> C["Parent agent"]
  C --> D["Git worktree"]
  C --> E["Subagent pool"]
  D --> F["Setup scripts"]
  E --> D
  E --> G["Model providers"]
  D --> H["Primary checkout"]
  I["Eval harness"] --> D
  I --> H
  C --> J["Comparison output"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Cursor user command Slash command such as /worktree or best-of-N request that loads the worktree prompt. Backend-controlled prompt
Backend-controlled prompt Markdown instruction payload controlled by Cursor servers and loaded only when the user invokes the command. Cursor user command, Parent agent
Parent agent Creates worktrees or launches subagents, waits for results, compares implementations, and advises the user. Backend-controlled prompt, Git worktree, Subagent pool, Comparison output
Git worktree Isolated checkout where an agent performs code changes away from the primary checkout. Parent agent, Subagent pool, Setup scripts, Primary checkout
Subagent pool Parallel model-specific agents for best-of-N or multi-agent coding workflows. Parent agent, Git worktree, Model providers
Setup scripts User-configured setup steps run when an agent begins work in a worktree. Git worktree
Model providers Models such as Kimi, Grok, Composer, GPT, and Opus competing on the same task. Subagent pool
Primary checkout Main repository checkout that should not be modified by worktree agents until changes are applied. Git worktree, Eval harness
Eval harness Headless Cursor CLI and scorers checking whether work happened in the worktree and not in the primary checkout. Primary checkout, Git worktree
Comparison output User-facing table/commentary that compares model implementations and can stitch pieces together. Parent agent

Data flow

A user invokes /worktree with a task or asks for multiple models to compete. Cursor loads the command prompt from the backend. For a single worktree, the agent creates an isolated checkout, runs setup scripts, works inside that directory, and can apply/delete the worktree later. For best-of-N, a parent agent creates subagents for each specified model, each subagent creates and works inside its own worktree, and the parent waits for all outputs, compares them, and presents a table or combined recommendation to the user.

3 supporting quotes
“the prompts for them can be controlled in our servers in our backend.”transcript, stated
“we're instructing the parent agent to go and create sub agents for each model, and then spin up a work tree”transcript, stated
“we also tell it to wait for all the sub agents, and when they're done, please provide some commentary.”transcript, stated

Why this architecture

Cursor chose prompt-based commands because the previous implementation was a heavy maintenance burden for an advanced feature. Skills/subagents reused existing primitives, allowed backend prompt iteration without app updates, enabled multi-repo and mid-chat worktree switching, and gave the parent agent better context for comparing implementations. The tradeoff is that isolation now depends on model compliance rather than physical enforcement.

3 supporting quotes
“the main pro of re-implementing this entire feature as a skill is that I have a lot less code to maintain.”transcript, stated
“now that it's just a slash command, it's much easier for for users to switch to a work tree halfway through a chat.”transcript, stated
“Now, we're trusting the model. So, it's you could say it's a bit vibes-based”transcript, stated

Models used: Kimi · Grok · Composer · GPT · Opus · Haiku

Scale

Alternatives considered (roads not taken)

Original programmatic worktrees feature

Rejected because: It enforced isolation strongly but required large amounts of code across worktree creation, context feeding, setup scripts, judging, harness changes, reminders, and cleanup.

“we had to write all the code for creating work trees, managing these work trees, feeding them into the agent as context.”transcript, stated
“And then finally there's there's some cleanup complexity as well because people like to spin up hundreds of these work trees”transcript, stated

Skills instead of commands

Rejected because: Cursor used commands so prompts could be controlled and iterated from the backend without requiring users to update Cursor.

“the only reason we did it as commands and not as skills is so that the prompts for them can be controlled in our servers in our backend.”transcript, stated
“I can iterate on these prompts um without you having to update your Cursor version.”transcript, stated

Fully prompt-based isolation

Rejected because: It is accepted for the lightweight version but explicitly weaker than the old physical enforcement, so Cursor is adding evals, reminders, and RL training.

“the agent had to stay on track. Like, it we didn't let the model ever touch any files outside its worktree. It was physically impossible for it to do so.”transcript, stated
“Now, we're trusting the model.”transcript, stated

Patterns

prompt-versioning (prompt-ops)

Cursor keeps the command prompts server-side so improvements can ship without app updates.

“the prompts for them can be controlled in our servers in our backend.”transcript, stated
“if I do some improvements to these prompts, the next time you use them, you're going to have you're going to get the latest version of the prompts.”transcript, stated

multi-agent-orchestration (architecture)

The best-of-N command has a parent agent create subagents for different models, wait for them, and compare their work.

“the parent agent starts by spinning up five sub agents on the five different models that I specified”transcript, stated
“the parent model, as instructed, will do that comparison of across all the different submissions.”transcript, stated

eval-driven-development (quality)

Cursor is adding evals that score whether models work inside their worktree and avoid modifying the primary checkout.

“the biggest problem right now is that the agent is not really always staying on track.”transcript, stated
“I have a two scorers. One that checks to see if the model did any work in its work tree as expected, and then another one, which is the reverse of that”transcript, stated

fine-tuning-adaptation (model-adaptation)

Cursor plans to add worktree-operation tasks into Composer's RL pipeline so future in-house models handle prompt-based worktree discipline better.

“we're working on adding a bunch of these tasks into our RL pipeline”transcript, stated
“by the time we launch Composer 3 or 4 or 5, uh at least our own model will be much better at this.”transcript, stated

workflow-decomposition (product-architecture)

Cursor decomposed the feature into existing primitives: skills/commands, subagents, git worktrees, setup scripts, and parent-agent comparison.

“there are two primitives that we could use to effectively allow Cursor users to use work trees by simply leveraging two primitives. One is agent skills and the other are sub agents.”transcript, stated

Tradeoffs

Feature implementation style

Chose prompt-based commands/skills plus subagents over large custom application feature code.

Rationale: The prompt version is dramatically lighter to maintain and unlocks new flows, but relies more on model behavior.

“going from a full-blown feature with a lot of code, a lot of dependencies, a lot of complexity and tests into a much more lightweight, streamlined version”transcript, stated
“The new implementation of the feature is almost as good as the previous one um and it is much much more lightweight in terms of us to maintain it”transcript, stated

Prompt delivery

Chose server-controlled commands over local skills requiring app updates.

Rationale: Server-side prompts allow iteration without users updating Cursor.

“I can iterate on these prompts um without you having to update your Cursor version.”transcript, stated

Best-of-N comparison

Chose parent-agent synthesis over picking one implementation over choosing a single subagent/model output.

Rationale: The parent can compare submissions, critique them, and combine pieces from different implementations.

“In the previous implementation, you had to choose one sub-agent or one model and just stick with that.”transcript, stated
“Can you match them together?" And the the parent agent will do that for you.”transcript, stated

Gotchas (what bit them)

Prompt-based worktree discipline is weaker than enforced filesystem isolation.

Root cause: The new system trusts the model to stay in the intended checkout instead of physically preventing access outside the worktree.

Resolution: Cursor is adding evals, stronger prompts/system reminders, and RL tasks for Composer.

“we didn't let the model ever touch any files outside its worktree. It was physically impossible for it to do so.”transcript, stated
“we're basically saying, "Hey, operate on this directory and and and then like, you know, knock on wood, please please don't forget about this."”transcript, stated

Long sessions and weaker models drift out of the worktree.

Root cause: Models can forget operating constraints or hallucinate, especially over long interactions.

Resolution: Cursor is testing models with worktree evals and found stronger models such as Composer and Grok performed better than Haiku.

“especially over long sessions, it's quite possible that the model will forget where it should be operating.”transcript, stated
“Haiku, which is a smaller, less intelligent model, will very often deviate and start working in the primary checkout.”transcript, stated

The command feels slower even if it is not actually slower.

Root cause: Users now see the agent creating the worktree in chat instead of Cursor doing setup invisibly.

Resolution: Cursor is looking at UX improvements while accepting the lightweight architecture.

“It's not actually slower, but it does feel like the agent is kind of like wasting time doing something that should be done for it in advance.”transcript, stated

Discoverability got worse.

Root cause: The visible dropdown was removed; users now must know the slash command exists.

Resolution: Cursor accepts this because worktrees are an advanced power-user feature.

“if you want to use work trees, you have to know the feature exists, so you can actually type {slash} work tree.”transcript, stated
“this is an advanced power user feature”transcript, stated

Evaluation

Cursor is building evals with the headless Cursor CLI and two scorers: one checks whether the model did work inside the worktree and another checks whether it modified the primary checkout. The source also compares model behavior qualitatively across Haiku, Composer, and Grok.

Metrics: Around 15,000 lines deleted from the old feature · Around 40 lines of markdown for the new best-of-N skill · Old best-of-N implementation was about 4,000 lines · Two eval scorers: work in worktree and no work in primary checkout · Model comparison across Haiku, Composer, and Grok

3 supporting quotes
“I spin up the cursor CLI. It's headless, so it's great for evals.”transcript, stated
“One that checks to see if the model did any work in its work tree as expected, and then another one, which is the reverse of that”transcript, stated
“Composer and Grok, um are doing much better.”transcript, stated

Outcomes

The feature targets Cursor power users rather than most users; the source explicitly says worktrees are not used by 90% of users.

3 supporting quotes
“We're not talking about a feature that is used by 90% of Cursor's users. Far from it.”transcript, stated
“The agent will make sure to create a worktree on each repo, and then if you open a PR, it'll open two PRs, one for each repo.”transcript, stated
“the judging experience at the end of knowing what model did which for best of N is far superior.”transcript, stated