Skip to content

[Bug Fix] UserPromptSubmit frustration-trigger fires on every message, not just frustration keywords#130

Open
tz5514 wants to merge 2 commits intotanweai:mainfrom
tz5514:fix/frustration-trigger-keyword-filter
Open

[Bug Fix] UserPromptSubmit frustration-trigger fires on every message, not just frustration keywords#130
tz5514 wants to merge 2 commits intotanweai:mainfrom
tz5514:fix/frustration-trigger-keyword-filter

Conversation

@tz5514
Copy link
Copy Markdown

@tz5514 tz5514 commented Apr 4, 2026

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:

`UserPromptSubmit` don't support matchers and always fire on every occurrence. If you add a `matcher` field to these events, it is silently ignored.

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

  • Neutral messages → no injection, no wasted tokens
  • Messages with frustration keywords → PUA activation fires as intended

Verified: Claude Code passes `{"prompt": "...", "session_id": "...", ...}` to `UserPromptSubmit` hooks via stdin.

tz5514 added 2 commits April 5, 2026 03:09
…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.
@tz5514 tz5514 changed the title fix: frustration-trigger fires on every message, not just frustration keywords [Bug Fix] UserPromptSubmit frustration-trigger fires on every message, not just frustration keywords Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant