CustomCondition

Protocol for user-defined hook conditions.

Usage

Source

CustomCondition()

Implement check to create arbitrary matching logic beyond the built-in condition types.

Example

class LargeFile(CustomCondition): … def check(self, evt: BaseHookEvent) -> bool: … return bool(evt.file and evt.file.path.stat().st_size > 1_000_000) … app.hook(Event.PreToolUse, only_if=[LargeFile()], message=“Large file”, block=True)