Answer: Pass a filter (called a matcher) as the second argument to `on`; it's an object whose fields are compared with the event's, and the hook runs only when every field matches. A field can be a value, an array of allowed values, or a regular expression. Status: Confirmed Entry: tool/claude-code/agents-and-automation/filter-hook-events Revision: 4 Digest: sha256:234ca9ecfb31b6d8 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:05:13Z Last changed: 2026-11-20T12:23:38Z (plugin matcher: — → { plugin: 'other-mod' }) Last verified: 2026-11-20T12:23:38Z Next check: 2026-11-21T12:23:38Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of method | pass a filter as the second argument to `on` | [1] | 2026-11-20 matcher definition | an object whose fields are compared with the event's | [1] | 2026-11-20 allowed field types | a value, an array of allowed values, or a regular expression | [1] | 2026-11-20 string example | { tool: 'Bash' } | [1] | 2026-11-20 array example | { tool: ['Edit', 'Write'] } | [1] | 2026-11-20 regex example | { tool: /^mcp__github__/ } | [1] | 2026-11-20 wildcard event | 'classic.*' | [1] | 2026-11-20 plugin matcher | { plugin: 'other-mod' } | [1] | 2026-11-20 Sources: [1] Anthropic. "React to events with a mod". https://code.claude.com/docs/en/plugins/mods/events.md Role: primary. Accessed: 2026-11-20T12:23:38Z Quote: "pass a filter as the second argument to `on`" (Supports: method) Quote: "It's an object whose fields are compared with the event's, and the hook runs only when every field matches." (Supports: matcher definition) Quote: "A field can be a value, an array of allowed values, or a regular expression." (Supports: allowed field types) Quote: "on('tool.call', { tool: 'Bash' }, hook)" (Supports: string example) Quote: "on('tool.call', { tool: ['Edit', 'Write'] }, hook)" (Supports: array example) Quote: "on('tool.call', { tool: /^mcp__github__/ }, hook)" (Supports: regex example) Quote: "The event name can be a wildcard. `'classic.*'` matches every" (Supports: wildcard event) Quote: "Use the mod's name without its marketplace, as in `{ plugin: 'other-mod' }`, or `{ plugin: '*' }` for every mod." (Supports: plugin matcher) Published: 2026-11-20T03:41:00Z Snapshot SHA-256: b1a98246633f1352cfea4789628969e972a9fdb0b126114925ff98a69a589326 (captured 2026-11-20T12:23:39Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:23:38Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:23:38Z Last attempt: 2026-11-20T12:23:38Z Notes and limitations: Extracted automatically from a single official source (section "Filter which events a hook handles"). Related: https://latestn.com/tool/claude-code/agents-and-automation/fork-session How do I fork a Claude Code SDK session to explore alternative approaches? https://latestn.com/tool/claude-code/agents-and-automation/free-text-input-responses How do I support free-text input for Claude Code clarifying question responses? https://latestn.com/tool/claude-code/agents-and-automation/goal-evaluation How does Claude Code evaluate whether a goal is met, and what happens when a turn fails? https://latestn.com/tool/claude-code/agents-and-automation/enable-file-checkpointing How do I enable file checkpointing in the Claude Code Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/enable-streaming-output How do I enable streaming output in the Claude Code Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/enforce-rules-with-hooks How do I enforce rules that can't have exceptions in Claude Code using hooks? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:23:38Z | changed | plugin matcher: — → { plugin: 'other-mod' } | [1] 2026-11-20T12:23:38Z | changed | method: — → pass a filter as the second argument to `on` | [1] 2026-11-20T12:23:38Z | changed | wildcard event: '*' → 'classic.*' | [1] 2026-11-20T12:23:38Z | changed | mechanism: pass a filter as the second argument to `on` → — | [1] 2026-11-17T12:29:21Z | changed | mechanism: — → pass a filter as the second argument to `on` | [1] 2026-11-17T12:29:21Z | changed | method: pass a filter as the second argument to `on` → — | [1] 2026-11-14T12:19:22Z | changed | wildcard event: — → '*' | [1] 2026-11-14T12:19:22Z | changed | regex example: — → { tool: /^mcp__github__/ } | [1] 2026-11-14T12:19:22Z | changed | array example: — → { tool: ['Edit', 'Write'] } | [1] 2026-11-14T12:19:22Z | changed | string example: — → { tool: 'Bash' } | [1] 2026-11-14T12:19:22Z | changed | method: — → pass a filter as the second argument to `on` | [1] 2026-11-14T12:19:22Z | changed | registration rule: Register each event once per matcher. → — | [1] 2026-11-14T12:19:22Z | changed | regex match example: on('tool.call', { tool: /^mcp__github__/ }, hook) → — | [1] 2026-11-14T12:19:22Z | changed | array match example: on('tool.call', { tool: ['Edit', 'Write'] }, hook) → — | [1] 2026-11-14T12:19:22Z | changed | string match example: on('tool.call', { tool: 'Bash' }, hook) → — | [1] 2026-11-14T12:19:22Z | changed | allowed field types: A field can be a value, an array of allowed values, or a regular expression. → a value, an array of allowed values, or a regular expression | [1] 2026-11-14T12:19:22Z | changed | matcher definition: It's an object whose fields are compared with the event's, and the hook runs only when every field matches. → an object whose fields are compared with the event's | [1] 2026-11-14T12:19:22Z | changed | filter argument: pass a filter as the second argument to `on` → — | [1] 2026-11-13T03:05:13Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/filter-hook-events/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/filter-hook-events POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/filter-hook-events with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/filter-hook-events?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I filter which events a Claude Code mod hook handles? Revision 4, last verified 2026-11-20T12:23:38Z. https://latestn.com/tool/claude-code/agents-and-automation/filter-hook-events (accessed 2026-11-21T09:59:10Z). @misc{LatestN_tool_claude_code_agents_and_automation_filter_hook_events_r4, title = {How do I filter which events a Claude Code mod hook handles?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/filter-hook-events}}, note = {Revision 4; digest sha256:234ca9ecfb31b6d8; last verified 2026-11-20T12:23:38Z; accessed 2026-11-21T09:59:10Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/filter-hook-events