A Go binary that handles Claude Code hooks for validating and modifying tool usage. This tool makes it easy to write custom hooks as simple Go functions.
## Installation
```bash
go build -o hooks
./hooks install
```
This will configure your `~/.claude/settings.json` to use this binary for all hook events.
## Usage
### Writing Custom Hooks
Hooks are simple Go functions that follow this signature:
This hooks system automatically attaches Claude conversation context to git commits using [git notes](https://git-scm.com/docs/git-notes). When you run `git commit` commands, the system captures relevant conversation context and stores it alongside your commits.
### What Gets Stored
Each git note contains structured JSON data with:
- **Session ID**: Unique identifier for the Claude session
- **Timestamp**: When the commit was made
- **Conversation Excerpt**: Recent user prompts and tool interactions
- **Tools Used**: List of tools used during the conversation
- **Commit Context**: Details about the git command and output
- **Claude Version**: Which version of Claude created the commit
### Example Usage
Let's say you're working on a project and ask Claude to implement a feature:
```bash
# You: "Add user authentication to the login form"
# Claude uses various tools (Edit, Write, Bash) to implement the feature
# Then creates a commit:
git commit -m "Add user authentication with password validation
- Implement bcrypt password hashing
- Add login form validation
- Create user session management
- Add error handling for failed logins"
```
The hook automatically captures the conversation context and attaches it to the commit.
### Viewing Conversation Context
To view the conversation context attached to any commit:
"conversation_excerpt": "Recent user prompts:\n- Add user authentication to the login form\n- Make sure to use bcrypt for password hashing\n\nTool interactions:\n- Edit: components/LoginForm.jsx\n- Write: utils/auth.js\n- Bash: npm install bcrypt",
"tools_used": ["Edit", "Write", "Bash"],
"commit_context": "Git command: git commit -m 'Add user authentication with password validation'\nResult: [main abc1234] Add user authentication with password validation",
"claude_version": "claude-sonnet-4-20250514"
}
```
### Configuration
Customize the git notes behavior by creating `.claude/notes.json`: