Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Agents putting worktrees in /tmp by default can wipe days of work on MacOS
I’m a heavy Cursor user on macOS. Over the last week Cursor agents repeatedly put durable project work in /tmp, macOS deleted it, and then Cursor kept the conversation rooted on the empty folder. I lost about 16 hours of work in one wipe. After that I added a user rule and a hook forbidding /tmp. Agents kept using it anyway because the chat workspace itself was /tmp.
Environment
- macOS 15
- Long-running agent chats on a large git repo
- A live local checkout I cannot disturb (dev server already running)
- Durable work lives under
~/Dev/…
What agents do
To avoid checking out a branch on top of my live IDE folder, agents create isolated git worktrees in /tmp:
git worktree add /tmp/wt-<repo>-<ticket>
This is not a one-off. In my history it is a habit: many chats, many /tmp/wt-… trees. Subagents (Task / isolated worktrees) pick /tmp as the “safe” place.
Cursor then bound the conversation to that path. From then on, the agent’s workspace was the /tmp worktree.
The IDE does not make this obvious
Nothing in the normal UI says “this chat is living in /tmp.” The window, chat title, and file tree look like a regular project. After macOS wiped the folder, the tree was just empty and the chat still looked fine. I only found out by asking the agent. Meanwhile I could keep working and committing under ~/Dev/… while the agent root, and a worker restart record, were still "roots":["/tmp/…"].
If the path were in the title bar or a banner, I would have stopped this on day one. Instead the UI implies you are in a durable workspace when you are not.
Why this is catastrophic on a Mac
/tmp is not a project directory. Reboot and periodic cleanup delete it. Uncommitted (and even committed-but-only-there) work is gone. That is the 16-hour loss.
After recovery, the real checkouts were under ~/Dev/…. The Cursor chat stayed rooted on the empty /tmp folder. Agents papered over it with cd ~/Dev/… instead of moving the window. The editor still looked like the project was open.
move_agent_to_root then failed in a way that made it worse
Calling move_agent_to_root with rootPath set to the durable ~/Dev/… checkout failed with:
Failed to move agent root: Cannot migrate: failed to detach worktree HEAD
(Error executing git: fatal: not a git repository (or any of the parent directories): .git
cwd: /tmp/…
command: "git checkout --detach")
The destination was a healthy repo. The source was an empty husk, so migrate refused to leave it.
Workaround that should not be required:
create_repoon the empty/tmpfolder (to get a.git)- empty commit so
HEADexists move_agent_to_rootagain
That finally moved the chat. It also checked out a new local master on the destination to match the husk’s branch name, even though the real work was on a different feature branch. I had to switch back and delete that master.
What Should Be Changed
- Never put agent worktrees, clones, or chat roots in
/tmp,/private/tmp,/var/folders, or$TMPDIRon macOS. Default to something durable, not a directory the OS is designed to wipe. - Show the agent workspace path in the UI, especially when it is not the folder the user thinks they opened. A
/tmproot should be a warning, not an invisible detail. move_agent_to_rootmust not require the current folder to be a git repo. If the source is an empty husk, still move the chat to the destination. Do not rungit checkout --detachas a hard prerequisite.- Do not retarget the destination branch to whatever dummy branch the husk had (
masterin this case). - If a chat’s workspace path is under
/tmpand a durable clone exists, migrate or warn loudly. Do not silently keep the agent in a deleted folder while the user is committing in~/Dev. - Teach the agent product default: isolated worktrees are fine;
/tmpis not. User rules should not be the only backstop after losing a day’s work.
Steps to Reproduce
- Open a git repo under a durable path such as
~/Dev/my-project, with a branch already checked out. Do not let the agent check out a different branch in that folder. - Ask the agent to do a feature on a new branch without disturbing the live checkout.
- Watch it create an isolated git worktree in
/tmp(typicallygit worktree add /tmp/wt-<repo>-<ticket>) and bind the chat to that path. - Confirm the window, chat title, and file tree still look like a normal project. There is no banner that the agent root is
/tmp. - Leave the machine running, or reboot, or wait for macOS to clean
/tmp. The worktree is gone. - Keep using the same chat. The UI still looks fine; the folder is empty. The agent may
cdto~/Dev/…and keep working while the chat root stays/tmp. - Ask the agent where the work is, and it will prepare to give you devastating news.
- Call
move_agent_to_rootwithrootPathset to the durable~/Dev/…checkout.
Expected Behavior
-
Agent worktrees, clones, and chat roots never go in /tmp, /private/tmp, /var/folders, or $TMPDIR on macOS. Isolated worktrees go somewhere durable that the OS will not delete.
-
The IDE shows the agent workspace path. A /tmp root is an obvious warning, not an invisible default.
-
move_agent_to_root still moves the chat when the current folder is empty or not a git repo. It does not require git checkout --detach on the old path, and it does not switch the destination to a dummy master branch.
Operating System
MacOS
Version Information
- Cursor: 3.27.12 (arm64)
- OS: macOS 15.7.1 (24G231)
For AI issues: which model did you use?
Multiple agent chats over several days. The /tmp worktree default is not specific to one model in my usage.
Does this stop you from using Cursor
No - Cursor works, but with this issue