[BUG] Shell snapshot corruption on Windows MSYS/Git Bash - base64 data interpreted as commands

Resolved 💬 3 comments Opened Mar 4, 2026 by anujpatel03 Closed Mar 7, 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?

On Windows with Git Bash (MSYS2), Claude Code's shell snapshot mechanism produces corrupted snapshot files in ~/.claude/shell-snapshots/. The snapshots contain base64-encoded data from Git Bash completion scripts that gets interpreted as shell commands when sourced via BASH_ENV.

Every Bash tool invocation produces ~950 lines of "command not found" errors (~172KB of error output) before the actual command output. The corruption is self-perpetuating — each new shell sources the corrupted snapshot, gets a corrupted environment, then saves a new corrupted snapshot.

Deleting ~/.claude/shell-snapshots/ does not help because Claude Code immediately recreates a new corrupted snapshot on the next Bash tool call.

What Should Happen?

Shell snapshots should correctly serialize and deserialize the bash environment on MSYS/Git Bash without errors. Bash tool invocations should show only the actual command output, not hundreds of lines of snapshot sourcing errors.

Error Messages/Logs

/c/Users/<user>/.claude/shell-snapshots/snapshot-bash-1772605787698-baif0c.sh: line 13: il: command not found
/c/Users/<user>/.claude/shell-snapshots/snapshot-bash-1772605787698-baif0c.sh: line 51: naXRrKQogICAgICAg: command not found
/c/Users/<user>/.claude/shell-snapshots/snapshot-bash-1772605787698-baif0c.sh: line 52: ICAgICAgICAgICAgIGN1cj0iZ2l0ayI7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsKICAgICAg: command not found
/c/Users/<user>/.claude/shell-snapshots/snapshot-bash-1772605787698-baif0c.sh: line 53: ICAgICAgICAgIDs7CiAgICAgICAgICAgICAgICBcISopCiAgICAgICAgICAgICAgICAgICAgOiBz: command not found
/c/Users/<user>/.claude/shell-snapshots/snapshot-bash-1772605787698-baif0c.sh: line 54: aGVsbCBjb21tYW5kIGFsaWFzCiAgICAgICAgICAgICAgICA7OwogICAgICAgICAgICAgICAgLSop: command not found
... (~950 lines of similar errors per Bash tool invocation)
/c/Users/<user>/.claude/shell-snapshots/snapshot-bash-1772605787698-baif0c.sh: line 1112: syntax error near unexpected token `fi'
/c/Users/<user>/.claude/shell-snapshots/snapshot-bash-1772605787698-baif0c.sh: line 1112: `fi'

Steps to Reproduce

  1. Install Claude Code on Windows with Git Bash (MSYS2) as the default shell
  2. Open Claude Code in VS Code integrated terminal
  3. Run any Bash tool command (e.g., ask Claude to run echo "hello")
  4. Observe ~950 lines of "command not found" errors in the output before the actual result
  5. Check ~/.claude/shell-snapshots/ — the snapshot file contains base64 fragments as raw shell lines
  6. Delete the snapshots directory: rm -rf ~/.claude/shell-snapshots/
  7. Run another Bash tool command — a new corrupted snapshot is immediately created and the errors return

Root cause: The snapshot serializer captures Git Bash completion functions (git-completion.bash) which contain data that gets incorrectly encoded, producing base64-like fragments as raw shell lines. When sourced, these fragments are interpreted as commands.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.66 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

Shell: Git Bash (MSYS_NT-10.0-26200 3.6.3-1f8def9f.x86_64)

Impact:

  • Functional: Commands still execute correctly (exit codes are accurate)
  • Performance: ~172KB of error output per Bash invocation that must be processed
  • UX: Tool result previews show errors instead of actual output

Attempted workarounds that DON'T persist:

  • rm -rf ~/.claude/shell-snapshots/ (recreated immediately)
  • Deleting individual snapshot files (same result)

Workarounds that help (outside Claude Code session):

  • Replace directory with a file: rm -rf ~/.claude/shell-snapshots && touch ~/.claude/shell-snapshots
  • Make directory read-only: rm -rf ~/.claude/shell-snapshots && mkdir ~/.claude/shell-snapshots && chmod 444 ~/.claude/shell-snapshots

Suggestions:

  1. Add a setting to disable shell snapshots (e.g., "shellSnapshots": false)
  2. Skip snapshot creation/restoration on MSYS/Git Bash
  3. Properly handle Git Bash completion scripts during serialization
  4. Gracefully fall back when snapshot sourcing produces errors

View original on GitHub ↗

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