{"version":"2.1.85","anchor":"hook-conditional-filtering-via-if-field","canonical_anchor":"hook-conditional-filtering-via-if-field","heading":"Hook Conditional Filtering via if Field","tier":null,"area":null,"scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.85\/e\/hook-conditional-filtering-via-if-field","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.85","markdown":"### Hook Conditional Filtering via `if` Field\n\n**What**\n\nHooks now support an `if` field that uses permission rule syntax to filter when the hook runs, avoiding unnecessary hook execution for non-matching commands.\n\n**Usage**\n\n`{ \"hooks\": { \"PreToolUse\": [{ \"if\": \"Bash(git *)\", \"command\": \"my-git-hook.sh\" }] } }` **Details** - The `if` field accepts permission rule syntax (e.g., `\"Bash(git *)\"`) - Hooks only fire when the tool call matches the pattern - Non-matching tool calls skip the hook entirely: \"Skipping hook due to if condition not matching\" - If the `if` condition cannot be evaluated for non-tool events, a diagnostic is logged - When a hook's condition is satisfied, interaction results are tracked (including deny rule overrides and ask rule prompts) **Evidence** Hook schema description (search for `\"Permission rule syntax to filter when this hook runs\"`)"}