How do I get the model to change the source directory and not ~/.cursor/worktrees

Had opus4.5 do a plan then execute. It won’t stop editing files in ~/.cursor/worktrees/ instead of the actual source directory. How do I tell it where to change the code?

ChatGPT tells me:

Yeah, your reaction is justified. This is Cursor getting clever at exactly the wrong layer.

What the hell are these “worktrees”?

Short version: Cursor is silently editing a copy of your repo, not your repo.

Longer, accurate version:

  • Cursor started using Git worktrees internally so the AI can:

    • Make speculative edits

    • Run tools / refactors without wrecking your working tree

    • Switch branches or states without stomping on your files

  • Those live under:

~/.cursor/worktrees/<some-hash>/
  • The AI edits that directory.

  • Then Cursor is supposed to sync or apply the changes back to your real repo.

When it fails (which it does, often), you get:

  • “I changed the file” → no diff

  • Git shows nothing

  • You waste time arguing with the model like it’s gaslighting you

So no, you’re not crazy. This is a UX footgun.

Why Cursor thinks this is a good idea (and why it’s mostly BS)

The theoretical benefits:

  • Safety: AI can’t trash your repo

  • Parallel experiments

  • Cleaner undo

The reality:

  • Breaks muscle memory

  • Breaks Git workflows

  • Breaks trust (“did it actually change anything?”)

  • Actively hostile if you live in git status

For experienced devs, this is negative value.

How to DISABLE worktrees in Cursor (this is the part you actually want)

As of now, Cursor does not expose this cleanly in the UI (yeah…).

But you can force sane behavior.

Option 1 (recommended): Turn off “agent mode” / sandboxed edits

  1. Open Cursor Settings

  2. Search for:

worktree
sandbox
agent
  1. Disable anything resembling:

    • Agent mode

    • Isolated workspace

    • Sandboxed edits

    • Apply changes in background workspace

Cursor’s wording changes between versions, but the intent is:

Force edits to apply directly to the open workspace

If there is a toggle like:

“Apply AI edits directly to files”

Turn it ON.


Option 2: Force “Apply changes” instead of background edits

When prompting Cursor, be explicit:

“Edit the files in the current workspace and apply changes directly. Do not use worktrees or background workspaces.”

This works annoyingly often because the model can choose the mode, but it’s brittle and stupid that you have to do this.

Option 3: Nuclear option (works)

If Cursor keeps misbehaving:

  1. Close Cursor

  2. Delete: ~/.cursor/worktrees

  3. Reopen your project

  4. Immediately disable any agent/sandbox features before running AI again

This doesn’t permanently disable worktrees, but it stops Cursor from reusing stale ones and “helpfully” editing the wrong copy.

Reality check (candid part)

  • This feature is built for people who don’t understand Git

  • Cursor optimized for “wow demos,” not serious workflows

  • If you live in git diff, this is objectively hostile design

You’re not misunderstanding anything — Cursor failed to respect the contract that “the open folder is the thing being edited.”

according to docs: Parallel Agents | Cursor Docs it is not possible

… none of which helps. You can’t just disable the agent.

hi @blackburied are you able to switch from Worktrees to Local in chat?

I do not recommend asking AI for now to show solutions which it doesnt know about.

Note that option isn’t available in my chat that started as a planning mode. Instead, there’s a branch-like icon to the right of the LLM selection that, hovering, indicated something about worktrees.

The real solution is to not use plan mode.

image