--worktree (-w) flag silently fails to create git worktree

Resolved 💬 3 comments Opened Apr 1, 2026 by zime78 Closed May 22, 2026

Bug Description

When launching Claude Code with the --worktree (-w) flag, the session starts normally but no git worktree is created. There is no error message or warning — it silently fails and runs in the main working directory.

Steps to Reproduce

  1. Navigate to a git repository
  2. Run: claude --dangerously-skip-permissions -w setting
  3. Session starts normally (hooks fire, conversation begins)
  4. Run git worktree list inside the session

Expected Behavior

  • A new git worktree named setting should be created
  • The session should run inside the worktree directory
  • A new branch (e.g., setting or worktree/setting) should be checked out

Actual Behavior

  • Session starts in the main working directory (not a worktree)
  • git worktree list shows only the main directory — no additional worktrees
  • .git/worktrees/ directory does not exist
  • No error message or warning is displayed
  • No branch related to "setting" is created
$ git worktree list
/path/to/repo  e53765b5 [feature/zime/dev]

Environment

  • Claude Code version: 2.1.89
  • OS: macOS (Darwin 25.4.0)
  • Shell: zsh
  • Platform: darwin (Apple Silicon)
  • Git version: available and working (repo is clean, no uncommitted changes)

Additional Context

  • The repository has a clean working tree (no uncommitted changes)
  • The current branch is a feature branch (feature/zime/dev)
  • The --help output confirms the flag exists: -w, --worktree [name] Create a new git worktree for this session (optionally specify a name)
  • Other flags in the same command (--dangerously-skip-permissions) work correctly

View original on GitHub ↗

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