When Anthropic's Claude Code source leaked last week (510K lines via an npm source map accident), most people focused on the daemon modes, pet systems, and undercover features.
The funniest discovery was in userPromptKeywords.ts:
/\b(wtf|wth|ffs|shit(ty)?|dumbass|horrible|awful|
piss(ed|ing)? off|piece of (shit|crap)|what the (fuck|hell)|
fucking? (broken|useless|terrible)|fuck you|screw (this|you)|
so frustrating|this sucks|damn it)\b/
A regex. Not a neural network. Not a fine-tuned sentiment classifier. Not even a call to their own API.
Why This Is Actually Smart
Think about what frustration detection needs to do:
- Run on every single user message
- Return instantly (before the LLM response starts)
- Be cheap (millions of executions per day)
- Be reliable enough to trigger a tone shift
| Approach | Latency | Cost | Accuracy |
|---|---|---|---|
| Regex | <1ms | Free | Good enough |
| Classifier | 50-200ms | ~$0.001/call | Better |
| LLM inference | 500-2000ms | ~$0.01/call | Best |
Nobody types "what the fuck" calmly. If you're writing "this sucks" at your terminal, the regex has correctly identified your emotional state.
What Happens When It Fires
The detection feeds into response tone adaptation:
- Shorter, more direct responses
- Fewer explanations of what went wrong
- More focus on "here's the fix"
- Less "I apologize for the confusion"
When you're angry, Claude stops being a chatbot and starts being a mechanic.
The Lesson
The best engineering isn't always the most sophisticated. A regex runs in microseconds, costs nothing, and catches the cases that matter.
We built an open-source version for OpenClaw with four severity levels and CAPS LOCK rage detection:
bash frustration-detect.sh "why the fuck isn't this working"
# → {"level": "high", "triggers": ["fuck", "isn't working"], "caps_rage": false}
30 lines of bash. No API key required. Sometimes regex is all you need.
Top comments (0)