Tool

Condition matching the current event’s tool name against a regex pattern.

Usage

Source

Tool(pattern)

Use in only_if or skip_if to filter hooks by which tool is being used.

Parameter Attributes

pattern: str

Example

hook(Event.PreToolUse, only_if=[Tool(“Bash|Execute”)], message=“…”, block=True)