A community-driven registry for the Claude Code ecosystem. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Type-safe hook system with auto-completion and strongly-typed payloads
TypeScript-powered hook system for Claude Code - write hooks with full type safety and auto-completion
claude-hooks gives you a powerful, TypeScript-based way to customize Claude Code's behavior. Write hooks with full type safety, auto-completion, and access to strongly-typed payloads - all in familiar TypeScript syntax. No more guessing payload structures or dealing with untyped data!
npx claude-hooks
This will:
.claude/settings.json with hook configuration.claude/hooks/index.ts with TypeScript handlersnpx claude-hooks
npm install -g claude-hooks
claude-hooks
The CLI sets up a complete TypeScript development environment for Claude hooks:
.claude/settings.json - Hook configuration.claude/hooks/index.ts - Your main hook handlers (edit this!).claude/hooks/lib.ts - Type definitions and utilities.claude/hooks/session.ts - Optional session tracking utilities.claude/
├── settings.json
└── hooks/
├── index.ts
├── lib.ts
└── session.ts
Session logs are saved to: <system-temp-dir>/claude-hooks-sessions/
The real power comes from editing .claude/hooks/index.ts. You get full TypeScript support with typed payloads:
// Example: Track and log specific tool usage
async function preToolUse(payload: PreToolUsePayload): Promise<HookResponse> {
// Full type safety - TypeScript knows exactly what's in the payload!
if (payload.tool_name === 'Write' && payload.tool_input) {
const { file_path, content } = payload.tool_input as WriteToolInput
console.log(`Claude is writing to: ${file_path}`)
// Add your custom logic here
// Maybe notify a webhook, update a dashboard, etc.
}
return { action: 'continue' }
}
// Example: React to completed tasks
async function postToolUse(payload: PostToolUsePayload): Promise<void> {
if (payload.tool_name === 'Bash' && payload.success) {
// TypeScript gives you auto-completion for all payload properties!
console.log(`Command completed: ${payload.tool_input.command}`)
}
}
The beauty is that you're writing regular TypeScript - use any npm packages, async/await, or patterns you're familiar with!
claude-hooks init [OPTIONS]
OPTIONS:
-f, --force Overwrite existing hooks
-h, --help Show help
curl -fsSL https://bun.sh/install | bash
MIT
Give Claude Code memory that evolves with your codebase via hooks and LLM-compiled knowledge
Security hooks with SSRF protection, MCP compression, and OpenTelemetry tracing
Context management with hooks for state via ledgers, MCP without context pollution
An LLM council that reviews your coding agent's every move for quality assurance
Community Package
@johnlindquist on GitHub