Follow Discord
Sweep 27 Oct 2026 · 19:04Z Build v2.1.312 531 read Stable v2.1.308 Latest v2.1.312 Next v2.1.312 Feeds RSS JSON llms.txt llms-full.txt Unofficial

Claude Code v2.1.311 ·

Opt in to start and end events for UserPromptSubmit hooks

Setting CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS makes Claude Code report when UserPromptSubmit hooks start and finish

Use it now New Features
JSON All of v2.1.311
Use it nowTier: how much it should matter to you
4Useful: my rating, 1 to 5
2Signal: worth watching, 1 to 5
HooksArea: what it touches
New FeaturesKind: in v2.1.311,
What probably matters to youSection of the release

Unclear What value the variable must be set to is not stated.

What

A hook is a command you configure to run automatically at a set point. A UserPromptSubmit hook runs when a prompt is submitted, before Claude processes it. Claude Code can send messages saying when a hook starts (hook_started) and when it responds, but until now it did not send them for UserPromptSubmit hooks.

Setting the new environment variable CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS turns these start and end messages on for UserPromptSubmit. Whether they are sent for other hook types is decided separately.

Claude Code reads the variable once when it starts and then removes it, so programs that Claude Code launches do not inherit it.

Why

Programs that drive Claude Code and read its output stream, such as ones built with the Agent SDK, can now see when a UserPromptSubmit hook begins and ends, but only if they set this variable.

Read from
Names in the bundleUserPromptSubmithook_started
What the documentation says
Since it was published

The entry above is what we published on the day. These lines were added later, as Anthropic's own pages caught up, and they sit beside the original rather than replacing it.

Confirmed since Anthropic's documentation has since written up hook_started, on Agent SDK reference - TypeScript. Of the [`hook_progress`](#sdkhookprogressmessage) messages a `SessionStart` or `Setup` hook emits before the handshake completes, you get only the newest, which carries all of the hook's output so far. `startup()` holds that message, the h… agent-sdk/typescript see the edit
How sure we are
Something disagreesSomething we can check disagrees with this entry, or the writer said they could not settle it.
The writer flagged doubtWhat value the variable must be set to is not stated.
Anthropic's documentation agreesAnthropic's documentation has since written up hook_started, on Agent SDK reference - TypeScript.

See this entry in the whole of v2.1.311 →

Feedback