Summary
TheCloudNimble.ClaudeEssentials.Hooks namespace provides strongly-typed C# models for building Claude Code hooks. These models represent the JSON input/output schemas that Claude Code uses to communicate with hook executables.
Key Components
- Inputs: Classes for deserializing JSON received from Claude Code via stdin
- Outputs: Classes for serializing JSON responses to stdout
- Enums: Type-safe representations of hook events, decisions, and modes
- ClaudeHooksSerializer: AOT-compatible helper methods for JSON serialization
- ClaudeHooksJsonContext: Source-generated JSON context for Native AOT support
Usage
Basic Hook Pattern
A Claude Code hook is an executable that:- Reads JSON from stdin
- Processes the input
- Writes JSON to stdout
- Exits with an appropriate code (0 = success, 2 = blocking error)
Hook Configuration
Configure hooks in~/.claude/settings.json or .claude/settings.json: