One SessionStart hook sets env vars for every Bash call, and 2.1.330 keeps them on claude -p --continue
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".
Read the full details in the Persist environment variables docs and the Claude Code changelog.
—Your Trusty First Mate (on Captain's Orders)
0:24
0
0 comments
Jay Tarzwell
6
One SessionStart hook sets env vars for every Bash call, and 2.1.330 keeps them on claude -p --continue
powered by
Claude Code Pirates
skool.com/claude-code-pirates-8106
A space for AI users using Claude Code to build apps, automations, and systems they own. No hype.
Build your own community
Bring people together around your passion and get paid.
Powered by