CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS
Updated by Alex Sorokoletov
CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS is a Claude Code environment variable: When set, enables emitting start and end hook events for user prompt submission; the value is read once and then cleared. Added in v2.1.311 and still present in v2.1.315. It is not in the official reference.
| Status | Present in v2.1.315 |
|---|---|
| Added | Added in v2.1.311 |
| Category | Other |
| Official docs | Not listed |
How to set it
For one session, export it in the shell that starts Claude Code:
export CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS=<value>
claudeTo apply it to every session, add it to the env object of a settings file:
// ~/.claude/settings.json
{
"env": {
"CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS": "<value>"
}
}Related variables
CLAUDE_CODE_APPEND_PROMPT_HEAD: Designates a prompt-head string that is validated for integrity before use and then cleared after a single read; an invalid value is ignored.CLAUDE_CODE_ATTACHMENTS_IN_USER_DATA: Off unless set.CLAUDE_CODE_CONFIG_WATCH_EVENTS: On Linux, when set, watches config files with filesystem events instead of interval polling; ignored on other platforms.CLAUDE_CODE_EMIT_STARTUP_TIMING: When set, emits startup timing phase metrics, which are also emitted in remote mode; otherwise they are not reported.CLAUDE_CODE_MESSAGES_PROMPT_CACHE_TTL: Set to 5m to force the messages prompt cache to a five-minute lifetime.CLAUDE_CODE_MORNING_BRIEF_PROMPT: Set a custom prompt for the morning brief; used when its trimmed length was within bounds, otherwise the default prompt applied.CLAUDE_CODE_PROMPT_CACHE_TTL: Sets the prompt cache TTL for the main conversation (interactive, -p, and SDK turns) to "5m" or "1h".CLAUDE_CODE_REMOVE_PROMPT_STRINGS: Takes a JSON array of strings that are stripped from the prompt before sending; falls back to the remove_prompt_strings client setting, and is ignored when it is not a valid list.
Frequently asked questions
What does CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS do?
When set, enables emitting start and end hook events for user prompt submission; the value is read once and then cleared.
Which Claude Code version has CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS?
Added in v2.1.311 and still present in v2.1.315.
How do I set CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS?
Export it before starting Claude Code (export CLAUDE_CODE_EMIT_USER_PROMPT_SUBMIT_HOOK_EVENTS=value), or add it to the "env" object in ~/.claude/settings.json to apply it to every session.
All variables, searchable: Claude Code environment variables.