[BUG] CLAUDE_ENV_FILE variables not available in Bash on resumed sessions (--continue/--resume)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment variables written to CLAUDE_ENV_FILE during a SessionStart hook are available in Bash tool calls on fresh sessions, but not on resumed sessions (--continue, --resume, /resume).
The hook executes successfully in both cases — the env file is written with correct content — but the file is not re-sourced into the Bash environment on resume.
This was previously reported in #12418, which was auto-closed as a duplicate of #11649. However, #11649 is a different bug (plugins not receiving CLAUDE_ENV_FILE at all). The resume-session issue is a separate root cause and was not addressed by the fix for #11649.
What Should Happen?
Variables written to CLAUDE_ENV_FILE during SessionStart hooks should be available in all subsequent Bash tool calls, regardless of whether the session is fresh or resumed.
Error Messages/Logs
Fresh session:
$ echo $HOOK_TEST
hello_from_hook ← ✓ works
Resumed session:
$ echo $HOOK_TEST
← ✗ empty
The env file exists and has the correct content in both cases:
$ cat /Users/.../.claude/session-env/<session-id>/sessionstart-hook-0.sh
export HOOK_TEST=hello_from_hook
Steps to Reproduce
- Add a
SessionStarthook to.claude/settings.local.json:
``json``
{
"hooks": {
"SessionStart": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "echo 'export HOOK_TEST=hello_from_hook' >> \"$CLAUDE_ENV_FILE\""
}
]
}
]
}
}
- Start a fresh session:
claude - Run
echo $HOOK_TEST→ outputshello_from_hook✓ - Exit and resume:
claude --continue - Run
echo $HOOK_TEST→ outputs empty string ✗
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.119 (Claude Code)
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
- The
SessionStarthook runs on resume (confirmed by writing a debug log to/tmp). CLAUDE_PROJECT_DIRandCLAUDE_ENV_FILEare both available inside the hook during resume.- The env file is written correctly — the issue is that it's not sourced into the Bash tool environment after resume.
- #12418 was auto-closed as duplicate of #11649, but they are different bugs: #11649 was about
CLAUDE_ENV_FILEnot being set for plugin-installed hooks; this is about the env file not being sourced on resumed sessions regardless of hook source.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗