What's wrong with this entry?
Anonymous. No account, no email.
What
Hooks now support an if field that uses permission rule syntax to filter when the hook runs, avoiding unnecessary hook execution for non-matching commands.
Usage
{
"hooks": {
"PreToolUse": [{
"if": "Bash(git *)",
"command": "my-git-hook.sh"
}]
}
}Details
- The
iffield 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
ifcondition 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")
Strings lifted out of the shipped bundle, so the claim above can be checked against them.