[BUG] PreToolUse hooks with additionalContext not working in VSCode extension
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
PreToolUse hooks configured in .claude/settings.json do not deliver additionalContext to the model when running Claude Code via VSCode extension (Claude Agent SDK). The same hooks work correctly when tested manually via CLI.
Related Issues
#16114 - Notification hooks not working in VSCode extension
#8985 - "Notification" hook doesn't work in VS Code extension "native UI" mode
#13203 - PermissionRequest hook does not trigger in VSCode extension
What Should Happen?
Environment
Claude Code Version: Latest (January 2026)
Platform: VSCode Extension (Claude Agent SDK)
OS: Linux
Settings Location: .claude/settings.json (project-level)
Configuration
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "python3 \"$CLAUDE_PROJECT_DIR/.claude/hooks/check-codex-before-write.py\"",
"timeout": 10
}
]
}
]
}
}
Hook Script Output
The hook script outputs valid JSON with additionalContext:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"additionalContext": "[Codex Consultation Reminder] File path contains 'config' - likely a design decision. Consider consulting Codex CLI before making this change."
}
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce
Configure a PreToolUse hook in .claude/settings.json that returns additionalContext
Run Claude Code via VSCode extension
Trigger an Edit or Write tool call
Ask Claude if it received the hook's additionalContext
Expected Behavior
Claude should receive the additionalContext string from the hook and be able to acknowledge it received the information.
Actual Behavior
Hook script executes correctly when tested manually: echo '{"tool_input": {"file_path": "src/config.py"}}' | python3 .claude/hooks/check-codex-before-write.py → outputs correct JSON
Claude reports it did not receive any additionalContext from the hook
No error messages or warnings displayed
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.7
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
This appears to be part of a broader issue where the VSCode extension does not properly process hooks from settings files. Issue #16114 showed debug logs with Found 0 hook matchers in settings in VSCode while CLI correctly found the hooks.
The additionalContext feature for PreToolUse hooks was added in v2.1.9 (January 17, 2026), but it seems this feature may not be fully implemented in the VSCode extension environment.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗