Hook Development

Design and validate Claude Code plugin hooks for event-driven automation.

2|1|Updated Apr 9, 2026
One-click install
npx skills add https://github.com/timgranlundmarsden/claude-agent-flow --skill hook-development-timgranlundmarsden
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Hook Development
Source: https://github.com/timgranlundmarsden/claude-agent-flow/tree/main/skills/hook-development
Command: npx skills add https://github.com/timgranlundmarsden/claude-agent-flow --skill hook-development-timgranlundmarsden

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, timeout, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Claude Code plugin hooks let you automate validation, policy enforcement, context loading, and completion checks, but they are easy to misconfigure without a clear pattern. This Skill helps you design reliable hook workflows that catch unsafe actions, reduce manual review, and keep plugin behavior predictable.

Core Features & Use Cases

  • Event-driven automation for PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, and Notification.
  • Prompt-based and command-based hooks for flexible reasoning, deterministic checks, and safer tool execution.
  • Security and workflow controls such as blocking dangerous commands, validating file writes, loading project context, and enforcing “done” criteria before stopping.
  • Use case: Build a Claude Code plugin that denies risky shell commands, loads environment context when a session starts, and requires a final review before the agent can stop.

Quick Start

Use the Hook Development skill to create a Claude Code hook that blocks dangerous Bash commands and validates tool usage before execution.

Frequently Asked Questions about Hook Development

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

FAQPage Schema
How do I automate security checks for Claude Code commands before execution?

You can automate command safety by configuring PreToolUse hooks that block dangerous Bash commands and validate tool usage before execution. This Skill helps you implement deterministic prompt-based and command-based hook configurations for reliable command safety.

What events can I target when building Claude Code plugin hooks?

Claude Code plugin hooks support event-driven automation for PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, and Notification workflows to enforce command safety, policy checks, and context loading.

How do I enforce project context loading when a Claude Code session starts?

To enforce context loading when a Claude Code session starts, you design a SessionStart hook using portable ${CLAUDE_PLUGIN_ROOT} paths and JSON input handling. This Skill provides patterns for configuring hooks to load environment context predictably.

Do I need jq and timeout installed to develop Claude Code hooks?

Yes, jq and timeout are required dependencies for Claude Code hook development with this Skill. They enable proper JSON input and output handling and enforce timeout settings necessary for deterministic hook execution and validation.

What is the best way to validate completion criteria before a Claude Code agent stops?

The best way to validate completion criteria before a Claude Code agent stops is to implement Stop or SubagentStop hooks. This Skill helps you design hooks that enforce final review and completion criteria before the agent is permitted to stop.

Why are my Claude Code hooks failing to execute predictably during testing?

Claude Code hooks fail predictably when missing deterministic test and lint scripts, proper JSON handling, or timeout settings. This Skill requires portable ${CLAUDE_PLUGIN_ROOT} paths and test scripts to ensure plugin behavior remains predictable and reliable.