hook-development

Develop Claude Code hooks that validate, approve, deny, or modify tool usage.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/moughamir/justwaitit-review --skill hook-development-moughamir
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/moughamir/justwaitit-review/tree/main/.agents/skills/hook-development
Command: npx skills add https://github.com/moughamir/justwaitit-review --skill hook-development-moughamir

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you design and configure Claude Code plugin hooks so automated tool actions are validated, policy-enforced, and reliably integrated into your workflow.

Core Features & Use Cases

  • Event-driven hook design: Implement guardrails and automation across hook events like PreToolUse, PostToolUse, Stop, SessionStart, and SessionEnd.
  • Prompt-based and command-based hooks: Choose LLM-evaluated approvals for flexible policy decisions or deterministic shell commands for validation/testing.
  • Correct configuration for plugin vs user settings: Generate the right hooks.json structure (plugin wrapper) or direct event mapping (.claude/settings.json).
  • Safety and validation guidance: Use portable paths via ${CLAUDE_PLUGIN_ROOT}, validate inputs, block path traversal, and ensure valid JSON outputs from hook scripts.
  • Operational best practices: Understand parallel execution behavior, restart requirements, matcher scoping, timeouts, and debugging with claude --debug.

Quick Start

Tell Claude to configure a PreToolUse hook for Write|Edit that blocks writes to sensitive files like .env and uses ${CLAUDE_PLUGIN_ROOT} to run a validation script that returns valid JSON decisions.

Frequently Asked Questions about hook-development

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

FAQPage Schema
How do I configure Claude Code hooks to validate or block tool usage?

Claude Code hooks validate tool usage by configuring PreToolUse or PostToolUse events to run deterministic scripts or prompt-based policies that return JSON decisions to approve, deny, or modify actions.

What is the difference between hooks.json and .claude/settings.json for plugin configuration?

Plugin configuration uses hooks.json with a wrapper structure, while user settings map events directly in .claude/settings.json. Both formats enable event-driven automation but differ in their JSON structural requirements.

How do I prevent Claude Code from writing to sensitive files like .env?

Prevent writes to sensitive files by configuring a PreToolUse hook with a Write|Edit matcher that executes a validation script, returning a JSON decision to deny the tool action.

Can I use LLM-evaluated approvals instead of deterministic scripts for Claude Code hooks?

Yes, Claude Code hooks support prompt-based approvals for flexible policy decisions using LLM evaluation, alongside deterministic shell commands for strict validation and testing scenarios.

How do I debug Claude Code hooks when automation is not working?

Debug Claude Code hooks by running claude --debug to inspect execution behavior. Ensure correct matcher scoping, validate JSON outputs from scripts, and restart to apply configuration changes.

What lifecycle events are available for Claude Code event-driven automation?

Claude Code event-driven automation supports PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, and SessionEnd lifecycle events for applying guardrails and automated workflows.