[BUG] UserPromptSubmit hooks in plugins not injecting context to agent
[BUG] UserPromptSubmit hooks in plugins not injecting context to agent
Description
UserPromptSubmit hooks defined in plugin hooks/hooks.json files are registered correctly but their stdout output is not injected into the agent's context. The same hook configuration works perfectly when defined in ~/.claude/settings.json.
Steps to Reproduce
- Create a plugin with UserPromptSubmit hook:
// wiz/hooks/hooks.json
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/test-hook.js"
}
]
}
]
}
}
- Create test script:
// wiz/scripts/test-hook.js
#!/usr/bin/env node
console.log('🔔 TEST HOOK EXECUTED');
process.exit(0);
- Install plugin:
ln -s /path/to/wiz ~/.claude/plugins/wiz
- Submit any prompt in Claude Code
- Ask Claude: "Did you see a message TEST HOOK EXECUTED in your context?"
Expected Behavior
Hook should execute and stdout should be injected into Claude's context, visible to the agent.
Actual Behavior
- Hook is registered (shows in
/hookscommand) - Hook does NOT execute OR output is not captured
- Claude responds: "No, I did not see that message"
Workaround
Moving the same hook configuration to ~/.claude/settings.json works correctly:
// ~/.claude/settings.json
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "node /Users/username/.claude/plugins/wiz/scripts/test-hook.js"
}
]
}
]
}
}
With this configuration, the hook executes and Claude sees the output in context.
Environment
- OS: macOS (Darwin 25.2.0)
- Claude Code version: [check with
claude --version] - Plugin location:
~/.claude/plugins/wiz/
Related Issues
- #10225 - UserPromptSubmit hooks from plugins match but never execute
- #12151 - Plugin hook output not captured or passed to agent
Impact
This prevents plugins from using UserPromptSubmit hooks for context injection, forcing users to manually configure hooks in their settings.json files, which defeats the purpose of distributable plugins.
Test Case Repository
Full reproduction test case available at: https://github.com/Lansweeper/wiz-agents
See:
wiz/hooks/hooks.json- Hook configurationwiz/scripts/story-verification-hook.js- Hook script
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗