claude-code - 💡(How to fix) Fix spawn_task chips should branch from parent session's current branch, not repo default [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52243Fetched 2026-04-24 06:12:22
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

Fix Action

Fix / Workaround

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.

RAW_BUFFERClick to expand / collapse

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)

extent analysis

TL;DR

The mcp__ccd_session__spawn_task tool should be modified to default to branching off the parent session's current HEAD instead of the repo default branch.

Guidance

  • Verify the current behavior by checking the branch used by the new worktree created by mcp__ccd_session__spawn_task.
  • Update the mcp__ccd_session__spawn_task tool to use the parent session's current HEAD as the default branch for new worktrees.
  • Consider adding an override parameter to spawn_task to allow branching off a different branch if needed.
  • Test the updated tool with different scenarios, including feature branches with unmerged commits.

Example

No code snippet is provided as the issue does not include specific code details.

Notes

The proposed fix assumes that the mcp__ccd_session__spawn_task tool has access to the parent session's current HEAD. If this is not the case, additional changes may be required to obtain this information.

Recommendation

Apply the workaround of updating the mcp__ccd_session__spawn_task tool to default to branching off the parent session's current HEAD, as this addresses the root cause of the issue and provides the correct functionality for the use case.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING