[BUG] claude -w creates worktree from stale local branch without fetching remote HEAD
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?
claude -w creates a worktree based on the current local branch without fetching the remote integration branch first. If the source branch is behind the remote HEAD (e.g. origin/dev), the worktree silently inherits stale code. No fetch, no warning.
This caused an entire refactoring session to be built on code missing a recently merged PR. The bug was only discovered late in the session when tests revealed a cache bug that had already been fixed in a PR merged to the integration branch earlier that day.
Steps to Reproduce
- Have a repo where
origin HEADisdev - Be on a feature branch that was created from
deva few commits ago - A PR is merged to
devafter the feature branch was created - Run
claude -wto create a worktree for a new task - The worktree is created from the current branch's HEAD, not from
origin/dev - The worktree is missing the code from the merged PR
Expected Behavior
claude -w should either:
git fetch originand base the worktree on the latest remote HEAD branch (e.g.origin/dev), or- Warn the user that the source branch is behind its remote integration branch
The remote HEAD is discoverable via git remote show origin | grep "HEAD branch".
Actual Behavior
The worktree is silently created from whatever stale state the current local branch is in. No fetch, no rebase, no warning. Work proceeds on outdated code.
Context
- The user's CLAUDE.md and memory both specify "Always base worktrees on dev, not main"
git remote show originreportsHEAD branch: dev- The information needed to do the right thing is available — it's just not used
Related Issues
- #51545 — stale SHA within a session (different: that's about branch advancing after worktree creation)
- #30070 — wrong remote (different: that's about which remote, not about fetching)
Version
Claude Code 2.1.104, macOS Darwin 25.3.0
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗