hook-development

Design Claude Code plugin hooks for tool validation and workflow policies.

1|Updated Apr 16, 2026
One-click install
npx skills add https://github.com/victorjoshi9/content--1- --skill hook-development-victorjoshi9
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/victorjoshi9/content--1-/tree/main/.claude/plugins/marketplaces/claude-plugins-official/plugins/plugin-dev/skills/hook-development
Command: npx skills add https://github.com/victorjoshi9/content--1- --skill hook-development-victorjoshi9

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps you design, validate, and maintain Claude Code plugin hooks that automate decisions, enforce safety rules, and add context at the right moment without fragile ad hoc scripting.

Core Features & Use Cases

  • Prompt-based hook design: Create context-aware hooks for PreToolUse, Stop, SubagentStop, and UserPromptSubmit events when you need flexible validation or approval logic.
  • Command-based automation: Build deterministic hooks for tasks like session context loading, schema validation, logging, and other repeatable checks.
  • Safety and reliability guidance: Apply portable paths, timeouts, JSON output conventions, input validation, and shell hardening to reduce risk.
  • Testing and migration support: Use the included utilities and references to lint hook scripts, test sample inputs, and move from basic command hooks to advanced prompt-based workflows.
  • Real-world example: A plugin can block dangerous Bash commands, load project-specific environment variables at session start, and confirm task completeness before the agent stops.

Quick Start

Use the hook-development skill to create a PreToolUse guard for Bash commands that blocks dangerous operations and generates the matching hooks configuration and shell script.

Frequently Asked Questions about hook-development

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

FAQPage Schema
How do I create Claude Code hooks to validate tool calls and enforce workflow policies?

Claude Code hooks validate tool calls and enforce workflow policies through structured JSON configurations paired with defensive shell scripts. You design prompt-based or command-based automation for events like PreToolUse, PostToolUse, and SessionStart to intercept and control agent actions.

What is the difference between prompt-based and command-based hooks in Claude Code?

Prompt-based hooks handle flexible validation and approval logic for events like PreToolUse and Stop, while command-based hooks execute deterministic, repeatable checks such as schema validation, logging, and session context loading. Both require structured JSON configurations and portable CLAUDE_PLUGIN_ROOT paths.

How do I block dangerous Bash commands automatically using Claude Code hooks?

Blocking dangerous Bash commands requires a PreToolUse hook that validates tool calls against safety rules before execution. You generate a matching JSON hook configuration and a defensive shell script with input validation, timeouts, and safe exit codes to reject risky operations.

Can I use shell scripts with Claude Code hooks for event-driven automation?

Shell scripts drive command-based event-driven automation in Claude Code hooks for tasks like session context loading and logging. You must apply shell hardening practices including input validation, timeouts, portable paths, and safe exit codes to ensure reliable, safe execution across plugin environments.

What safety practices should I follow when developing Claude Code plugin hooks?

Safe Claude Code plugin hook development requires portable CLAUDE_PLUGIN_ROOT paths, JSON output conventions, defensive shell scripting with input validation, timeouts, and safe exit codes. These practices reduce risk and prevent fragile ad hoc scripting from breaking automation workflows.

Does the hook-development approach support session lifecycle events like SessionStart and SessionEnd?

Session lifecycle events including SessionStart, SessionEnd, SessionStart, and PreCompact are fully supported. You can build command-based hooks to load project-specific environment variables at session start, log context, and run repeatable checks throughout the agent workflow.