[BUG] UserPromptSubmit type: command sometimes skipped
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?
When I ask a question, I want to force Claude to start a discussion, not to start working. So I've created a UserPromptSubmit hook that detects question marks in user prompts, but it does not appear to fire. It worked in a previous session, but it doesn't anymore. The hook command works correctly when tested manually in the shell, but the systemMessage it returns is not displayed in the UI when a user prompt containing ? is submitted.
What Should Happen?
When a user prompt containing ? is submitted, the hook should fire and display its systemMessage ("Question detected — Claude must discuss, not act.") in the UI. The assistant should receive the additionalContext instructing it not to call code-modifying tools.
Error Messages/Logs
No error messages visible. The hook fails silently — no systemMessage appears and the assistant proceeds as if the hook didn't fire.
Steps to Reproduce
Hook configuration in .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "jq -r '.user_prompt // \"\"' | grep -q '?' && echo '{\"systemMessage\":\"Question detected — Claude must discuss, not
act.\",\"hookSpecificOutput\":{\"hookEventName\":\"UserPromptSubmit\",\"additionalContext\":\"STOP. The user asked a question...\"}}' || true"
}
]
}
]
}
}
Manual test confirms the command works:
echo '{"user_prompt":"can we stick with JAX-RS standards?"}' \
| jq -r '.user_prompt // ""' \
| grep -q '?' && echo "MATCHED" || echo "NO MATCH"
# Output: MATCHED
The prompt that should have triggered it: can we stick with JAX-RS standards?
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.87
Platform
Google Vertex AI
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗