claude-code - 💡(How to fix) Fix [Feature Request] Support OR syntax in hooks[].if field like matcher [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49629Fetched 2026-04-17 08:35:46
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Code Example

[]
RAW_BUFFERClick to expand / collapse

Bug Description

Title: hooks[].if field should support OR syntax like matcher

Body:

▎ The matcher field supports OR syntax (e.g., "Write|Edit"), but the if field only accepts a single permission rule pattern. ▎ ▎ When you need to run the same hook for multiple conditions (e.g., Bash(git *) OR Bash(npm *)), you're forced to duplicate the entire hook entry — one per condition. ▎ ▎ Request: Support OR syntax in if, e.g.: ▎ "if": "Bash(git *)|Bash(npm *)"


Environment Info

  • Platform: win32
  • Terminal: null
  • Version: 2.1.112
  • Feedback ID: 818b87c8-bd08-4da9-80e0-0cb38a418606

Errors

[]

extent analysis

TL;DR

The if field in hooks may need to support OR syntax to avoid duplicating hook entries for multiple conditions.

Guidance

  • Review the current implementation of the if field to determine if it can be modified to support OR syntax, similar to the matcher field.
  • Consider adding a feature request to the project's issue tracker to support OR syntax in the if field, providing examples of use cases that would benefit from this functionality.
  • If possible, explore alternative solutions that do not require modifying the if field, such as using a separate hook for each condition or utilizing a different configuration option.

Notes

The issue lacks information about the specific code or configuration files involved, making it difficult to provide a more detailed solution.

Recommendation

Apply workaround: Until the if field supports OR syntax, consider duplicating hook entries for each condition or exploring alternative configuration options.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [Feature Request] Support OR syntax in hooks[].if field like matcher [1 participants]