File: src/hooks/hook_executor.py:153-160
The executor sets CLAUDE_ENV_FILE (a per-fire ephemeral env file path) for SessionStart, Setup, and CwdChanged hooks, but per the in-code note:
the sourcing-and-applying loop (read the file back and apply exports to subsequent shells in the session) is a separate follow-up ticket.
TODO(ch12-followup): ticket #<TBD> — this issue is that ticket.
Impact: A hook script that writes export FOO=bar to "$CLAUDE_ENV_FILE" (the contract documented to hook authors) has no effect — the file is created and the path is set, but nothing reads it back. Hook authors cannot inject env vars into subsequent Bash tool calls, which is the documented purpose of the variable.
Fix sketch: After each hook fires for those three events, read CLAUDE_ENV_FILE, parse KEY=VAL lines (POSIX shell semantics — handle quoting), and merge into the session env that BashTool._build_subprocess_env consumes. Cover with a hook integration test that writes an export and asserts the next Bash tool call sees the variable.
File:
src/hooks/hook_executor.py:153-160The executor sets
CLAUDE_ENV_FILE(a per-fire ephemeral env file path) forSessionStart,Setup, andCwdChangedhooks, but per the in-code note:Impact: A hook script that writes
export FOO=barto"$CLAUDE_ENV_FILE"(the contract documented to hook authors) has no effect — the file is created and the path is set, but nothing reads it back. Hook authors cannot inject env vars into subsequent Bash tool calls, which is the documented purpose of the variable.Fix sketch: After each hook fires for those three events, read
CLAUDE_ENV_FILE, parseKEY=VALlines (POSIX shell semantics — handle quoting), and merge into the session env thatBashTool._build_subprocess_envconsumes. Cover with a hook integration test that writes an export and asserts the next Bash tool call sees the variable.