Shell snapshot filters _-prefixed functions, breaking dependent exported functions (GVM _encode/_decode)

Resolved 💬 5 comments Opened May 4, 2026 by tomi77 Closed May 21, 2026

Description

Claude Code's shell snapshot mechanism filters out shell functions whose names start with _. This causes breakage when exported functions (which are captured in the snapshot) internally call _-prefixed helpers (which are not captured).

Steps to Reproduce

  1. Install GVM (Go Version Manager)
  2. Source GVM in ~/.zshrc: [[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
  3. Open Claude Code and run any bash command that triggers a cd call

What Happens

GVM overrides the cd shell function. This override calls setValueForKeyFakeAssocArray (captured in snapshot), which in turn calls _encode/_decode (defined in ~/.gvm/scripts/function/_bash_pseudo_hash, filtered from snapshot).

Every bash command that causes a directory change produces:

setValueForKeyFakeAssocArray:27: command not found: _encode
valueForKeyFakeAssocArray:28: command not found: _decode

Root Cause

In ~/.claude/shell-snapshots/snapshot-zsh-*.sh, functions like setValueForKeyFakeAssocArray and valueForKeyFakeAssocArray are present (they don't start with _), but _encode and _decode — which they depend on — are absent because the snapshot capture filters all _-prefixed function names.

The snapshot files are consistently 6997 lines and do not contain a single ^_[a-z] function definition, confirming the filter is applied broadly.

Expected Behavior

The snapshot should either:

  • Follow function call dependencies and include _-prefixed functions that are called by captured functions, or
  • Not filter _-prefixed functions from the snapshot at all (they are legitimate shell functions, not internal shell builtins)

Impact

  • Stderr noise on every bash command involving cd
  • GVM's Go version auto-switching fails silently in Claude Code's bash context
  • Affects any user with shell setups where public functions depend on _-prefixed helpers (GVM, some zsh plugins, custom scripts)

Environment

  • macOS Darwin 25.4.0 (arm64)
  • Shell: zsh
  • GVM installed at ~/.gvm
  • Claude Code CLI

View original on GitHub ↗

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