Skip to main content

Summary

The Inputs namespace contains classes for deserializing JSON data that Claude Code sends to hooks via stdin. Each hook event type has a corresponding input class.

Input Classes

ClassHook EventDescription
PreToolUseHookInput<T>PreToolUseReceived before a tool executes
PostToolUseHookInput<T,R>PostToolUseReceived after a tool completes
PermissionRequestHookInput<T>PermissionRequestReceived when permission is requested
UserPromptSubmitHookInputUserPromptSubmitReceived when user submits a prompt
StopHookInputStopReceived when Claude finishes responding
SubagentStopHookInputSubagentStopReceived when a subagent completes
NotificationHookInputNotificationReceived for notifications
SessionStartHookInputSessionStartReceived when a session starts
SessionEndHookInputSessionEndReceived when a session ends
PreCompactHookInputPreCompactReceived before context compaction
All input classes inherit from HookInputBase which provides common properties like SessionId, TranscriptPath, and CurrentWorkingDirectory.

Usage

Deserializing Hook Input

Use ClaudeHooksSerializer to deserialize input from stdin:
// For PreToolUse hooks
var input = ClaudeHooksSerializer.DeserializePreToolUseInput(Console.In.ReadToEnd());
Console.WriteLine($"Tool: {input?.ToolName}");
Console.WriteLine($"Session: {input?.SessionId}");

// For strongly-typed tool input (requires custom JsonSerializerContext)
var typedInput = ClaudeHooksSerializer.DeserializePreToolUseInput<MyToolInput>(
    json, MyJsonContext.Default.PreToolUseHookInputMyToolInput);

Common Base Properties

All inputs include these properties from HookInputBase:
  • SessionId - Unique session identifier
  • TranscriptPath - Path to conversation transcript
  • CurrentWorkingDirectory - Active working directory
  • PermissionMode - Current permission mode
  • HookEventName - The event that triggered this hook

Types

Classes

NameSummary
HookInputBaseBase class containing common fields present in all hook inputs. All hooks receive these fields via JSON through stdin.
NotificationHookInputRepresents the input received by a Notification hook. This hook runs when Claude Code sends notifications.
PermissionRequestHookInputRepresents the input received by a PermissionRequest hook. This hook runs when a permission dialog is shown and can automatically allow or deny permissions.
PostToolUseHookInputRepresents the input received by a PostToolUse hook. This hook runs after tool calls complete and includes the tool’s response.
PreCompactHookInputRepresents the input received by a PreCompact hook. This hook runs before a compact operation.
PreToolUseHookInputRepresents the input received by a PreToolUse hook. This hook runs before tool calls are executed and can block or modify them.
SessionEndHookInputRepresents the input received by a SessionEnd hook. This hook runs when a Claude Code session ends.
SessionStartHookInputRepresents the input received by a SessionStart hook. This hook runs when Claude Code starts a new session or resumes one.
StopHookInputRepresents the input received by a Stop hook. This hook runs when Claude Code finishes responding.
SubagentStopHookInputRepresents the input received by a SubagentStop hook. This hook runs when subagent tasks complete.
ToolHookInputBaseBase class for tool-related hook inputs that contain tool name, input, and use ID. Used as a base for PreToolUse and PostToolUse hook inputs.
UserPromptSubmitHookInputRepresents the input received by a UserPromptSubmit hook. This hook runs when the user submits a prompt, before Claude processes it.