Preflight Checklist
What's Wrong?
When /clear is executed, a new session is created and the SessionStart hook runs correctly, writing to the new $CLAUDE_ENV_FILE. However, subsequent Bash tool calls
do not have access to the environment variables from this file - they still use the environment from the original session startup.
The docs state: "Claude Code will source this file before each Bash command, making the environment persistent across all commands."
- Hook runs correctly (verified via debug logs)
- New env file is created at new path: ~/.claude/session-env/{new-session-id}/hook-0.sh
- But Bash tool calls still use environment from original session startup
- New env file is never sourced
What Should Happen?
After /clear, $CLAUDE_SESSION_ID should reflect the new session ID (e.g., bbb-222) since:
- SessionStart hook runs with source: "clear"
- Hook writes new session ID to the new $CLAUDE_ENV_FILE
- Docs say env file is sourced before each Bash command
Error Messages/Logs
Steps to Reproduce
- Create a SessionStart hook that captures the session ID:
// hooks/hooks.json
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "echo \"export CLAUDE_SESSION_ID='$(echo | jq -Rr 'fromjson? | .session_id // empty' <<< \"$(cat)\")''\" >> \"$CLAUDE_ENV_FILE\""
}
]
}
]
}
}
- Start a fresh Claude Code session
- Run: echo $CLAUDE_SESSION_ID → outputs correct session ID (e.g., aaa-111)
- Run /clear command
- Run: echo $CLAUDE_SESSION_ID → still outputs old session ID aaa-111
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.0.72
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
I am using latest version of Ghostty terminal.
Preflight Checklist
What's Wrong?
When
/clearis executed, a new session is created and theSessionStarthook runs correctly, writing to the new$CLAUDE_ENV_FILE. However, subsequent Bash tool callsdo not have access to the environment variables from this file - they still use the environment from the original session startup.
The docs state: "Claude Code will source this file before each Bash command, making the environment persistent across all commands."
What Should Happen?
After /clear, $CLAUDE_SESSION_ID should reflect the new session ID (e.g., bbb-222) since:
Error Messages/Logs
Steps to Reproduce
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.0.72
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
I am using latest version of Ghostty terminal.