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-*.sh keeps 1 of them (__arguments).
  • Real case: .zshrc defined wrappers grok, codex and similar, each calling _infisical_wrap. The wrappers were in the snapshot and the helper was not. Every wrapper call inside Claude Code failed with command 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)

  1. In ~/.zshrc: _greet_helper() { echo hi; } and greet() { _greet_helper; }
  2. Start a new session, run greet via the Bash tool.
  3. 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.

View original on GitHub ↗