[BUG] Subagent worktrees (isolation: worktree) branch from default branch, not parent's current branch

Resolved 💬 3 comments Opened Apr 1, 2026 by Nubaeon Closed Apr 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When launching a subagent with isolation: "worktree", the worktree is created from the repository's default branch (e.g., main) rather than the parent's current working branch (e.g., develop).

This means the subagent cannot see any commits on the parent's branch. If the parent is on develop with 10 commits ahead of main, the subagent works on stale code from main.

What Should Happen?

isolation: "worktree" should create the worktree from the parent's current HEAD, not the repository's default branch. This ensures the subagent works on the same code the parent is working on.

Steps to Reproduce

  1. Create a feature branch or work on develop with commits ahead of main
  2. Launch a subagent with isolation: "worktree" from an Agent tool call
  3. In the subagent, check git log --oneline -3 — it shows main's commits, not develop's
  4. The subagent cannot see or modify files that only exist on the parent's branch

Observed Behavior

# Parent is on develop with recent commits:
$ git log --oneline -3
f32ca5a7 refactor(sentinel): Extract anti-gaming check
3288bc9e refactor(sentinel): Extract 3 more helpers
6ac99dcc refactor(sentinel): Table-driven is_safe_bash_command

# Subagent worktree shows main:
$ git log --oneline -3  
2b2bd311 chore: automated release 1.7.3
6ba5e9ee chore: Bump to 1.7.3
3bf43a22 feat(sentinel): Advisory mode

Environment

  • Platform: Linux (Ubuntu 24.04)
  • Claude Code: latest
  • Git: 2.47.1

Related Issues

  • #30070 — wrong remote (similar but about remote, not branch)
  • #28363 — WorktreeRemove hook not invoked (worktree lifecycle issue)

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗