claude-code-hook-development

Create and configure Claude Code hooks with exit codes and JSON outputs.

23|2|Updated Jan 6, 2026
One-click install
npx skills add https://github.com/dwmkerr/claude-toolkit --skill claude-code-hook-development
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-code-hook-development
Source: https://github.com/dwmkerr/claude-toolkit/tree/main/plugins/toolkit/skills/claude-code-hook-development
Command: npx skills add https://github.com/dwmkerr/claude-toolkit --skill claude-code-hook-development

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Claude Code hook development provides a structured approach to creating, configuring, and governing guards and automations that run on specific events, ensuring consistent policy enforcement across tool usage.

Core Features & Use Cases

  • Hook Types: Command hooks (bash/script execution) and Prompt hooks (LLM-driven decisions) to cover a wide range of automation and governance needs.
  • Exit Codes & Behavior: Clear exit code conventions (0 = allow, 2 = block) for reliable enforcement and predictable Claude responses.
  • Settings & File Layout: Standard locations (.claude/settings.json and .claude/hooks/) for configuration and hook scripts, enabling deterministic deployment.
  • Hook Events & Matchers: Supports PreToolUse, PostToolUse, PermissionRequest, UserPromptSubmit, Stop, SessionStart, and other events with a flexible matcher system.
  • Usage Scenarios: Enforce security policies, block dangerous commands, automate routine checks, and insert guardrails during development workflows.
  • Activation & References: Activation relies on documented references and examples to implement common policies and patterns.

Quick Start

Create a basic hook by placing a script under .claude/hooks/ and registering it in .claude/settings.json, then consult the References for sample patterns and activation steps.

Frequently Asked Questions about claude-code-hook-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create Claude Code hooks to enforce security policies?

To create Claude Code hooks for security policies, place a script under the .claude/hooks/ directory and register it in .claude/settings.json. This setup enables deterministic policy enforcement by producing specific exit codes during tool usage.

What is the difference between PreToolUse and PostToolUse hook events?

PreToolUse and PostToolUse are hook events that trigger automation at different stages. PreToolUse runs before tool execution to block dangerous commands, while PostToolUse executes after completion to automate routine checks and enforce guardrails.

How do I block dangerous commands using Claude Code guardrails?

You can block dangerous commands by configuring a command hook to return exit code 2. This exit code convention reliably blocks tool execution and produces predictable Claude responses for policy enforcement.

Can I use LLM-driven decisions instead of bash scripts for Claude Code hooks?

Yes, Claude Code supports both command hooks and prompt hooks. Prompt hooks enable LLM-driven decisions for governance and automation, while command hooks execute bash scripts to cover a wide range of policy enforcement needs.

How do I configure Claude Code hooks for automated checks?

Configure Claude Code hooks by defining automation rules in .claude/settings.json with scripts under .claude/hooks/. This standard file layout supports matchers for events like UserPromptSubmit and Stop, enabling deterministic deployment and routine checks.

What exit codes does Claude Code use for hook permission decisions?

Claude Code uses clear exit code conventions for hook permission decisions: exit code 0 allows the action, while exit code 2 blocks it. This ensures reliable enforcement and predictable responses during tool usage.