[Bug Fix] UserPromptSubmit frustration-trigger fires on every message, not just frustration keywords#130
Open
tz5514 wants to merge 2 commits intotanweai:mainfrom
Open
Conversation
…cher UserPromptSubmit does not support the matcher field in Claude Code hooks. The matcher is silently ignored, causing the hook to fire unconditionally. Fix: read the user prompt from stdin and perform keyword matching in the script itself before deciding whether to inject the PUA activation message.
Claude Code silently ignores matcher for UserPromptSubmit events. Keyword filtering is now handled inside frustration-trigger.sh instead.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
`frustration-trigger.sh` currently fires on every single user message, including neutral messages like "hi". The `matcher` field in `hooks.json` was intended to filter this, but it has no effect.
Root Cause
Per the official Claude Code hooks documentation:
The `matcher` field only works for tool-based events (`PostToolUse` etc.) where it filters by tool name. For `UserPromptSubmit`, there is no built-in content filtering — the hook script must handle it.
Fix
Move keyword matching into `frustration-trigger.sh`. The script reads the user's prompt from stdin (Claude Code passes `{"prompt": "..."}` as JSON) and exits silently if no frustration keywords are found.
Result
Verified: Claude Code passes `{"prompt": "...", "session_id": "...", ...}` to `UserPromptSubmit` hooks via stdin.