Worktree cleanup hangs when using --worktree --tmux, leaving orphaned worktrees

Resolved 💬 3 comments Opened Feb 20, 2026 by Gotrek77 Closed Feb 24, 2026

Description

When launching Claude Code with --worktree --tmux, the /exit command causes the session to hang instead of returning to the shell prompt. The user must press Ctrl+C to force-exit, which bypasses the worktree cleanup process, leaving orphaned worktrees and branches.

Steps to Reproduce

  1. Start Claude Code with worktree and tmux flags:

``bash
claude --worktree --tmux
``

  1. Work normally in the session
  2. Type /exit to quit
  3. Expected: Claude exits cleanly, prompts to keep/remove the worktree, and returns to the shell prompt
  4. Actual: The session hangs after /exit. No prompt appears. The tmux pane becomes unresponsive.
  5. Press Ctrl+C to force-exit

Impact

Each forced exit leaves behind:

  • An orphaned git worktree in .claude/worktrees/<random-name>
  • An orphaned git branch worktree-<random-name>

Over multiple sessions, these accumulate. In my case, 4 orphaned worktrees were left behind before I noticed.

Workaround

Manual cleanup after each session:

git worktree list
git worktree remove .claude/worktrees/<name> --force
git branch -D worktree-<name>

Environment

  • Claude Code CLI (latest as of 2026-02-20)
  • Linux (Ubuntu 24.04 kernel 6.17.0-14-generic)
  • tmux 3.x
  • Git 2.x

Notes

  • The issue does not occur without --tmux (worktree cleanup works correctly in a regular terminal)
  • The hang likely happens because the interactive worktree cleanup prompt doesn't interact correctly with the tmux terminal

View original on GitHub ↗

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