Skip to content

tenxhq/tenx-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Hooks

Rust toolkit for building hooks for Claude Code. Hooks are shell commands that execute at various points in Claude Code's lifecycle.

Crates

  • code-hooks: Core library for building Claude Code hooks
  • claude-transcript: Parse and analyze Claude conversation transcripts
  • hooktest: Test hooks during development
  • rust-hook: Example hook that formats and lints Rust code

Quick Start

use code_hooks::*;

fn main() -> Result<()> {
    let input = PreToolUse::read()?;
    
    if input.tool_name == "Bash" {
        if let Some(cmd) = input.tool_input.get("command").and_then(|v| v.as_str()) {
            if cmd.contains("rm -rf /") {
                return input.block("Dangerous command").respond();
            }
        }
    }
    
    input.approve("OK").respond()
}

Test with hooktest:

hooktest pretool --tool Bash --tool-input command="ls" -- ./my-hook

About

Anthropic's Claude Code hooks in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors