{"version":"2.1.311","anchor":"env-var-opts-userpromptsubmit-hooks-into-hook-startedhook-r","canonical_anchor":"env-var-opts-userpromptsubmit-hooks-into-hook-startedhook-r","heading":"Opt in to start and end events for UserPromptSubmit hooks","tier":"use","area":"Hooks","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.311\/e\/env-var-opts-userpromptsubmit-hooks-into-hook-startedhook-r","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.311","markdown":"### Opt in to start and end events for `UserPromptSubmit` hooks\n\nSetting CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS makes Claude Code report when UserPromptSubmit hooks start and finish\n\n**Unclear.** What value the variable must be set to is not stated.\n\n**What**\n\nA 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.\n\nSetting 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.\n\nClaude Code reads the variable once when it starts and then removes it, so programs that Claude Code launches do not inherit it.\n\n**Why**\n\nPrograms 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.\n\n- Area: Hooks\n- Names: `UserPromptSubmit`, `hook_started`\n- Tier: Use it now\n- Useful: 4\/5\n- Signal: 2\/5\n- Scope: individual\n- Heads-up: no"}