Claude Code hook

User-defined shell command triggered by Claude Code at specific lifecycle moments — session start, prompt submit, stop, and others.

Definition

Claude Code hooks are shell commands declared in settings.json that fire at specific moments: SessionStart (when a session begins), UserPromptSubmit (before each prompt reaches the model), PreToolUse, PostToolUse, Stop, and others. Hooks let teams inject context, enforce rules, log activity, or block tool calls. They run with the same permissions as Claude Code itself.

When to use

See also