Skip to main content

Crate claude_hooks

Crate claude_hooks 

Source
Expand description

Programmatic management of Claude Code hooks

This crate provides a library API to install, uninstall, and list hooks in Claude Code’s settings.json with atomic safety guarantees and ownership tracking.

§Platform Support

  • macOS: Supported
  • Linux: Supported
  • Windows: Not supported in v0.1 (deferred to v0.2+)

§Scope Limitations (v0.1)

  • User scope only (~/.claude/settings.json)
  • No multi-scope support (user/project/local)
  • Library-only (no CLI binary)

§Examples

use claude_hooks::{HookEvent, HookHandler, install};

let handler = HookHandler {
    r#type: "command".to_string(),
    command: "/path/to/stop.sh".to_string(),
    timeout: Some(600),
    r#async: None,
    status_message: None,
};

install(HookEvent::Stop, handler, None, "acd")?;

Structs§

HookHandler
Hook handler configuration (matches Claude’s settings.json structure)
ListEntry
Entry returned by list() function
MatcherGroup
Matcher group in Claude Code hooks structure
RegistryEntry
Registry entry (internal representation with metadata)
RegistryMetadata
Subset of registry metadata for list output

Enums§

Error
Top-level error type
HookError
Hook logic errors
HookEvent
Claude Code hook events
RegistryError
Registry errors
SettingsError
Settings file errors

Functions§

install
Install a hook for the specified event.
list
List all hooks from settings.json with management status.
uninstall
Uninstall a hook for the specified event and command.

Type Aliases§

Result
Result type alias for claude-hooks operations