hook-development

Create Claude Code plugin hooks that manage your application's lifecycle and resources.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/phpmac/skills --skill hook-development-phpmac
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/phpmac/skills/tree/main/plugins/plugin-dev/skills/hook-development
Command: npx skills add https://github.com/phpmac/skills --skill hook-development-phpmac

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Hooks unlock event-driven automation for Claude Code plugins. This skill provides a structured, comprehensive approach to creating and implementing PreToolUse, PostToolUse, Stop, SessionStart, and other hook events, with emphasis on advanced prompt-based hooks to enforce safety, govern tool use, and orchestrate workflows.

Core Features & Use Cases

  • Guides how to design and implement plugin hooks for Claude Code, including both prompt-based and command-based hooks.
  • Provides templates and best practices for hooks.json configurations, script organization, and cross-event coordination.
  • Includes actionable examples, security-focused patterns, and debugging workflows to ship production-ready hooks.

Quick Start

Install, configure, and start building hooks by wiring up hooks.json and implementing example hooks in scripts/ to begin validating user tool usage.

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 automate workflows and enforce safety?

Claude Code hooks automate workflows by configuring a valid hooks.json schema to handle PreToolUse, PostToolUse, and SessionStart events. You implement prompt-based or command-based hooks in scripts to validate tool usage and coordinate event responses.

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

Prompt-based hooks use natural language to guide Claude's behavior dynamically, while command hooks execute deterministic script checks. Both are defined in hooks.json and organized across events to guard, validate, and coordinate tool usage within Claude Code plugins.

How do I set up hooks.json for Claude Code plugin development?

Setting up hooks.json requires defining valid hook types for events like PreToolUse and Stop, ensuring portable paths via CLAUDE_PLUGIN_ROOT, and using jq for JSON handling. Scripts are organized in a scripts directory to provide clear exit codes and structured outputs.

Do I need jq to build Claude Code hooks?

Yes, jq is required for JSON handling when building Claude Code hooks. It processes the JSON payloads passed to command-based hooks, enabling scripts to parse event data and return structured outputs with appropriate exit codes for hook results.

When should I use SessionStart and Stop hook events in Claude Code?

Use SessionStart hooks to initialize environment configurations when a session begins, and Stop hooks to execute cleanup or validation when Claude finishes responding. Coordinating these events in hooks.json orchestrates workflows and enforces safety across the session lifecycle.

Why are my Claude Code plugin hooks not triggering on tool use events?

Hooks may fail to trigger if the hooks.json schema contains invalid types or incorrect paths. Ensure paths use CLAUDE_PLUGIN_ROOT for portability, scripts return proper exit codes, and jq correctly parses the event JSON to generate structured hook results.