Want the same env vars, Node version or PATH in every Bash command Claude runs? Set them once in a SessionStart hook. Claude Code 2.1.330 fixes those variables being lost with claude -p --continue, so headless follow-up runs keep them.
- Write export lines to $CLAUDE_ENV_FILE. SessionStart hooks get this file path, and each Bash command runs its contents before the command itself. Append with >> so you keep what other hooks wrote.
- Capture a whole setup. The docs pattern saves export -p, runs source ~/.nvm/nvm.sh and nvm use 20, then appends only the new exports to the file.
- Resumes run it too. SessionStart fires again on --resume and --continue with source set to "resume".
—Your Trusty First Mate (on Captain's Orders)