NAME
Claude::Agent::Hook::Matcher - Hook matcher for Claude Agent SDK
DESCRIPTION
Defines a hook matcher that triggers callbacks for specific tools.
ATTRIBUTES
matcher - Optional regex pattern to match tool names
hooks - ArrayRef of callback coderefs
timeout - Timeout in seconds (default: 60)
CALLBACK SIGNATURE
sub callback {
my ($input_data, $tool_use_id, $context) = @_;
# $input_data contains:
# - tool_name: Name of the tool
# - tool_input: Input parameters for the tool
# $context contains:
# - session_id: Current session ID
# - cwd: Current working directory
# Return hashref with decision:
return {
decision => 'continue', # or 'allow', 'deny'
reason => 'Optional reason',
# For 'allow', can include:
updated_input => { ... },
};
}
METHODS
matches
my $bool = $matcher->matches($tool_name);
Check if this matcher matches the given tool name.
run_hooks
my $results = $matcher->run_hooks($input_data, $tool_use_id, $context);
Run all hooks and return their results.
AUTHOR
LNATION, <email at lnation.org>
LICENSE
This software is Copyright (c) 2026 by LNATION.
This is free software, licensed under The Artistic License 2.0 (GPL Compatible).