Skip to content

[FEATURE] Allow --worktree to branch from current HEAD instead of default remote branch #27876

Description

@dariusrosendahl

Feature Request

When using claude --worktree (or claude -w), the new worktree always branches from the default remote branch (e.g., main). There's no way to create a worktree based on the current branch/HEAD.

Use Case

When working on a feature branch and wanting to spin up an isolated Claude session to work on a subtask or related change, it would be useful to branch from the current branch rather than main. Currently, the workaround is to manually create a worktree with git and then start Claude in it:

git worktree add .claude/worktrees/my-feature -b worktree-my-feature HEAD
cd .claude/worktrees/my-feature && claude

This loses the automatic cleanup prompt and other niceties of --worktree.

Proposal

Add a --worktree-base flag (or similar) to specify the base branch/ref:

# Branch from current HEAD
claude -w my-feature --worktree-base HEAD

# Branch from a specific branch
claude -w my-feature --worktree-base feature/auth

Alternatively, a simpler approach: make --worktree branch from HEAD by default (matching git worktree add behavior) instead of always using the default remote branch. This would be the least surprising behavior for users already on a feature branch.

A middle ground could be a setting in ~/.claude/settings.json:

{
  "worktree": {
    "baseBranch": "HEAD"
  }
}

Current Behavior

claude --worktree always branches from the default remote branch (e.g., origin/main).

Expected Behavior

Users should be able to control which branch/ref the worktree is based on, either via a CLI flag or a setting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions