Environment
- Claude Code VSCode Extension (tested on v2.1.109+)
- Windows 11, Python 3.x
- Hook registered in
~/.claude/settings.json under hooks.UserPromptSubmit
Summary
A UserPromptSubmit hook that outputs valid {"additionalContext": "..."} JSON to stdout executes successfully but the content never reaches the model context. The same hook mechanism works as expected in CLI.
Reproduction
- Register a UserPromptSubmit hook in
settings.json:
"UserPromptSubmit": [{
"hooks": [{
"type": "command",
"command": "python path/to/hook.py",
"timeout": 10
}]
}]
- The hook script reads stdin JSON, builds context, outputs:
{"additionalContext": "Current time: 2026-04-16 16:28 ..."}
- Open VSCode, start a new Claude Code conversation
- Ask the model: "What startup context did you receive from hooks?"
- Model reports: none received
Evidence that the hook DID execute
- Hook writes a state file on successful execution → file exists with correct
session_id and timestamp
- Running the hook manually with
echo '{"session_id":"test"}' | python hook.py produces valid JSON output
- A second hook (
session_reset.py) registered on the same event also executes and writes its own state file
Evidence that additionalContext is NOT injected
- Model explicitly reports no startup context received
- No
<user-prompt-submit-hook> tag visible in conversation
- No time/memory/backlog content visible anywhere in model context
What works
- Hook triggering: ✅
- Hook script execution: ✅
- Hook stdout output (valid JSON with
additionalContext): ✅
- Stop hook blocking feedback (non-zero exit): ✅ (reaches model)
- CLAUDE.md loading: ✅
- MCP tool calls: ✅
What doesn't work
UserPromptSubmit hook additionalContext → model context: ❌
Expected behavior
Per Claude Code hooks documentation, additionalContext returned from a hook's stdout should be appended to the model's context for that turn. This works in CLI but not in the VSCode extension.
Environment
~/.claude/settings.jsonunderhooks.UserPromptSubmitSummary
A
UserPromptSubmithook that outputs valid{"additionalContext": "..."}JSON to stdout executes successfully but the content never reaches the model context. The same hook mechanism works as expected in CLI.Reproduction
settings.json:{"additionalContext": "Current time: 2026-04-16 16:28 ..."}Evidence that the hook DID execute
session_idand timestampecho '{"session_id":"test"}' | python hook.pyproduces valid JSON outputsession_reset.py) registered on the same event also executes and writes its own state fileEvidence that additionalContext is NOT injected
<user-prompt-submit-hook>tag visible in conversationWhat works
additionalContext): ✅What doesn't work
UserPromptSubmithookadditionalContext→ model context: ❌Expected behavior
Per Claude Code hooks documentation,
additionalContextreturned from a hook's stdout should be appended to the model's context for that turn. This works in CLI but not in the VSCode extension.