Proto.HooksClaude Code Hooks System - Wire Format
This module defines the wire format for hook configuration. Hooks allow you to intercept and control events in Claude Code sessions, such as tool usage, prompt submission, and session stops.
Hooks are organized by event type, with each event having:
This is the wire format module - it does not include the callback system or Eio dependencies. For the full hooks system with callbacks, see the Hooks module in the lib directory.
val event_to_string : event -> stringevent_to_string event converts an event to its wire format string. Wire format: "PreToolUse", "PostToolUse", "UserPromptSubmit", "Stop", "SubagentStop", "PreCompact"
val event_of_string : string -> eventevent_of_string s parses an event from its wire format string.
module Context : sig ... endContext provided to hook callbacks.
Hook decision control
decision_jsont is the Jsont codec for hook decisions. Wire format: "continue", "block"
module PreToolUse : sig ... endPreToolUse hook - fires before tool execution
module PostToolUse : sig ... endPostToolUse hook - fires after tool execution
module UserPromptSubmit : sig ... endUserPromptSubmit hook - fires when user submits a prompt
module Stop : sig ... endStop hook - fires when conversation stops
module SubagentStop : sig ... endSubagentStop hook - fires when a subagent stops
module PreCompact : sig ... endPreCompact hook - fires before message compaction
type result = {decision : decision option;system_message : string option;hook_specific_output : Jsont.json option;unknown : Unknown.t;}Generic result structure for hooks
val continue :
?system_message:string ->
?hook_specific_output:Jsont.json ->
unit ->
resultcontinue ?system_message ?hook_specific_output () creates a continue result.
val block :
?system_message:string ->
?hook_specific_output:Jsont.json ->
unit ->
resultblock ?system_message ?hook_specific_output () creates a block result.