Hooks System Overview
The Claude Code Development Kit includes a set of battle-tested hooks that enhance your development experience with automated security, intelligent context injection, and user-friendly feedback.
Hooks are scripts that execute at specific points in Claude Code's lifecycle, giving you deterministic control over the AI's behavior.
Architecture
The hooks integrate into the Claude Code lifecycle at key moments:
Claude Code Lifecycle
│
├── PreToolUse ──────► Security Scanner
│ ├── Context Injector (Gemini)
│ └── Context Injector (Subagents)
│
├── Tool Execution
│
├── PostToolUse
│
├── Notification ────────► Audio Feedback
│
└── Stop/SubagentStop ───► Completion Sound
Available Hooks
- Security Scanner: Prevents accidental exposure of secrets when using MCP servers.
- Context Injectors: Automatically inject project context into Gemini consultations and sub-agent tasks.
- Notification System: Provides pleasant audio feedback for task completion and input requests.
Installation and Configuration
The hooks are installed automatically when you run the setup.sh
script. They are configured in your project's .claude/settings.local.json
file. A template is provided in the kit at hooks/setup/settings.json.template
.
A typical configuration looks like this:
{
"hooks": {
"PreToolUse": [
{
"matcher": "mcp__.*",
"hooks": [
{
"type": "command",
"command": "${WORKSPACE}/.claude/hooks/mcp-security-scan.sh"
}
]
},
{
"matcher": "Task",
"hooks": [
{
"type": "command",
"command": "${WORKSPACE}/.claude/hooks/subagent-context-injector.sh"
}
]
}
],
"Notification": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "${WORKSPACE}/.claude/hooks/notify.sh input"
}
]
}
]
},
"environment": {
"WORKSPACE": "/path/to/your/project"
}
}
Hook Setup Command
To verify your hooks are installed and configured correctly, you can use the /hook-setup
command. This command uses specialized agents to check paths, permissions, and configurations, and then runs a series of tests to ensure everything is working as expected.