Chip-spawned task runs on primary checkout instead of fresh worktree
Summary
A task spawned by clicking a chip created via mcp__ccd_session__spawn_task opens a new session that runs on the primary checkout's current branch (e.g. main), not in a fresh git worktree under .claude/worktrees/agent-<hash>/. This contradicts the documented desktop-app contract that each session is automatically isolated in its own worktree.
Expected behavior
Per the docs:
- Worktrees: "The desktop app creates a worktree for every new session automatically."
- Desktop: "For Git repositories, each session gets its own isolated copy of your project using Git worktrees, so changes in one session don't affect others."
- Issue #53494 (chip flow): "User clicks the chip — task spawns to a fresh worktree."
- Issue #50109 (request for
--no-worktreeopt-out) was closed; no opt-out exists.
The chip-spawned session should:
- Create
.claude/worktrees/agent-<hash>/under the project root. - Open the new session with its CWD inside that worktree.
- Have HEAD on a fresh branch, not on the primary checkout's current branch.
Actual behavior
The chip-spawned session opens with its CWD on the primary checkout, on the primary's current branch. No .claude/worktrees/agent-<hash>/ directory is created for it.
Evidence from the Code-tab session footer of a chip-spawned session in a private repo:
<repo> main +0 -310 [Create PR]
The footer shows main (the primary branch), not the documented agent-<hash> worktree branch. The +0 -310 is a working-tree diff against main — i.e. the spawned session is editing files directly on the primary checkout. Any commit it makes will land on main of the primary, exactly the contamination the worktree contract is supposed to prevent.
Reproduction
- From a parent Claude Code session, invoke
mcp__ccd_session__spawn_taskwith atitle,prompt, andtldr. A chip appears in the parent's UI. - Click the chip.
- In the spawned session's footer (Code tab), observe the branch label.
- Run inside the spawned session:
``bash``
pwd
git rev-parse --show-toplevel
git rev-parse --abbrev-ref HEAD
git rev-parse --git-common-dir
- Expected:
pwdends in.claude/worktrees/agent-<hash>;--show-toplevelreturns that worktree path;HEADis a fresh branch;--git-common-dirpoints at the primary's.git/. - Actual:
pwdis the primary checkout;HEADis the primary's current branch (e.g.main); the worktree was never created.
Impact
- Silent contract violation. Both the desktop docs and the chip's own UX (chip → "fresh session") imply isolation. Sessions appear isolated but mutate the primary tree.
- Risk of accidental commits to
main. A spawned session that thinks it's in its own worktree (per the documented contract) will happilygit commitand land work directly on the parent's working branch. - Confounds debugging. Because the worktree contract is documented as unconditional, downstream rules and skills assume it.
Environment
- OS: Windows 11 Pro (10.0.22621)
- Claude Code desktop version: 1.9659.2 (390d6c)
.claude/worktrees/directory existed prior to chip-click: yes (sibling agent worktrees already present)- Filesystem: local NTFS; no symlinks involved; path lengths well under Windows MAX_PATH
Notes
- Tested via the standard chip UX in the Claude Desktop "Code" tab; not via the CLI
claude --resumeflow. - The
mcp__ccd_session__spawn_tasktool's own parameter surface (title,prompt,tldr) exposes no worktree-control flag, consistent with the docs treating worktree creation as the unconditional default.
Related issues, not duplicates
These all touch the same area but report different failure modes. This bug is "no worktree created at all" — the spawned session never enters worktree isolation in the first place.
- #57643 (closed) —
spawn_taskcreates the worktree offorigin/maininstead of the parent's branch. Different: assumes a worktree is created and discusses its base branch. - #52243 (closed) — Chips should branch from parent's branch, not repo default. Different: same as above, assumes worktree exists.
- #57512 (open) —
spawn_taskshould auto-add.claude/worktrees/to.git/info/exclude. Different: assumes the worktree directory is created. - #59628 (open) — Worktree sessions can edit files in the parent main checkout via absolute path. Different: the worktree exists; the agent escapes it via absolute paths. Here, no worktree exists to escape from.
- #36182 (open) — Worktree Edit/Read tools use main-workspace paths instead of worktree paths. Different: worktree exists; tool path-resolution bug.
- #63008 (open) —
preview_startMCP spawns dev server with main-repo cwd from a worktree session. Different: worktree exists; downstream MCP child inherits wrong cwd.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗