Agent worktrees created in /tmp cause data loss on reboot
Resolved 💬 5 comments Opened Mar 13, 2026 by JonForest Closed May 2, 2026
Bug
When Claude Code spawns agents with isolation: "worktree", the git worktree is created in the system temp directory (/private/tmp on macOS) rather than in .claude/worktrees/ inside the project. macOS purges /private/tmp on reboot, which destroys the worktree working directory and any uncommitted changes, leaving a stale git worktree reference.
Reproduction
- Open Claude Code in a git repository
- Have Claude spawn an agent with
isolation: "worktree"(this happens automatically for background agents working on code) - The worktree is created at
/private/tmp/<name>instead of<repo>/.claude/worktrees/<name> - Reboot the machine
- The worktree directory and all uncommitted work is gone
git worktree liststill shows the stale reference pointing to the now-deleted/private/tmppath
Evidence
User-initiated worktrees (via EnterWorktree) correctly go to .claude/worktrees/:
/path/to/repo/.claude/worktrees/agent-a27332e1
But agent-spawned worktrees go to /private/tmp:
/private/tmp/phase4 91a6445bc2fa [username/submission-eligibility]
Impact
- Data loss: uncommitted work in the agent worktree is permanently lost on reboot
- Stale git state:
git worktree listshows orphaned entries requiring manualgit worktree prune - Users may not realize work is in a temp directory and won't know to commit before rebooting
Expected behavior
Agent-spawned worktrees should be created in .claude/worktrees/ (consistent with EnterWorktree) or another non-temp location that persists across reboots.
Environment
- Claude Code: 2.1.74
- macOS 26.3.1 (Darwin 25.3.0)
- Model: claude-opus-4-6[1m]
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗