pub struct HookSpec {
pub tag: String,
pub command: HookCommand,
pub matcher: Matcher,
pub event: Event,
pub rules: Option<RulesBlock>,
pub script: Option<ScriptTemplate>,
pub friendly_name: Option<String>,
}Expand description
Everything an Integration needs to install a hook.
Build via HookSpec::builder. For fallible construction see
HookSpecBuilder::try_build.
Fields§
§tag: StringUnique identifier for the consumer of this library. Used to namespace
fenced markdown blocks, JSON entries, and per-tag filenames so multiple
CLIs can coexist without stomping each other. Must be ASCII alnum / _
/ -, non-empty.
command: HookCommandThe command the harness should execute.
Use HookSpecBuilder::command_program for the safe default. Raw shell
remains available through HookSpecBuilder::command_shell_unchecked
for callers that intentionally need shell syntax.
matcher: MatcherWhich tool calls the hook should match.
event: EventWhich lifecycle event to attach to.
rules: Option<RulesBlock>Optional markdown to inject into the harness’s rules/memory file
(e.g., ~/.claude/CLAUDE.md, ./.clinerules, ~/.gemini/GEMINI.md).
script: Option<ScriptTemplate>Optional script body for harnesses that delegate via a script file
(currently Gemini’s ~/.gemini/hooks/*.sh) or a TS plugin
(OpenCode, OpenClaw).
friendly_name: Option<String>Optional human-friendly display name for log/UI output. If absent the
integration’s display_name is used.