One of the main thing that upset me when using [[Claude Code]] is that its permissions are handled in a quite poor way, and it often blocks the agent's work when the command is too hard to interpret. One of the things that messes with command parsing is prepending env variables to override them during command execution. Furthermore, every tool call is executed in a different shell, so `export` will not work as expected. [[Claude Code]]'s shells run in non-interactive [[zsh]] shells; this means shell hooks like `direnv hook zsh` (which rely on `precmd`) never fire, so env vars set via `.envrc` won't propagate to them. So to work around this issue I decided to plug [[direnv]] to work in non-interactive [[zsh]] sessions as well. Use `direnv export zsh` in `~/.zshenv`; the only [[zsh]] config file sourced for **all** shell invocations (interactive, non-interactive, login, non-login): ```zsh # ~/.zshenv # direnv export for non-interactive shells (primarily Claude Code subagents) eval "$(direnv export zsh 2>/dev/null)" ``` Then in any project directory, create `.envrc` as usual and allow it: ```bash echo 'export MY_API_URL=http://localhost:3030' > .envrc direnv allow . ``` > [!Warning] Disclaimer > I have to admit: **I am not 100% sure of the implications on the day-to-day usage of [[zsh]]**, I can afford to be more relaxed making this decision since [[Fish Shell|fish]] is my daily driver.