zsh shell snapshot drops user-defined _-prefixed functions that captured functions call -> command not found in Bash tool
Status Open
Reported on v2.1.274
Maintainer reply None cached
Activity 0 comments · opened Sep 23, 2026
Environment
- Claude Code 2.1.274, macOS, zsh
Bug
The zsh shell snapshot drops every function whose name starts with _, but keeps functions that call them. A user function that relies on a private _helper is captured, and calling it in the Bash tool fails with command not found: _helper. It works in the user's own terminal.
Evidence
- On this machine an interactive zsh defines 982
_-prefixed functions. The newest~/.claude/shell-snapshots/snapshot-zsh-*.shkeeps 1 of them (__arguments). - Real case:
.zshrcdefined wrappersgrok,codexand similar, each calling_infisical_wrap. The wrappers were in the snapshot and the helper was not. Every wrapper call inside Claude Code failed withcommand not found: _infisical_wrap, and the wrapper still exited 0, so agents read empty output as success. The fix was renaming the helper to drop the underscore.
Minimal repro (derived from the filter above; the real case is the evidence)
- In
~/.zshrc:_greet_helper() { echo hi; }andgreet() { _greet_helper; } - Start a new session, run
greetvia the Bash tool. command not found: _greet_helper
Expected
Filtering completion-system functions (_arguments, _git) makes sense. User-defined _ functions that a captured function references should be kept, for example by filtering on the function's source file (completion fpath) rather than the name prefix. At minimum, document the filter.