[BUG] Session crashes when worktree directory is deleted while Claude is operating inside it

Resolved 💬 4 comments Opened Mar 14, 2026 by fritzek Closed Apr 14, 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 a git worktree directory is removed (e.g. via git worktree remove or manually) while Claude Code has that directory as its active working directory, the session crashes instead of recovering gracefully.

Actual behavior:

The session terminates. Any in-session context that was not yet persisted to memory or a file is lost. The user must start a new session.

Workaround:

Avoid using worktrees entirely and always work from the main repository root.

Environment:

OS: macOS
Shell: zsh

What Should Happen?

Expected behavior:

Claude should detect that the working directory no longer exists and either fall back to the main repository root or surface a clear error — without crashing the session.

Error Messages/Logs

Ordner existiert nicht mehr. Bitte starte eine neue Sitzung.

(Sorry, don't know the English version)

Steps to Reproduce

Steps to reproduce:

  1. Start a Claude Code session in a worktree (e.g. via EnterWorktree)
  2. Delete the worktree directory (e.g. git worktree remove <name> from another terminal, or Claude itself removes it via ExitWorktree)
  3. Claude attempts any file-system tool call (Bash, Read, Glob, Grep, etc.) targeting the now-deleted path

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.74 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

The error happens in the Claude desktop app in the code tab

View original on GitHub ↗

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