Shell snapshot breaks zoxide cd wrapper - __zoxide_z not found

Resolved 💬 8 comments Opened Jan 23, 2026 by ryanschneider Closed Mar 8, 2026

Description

When using zoxide with the --cmd cd option (which replaces the cd command), Claude Code's shell snapshot captures the cd function wrapper but not the underlying __zoxide_z function, resulting in a broken cd command.

Environment

  • macOS (Darwin 24.6.0)
  • zsh
  • zoxide installed via cargo

zoxide configuration

In ~/.zshrc:

eval "$(zoxide init --cmd cd zsh)"

This creates a cd function that wraps __zoxide_z:

cd () {
    __zoxide_z "$@"
}

Observed behavior

When running cd ../ in Claude Code:

zsh: command not found: __zoxide_z

Investigation

  1. type cd shows: cd is a shell function from /Users/.../.claude/shell-snapshots/snapshot-zsh-....sh
  2. type __zoxide_z shows: __zoxide_z not found
  3. The snapshot file contains the cd wrapper function but not the __zoxide_z function it depends on

Workaround

Using builtin cd bypasses the broken wrapper and works correctly.

Suggested fix

The shell snapshot logic should either:

  1. Capture all zoxide-related functions (__zoxide_z, __zoxide_zi, __zoxide_hook, etc.) when it captures the cd wrapper
  2. Not capture function-based cd overrides
  3. Re-run eval "$(zoxide init ...)" when loading the snapshot to regenerate the required functions
  4. Detect and skip functions that reference undefined dependencies

View original on GitHub ↗

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