spawn_task chips should branch from parent session's current branch, not repo default
Problem
The mcp__ccd_session__spawn_task tool (used by Cowork "chips" to launch a fresh Claude Code session in a new git worktree) always creates the new worktree from the repo's default branch, regardless of the parent session's current branch.
This invalidates every worktree use-case spawn_task has. The only reason to spawn a fresh session in a new worktree is to hand off context-heavy follow-up work — refactors, cleanups, tests against code you just wrote. All of those require the parent session's unmerged commits to be present. If the new worktree can't see them, the spawned agent is staring at stale code and the task is unrunnable until a human manually redirects its branch.
If the parent's work isn't needed, there's no reason to spawn a session at all — the parent could have done the work inline.
Concrete failure mode
A feature branch contains ~45 commits of site redesign + design-partner launch work not yet merged to dev. The parent Claude session just finished the launch and spawned three spawn_task chips for follow-up refactors (shared form abstractions, server-action helpers, route constants).
Each chip would have been unrunnable: the files they need to refactor — site/app/design-partners/DesignPartnerForm.tsx, submitDesignPartnerApplication in site/app/actions.ts, site/components/SiteNav.tsx — only exist on the feature branch. The new worktrees would have branched off dev, where none of those files exist.
The workaround is to bake explicit branch-setup instructions at the top of every spawn_task prompt ("fetch branch X, check out a new branch from it, verify file Y exists before starting"). That works but pushes discipline onto every caller and is easy to forget.
Proposed fix
Spawned worktrees should default to branching off the parent session's current HEAD, not the repo default. Optionally, expose an override param on spawn_task if an escape hatch is needed (branch off main regardless, e.g. for truly orthogonal work).
Related: #27749 (closed as "not planned") raised a similar issue for the Task tool's isolation: "worktree" mode. That issue was scoped narrowly to custom branch names, which is why the "not planned" rationale made sense. This is a different, sharper scope — correct default inheritance, not a new configuration surface.
Environment
- Claude Code version: 2.1.104
- OS: macOS
- Tool affected:
mcp__ccd_session__spawn_task(Cowork chip spawner)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗