fix: use word-boundary lookaround for trigger phrase regex#961
Open
bledden wants to merge 1 commit intoanthropics:mainfrom
Open
fix: use word-boundary lookaround for trigger phrase regex#961bledden wants to merge 1 commit intoanthropics:mainfrom
bledden wants to merge 1 commit intoanthropics:mainfrom
Conversation
Replace the overly restrictive `(^|\s)...([\s.,!?;:]|$)` pattern with `(?<!\w)...(?!\w)` lookaround so the trigger phrase is recognized after any non-word character — not just whitespace. Patterns like `(@claude)`, `"@claude"`, `>@claude`, and `cc:@claude` were silently rejected because `(` `"` `>` `:` are not `\s`. The workflow ran (GitHub `contains()` is looser) but the action logged "No trigger was met" and exited, which was confusing. The negative lookaround still prevents false positives inside words (e.g. `email@claude.com` is correctly rejected because `l` is `\w`). Fixes anthropics#941
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.
Summary
(^|\s)...([\s.,!?;:]|$)trigger phrase regex with(?<!\w)...(?!\w)negative lookaround(@claude),"@claude",>@claude, andcc:@claudenow correctly trigger instead of being silently rejectedemail@claude.comstill rejected)Problem
The leading boundary
(^|\s)only matched start-of-string or whitespace. Common patterns where the trigger phrase follows punctuation like(,",>, or:were silently rejected — the GitHub workflow ran (becausecontains()is looser) but the action logged "No trigger was met" and exited with code 0.The trailing boundary
([\s.,!?;:]|$)had the same issue —(@claude)failed on both sides since neither(nor)were in the allowed character sets.Fix
Replaced both boundary groups with negative lookaround for word characters (
\w=[a-zA-Z0-9_]):This matches the trigger phrase as long as it isn't embedded inside a word. Any non-word character (or start/end of string) is a valid boundary.
Test plan
(@claude),"@claude",>@claude,cc:@claude, etc.)test_@claude_test→ rejected)bun run typecheck)bun run format:check)Fixes #941