A lightweight Python SDK for building Claude Code hooks with automatic JSON parsing and type-safe context handling.
cchooks is a Python SDK that simplifies creating hooks for Claude Code, an AI coding assistant. It eliminates the boilerplate of JSON parsing and validation, allowing developers to focus on implementing hook logic for security, automation, and workflow control.
Python developers building custom hooks for Claude Code to add security, automation, logging, or workflow control to their AI-assisted coding sessions.
Developers choose cchooks because it provides a one-liner setup with automatic JSON parsing and hook type detection, full type hints for IDE autocompletion, and support for both simple exit codes and advanced JSON output modes, significantly reducing implementation complexity.
A Python SDK for claude-code hooks
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The create_context() function automatically handles JSON parsing and validation from stdin, eliminating boilerplate code as shown in the quick start example for building a PreToolUse hook.
Automatically identifies the hook type from nine supported events like SessionStart and SessionEnd, reducing manual configuration and errors.
Provides full type hints and IDE autocompletion for each hook context, improving code reliability and developer experience, evident in the PreToolUseContext assertions.
Supports simple exit codes for basic control and advanced JSON output with system messages, offering flexibility as demonstrated in the system message support section.
Designed exclusively for Claude Code hooks, making it unsuitable for other AI assistants or general-purpose automation, with no built-in adapters for different platforms.
Requires Python and the cchooks package installation, adding complexity for teams preferring lightweight shell scripts or zero-dependency solutions.
For Stop hooks, developers must manually check stop_hook_active to handle parallel execution, a nuance the README admits can lead to errors if overlooked.