[BUG] Bash tool breaks if claude rm's the current pwd

Resolved 💬 6 comments Opened Oct 9, 2025 by Keno Closed Jan 28, 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 claude removes the pwd of the bash tool while it's running, the bash tool irrecoverably breaks. This happened to me in a real session, but is easy to reproduce from scratch. Example session:

> create a directory, then cd into it, then delete it while it's the pwd and see if the 
bash tool is still working 

● I'll test what happens when we delete the current working directory from under the
  shell. Let me run this experiment:

● Bash(mkdir test_dir && cd test_dir && pwd)
  ⎿  /workspace/test_dir

● Now let me delete the directory while we're still inside it:

● Bash(rm -rf /workspace/test_dir)
  ⎿  Error: pwd: error retrieving current directory: getcwd: cannot access parent directories: 
     No such file or directory

● Interesting! The shell can't determine the current directory anymore. Let me test if the
   shell is still functional by running some commands:

● Bash(echo "Shell is still alive!" && ls -la)
  ⎿  Error: Error

● The shell appears to be in an error state. Let me try to recover by changing to a valid
  directory:

● Bash(cd /workspace && pwd && echo "Recovered!")
  ⎿  Error: Error

● The shell appears to be completely broken. Let me try one more simple command:

● Bash(whoami)
  ⎿  Error: Error

What Should Happen?

The bash tool should not break. In particular the agent should be allowed to cd out of the deleted directory.

Error Messages/Logs

Steps to Reproduce

See prompt above

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.11

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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