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§
- Hook
Handler - Hook handler configuration (matches Claude’s settings.json structure)
- List
Entry - Entry returned by list() function
- Matcher
Group - Matcher group in Claude Code hooks structure
- Registry
Entry - Registry entry (internal representation with metadata)
- Registry
Metadata - Subset of registry metadata for list output
Enums§
- Error
- Top-level error type
- Hook
Error - Hook logic errors
- Hook
Event - Claude Code hook events
- Registry
Error - Registry errors
- Settings
Error - 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