A Hook in 📝Claude Code is a shell command the harness executes automatically in response to lifecycle events — tool calls, notifications, prompt submission, session start or stop — without explicit user invocation.
Hooks are configured in ~/.claude/settings.json under a hooks object keyed by event type: PreToolUse, PostToolUse, UserPromptSubmit, Notification, SessionStart, Stop, and others. Each hook entry pairs a matcher (which tool or condition fires it) with a shell command. The command runs in the user's shell environment with access to contextual variables like CLAUDE_FILE_PATH and CLAUDE_NOTIFICATION, and its exit code can block or allow the triggering action.
Typical patterns include auto-formatting files after Edit operations (npx eslint --fix $CLAUDE_FILE_PATH), routing notifications to macOS or Slack, logging session metrics to a dashboard, and blocking risky Bash invocations before they execute. Hooks are the operational nervous system of a mature Claude Code setup — they handle the mechanical work that should happen every time without explicit instruction, freeing the human-AI collaboration to focus on judgment.
Because hooks run shell commands on the user's machine with full filesystem and network access, the trust surface is significant: every installed 📝Claude Code Plugin effectively grants its hooks unsandboxed execution. The distinction from a 📝Slash Command is reactivity — hooks fire on events automatically, slash commands fire on explicit user invocation. See 📝Claude Code Hooks and Skills for the side-by-side comparison and configuration examples.
