Skip to content

CLAUDE_ENV_FILE is set for SessionStart/Setup/CwdChanged hooks but the source-and-apply cycle is not implemented #281

Description

@ericleepi314

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions