Shell snapshots don't capture zsh chpwd_functions/precmd_functions arrays

Resolved 💬 2 comments Opened Jan 31, 2026 by sparklbarff Closed Mar 1, 2026

GitHub Issue for anthropics/claude-code

Title: Shell snapshots don't capture zsh chpwd_functions/precmd_functions arrays

Body:

Summary

Claude Code's shell snapshots don't capture zsh special arrays like chpwd_functions and precmd_functions, causing false positive warnings from tools that use these arrays (e.g., zoxide).

Environment

  • macOS 15.2 (Darwin 25.1.0)
  • zsh 5.9
  • zoxide 0.9.x
  • Claude Code (latest)

Steps to Reproduce

  1. Install zoxide with --cmd cd option in .zshrc:

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

  1. Run any command in Claude Code that triggers shell execution
  2. Observe warning:

``
zoxide: detected a possible configuration issue.
``

Root Cause Analysis

Claude Code creates shell snapshots (~/.claude/shell-snapshots/) that capture:

  • Functions (including zoxide's cd function)
  • Environment variables
  • Aliases

But the snapshots do not capture:

  • chpwd_functions array
  • precmd_functions array
  • Other special zsh arrays

When Claude Code runs commands:

  1. Snapshot is sourced (includes zoxide's cd function)
  2. chpwd_functions array is empty (not captured in snapshot)
  3. cd runs → zoxide's __zoxide_doctor checks if __zoxide_hook is in chpwd_functions
  4. Since array is empty, warning appears

This is a false positive - the cd functionality works, but zoxide's health check fails because it can't find its hook in the empty array.

Workaround

Users can disable zoxide's doctor check:

export _ZO_DOCTOR=0
eval "$(zoxide init zsh --cmd cd)"

Suggested Fix

Shell snapshots should preserve zsh special arrays, particularly:

  • chpwd_functions - hooks called when directory changes
  • precmd_functions - hooks called before each prompt
  • preexec_functions - hooks called before command execution

These arrays are used by many zsh tools and plugins beyond zoxide.

Impact

  • Cosmetic warning messages in Claude Code output
  • May confuse users into thinking their shell configuration is broken
  • Affects any tool using zsh hook arrays (zoxide, direnv, various oh-my-zsh plugins, etc.)

View original on GitHub ↗

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