Claude Code hooks configuration and development. Covers hook lifecycle events, configuration patterns, input/output schemas, and common automation use cases. Use when user mentions hooks, automation, PreToolUse, PostToolUse, SessionStart, SubagentStart, or needs to enforce consistent behavior in Claude Code workflows.
View on GitHublaurigates/claude-plugins
hooks-plugin
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/laurigates/claude-plugins/blob/main/hooks-plugin/skills/hooks-configuration/SKILL.md -a claude-code --skill hooks-configurationInstallation paths:
.claude/skills/hooks-configuration/# Claude Code Hooks Configuration Expert knowledge for configuring and developing Claude Code hooks to automate workflows and enforce best practices. ## Core Concepts **What Are Hooks?** Hooks are user-defined shell commands that execute at specific points in Claude Code's lifecycle. Unlike relying on Claude to "decide" to run something, hooks provide **deterministic, guaranteed execution**. **Why Use Hooks?** - Enforce code formatting automatically - Block dangerous commands before execution - Inject context at session start - Log commands for audit trails - Send notifications when tasks complete ## Hook Lifecycle Events | Event | When It Fires | Key Use Cases | |-------|---------------|---------------| | **SessionStart** | Session begins/resumes | Environment setup, context loading | | **UserPromptSubmit** | User submits prompt | Input validation, context injection | | **PreToolUse** | Before tool execution | Permission control, blocking dangerous ops | | **PostToolUse** | After tool completes | Auto-formatting, logging, validation | | **Stop** | Agent finishes | Notifications, git reminders | | **SubagentStart** | Subagent is about to start | Input modification, context injection | | **SubagentStop** | Subagent finishes | Task completion evaluation | | **PreCompact** | Before context compaction | Transcript backup | | **Notification** | Claude sends notification | Custom alerts | | **SessionEnd** | Session terminates | Cleanup, state persistence | ## Configuration ### File Locations Hooks are configured in settings files: - **`~/.claude/settings.json`** - User-level (applies everywhere) - **`.claude/settings.json`** - Project-level (committed to repo) - **`.claude/settings.local.json`** - Local project (not committed) Claude Code merges all matching hooks from all files. ### Frontmatter Hooks (Skills and Commands) Hooks can also be defined directly in skill and command frontmatter using the `hooks` field: ```yaml --- name: my-skill description: A sk