hook-development

Validate and enforce safe tool usage for Claude Code plugin hooks.

6|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/archibate/archibate-skills --skill hook-development-archibate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hook-development
Source: https://github.com/archibate/archibate-skills/tree/main/skills/hook-development
Command: npx skills add https://github.com/archibate/archibate-skills --skill hook-development-archibate

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Provides a structured, secure way to validate, modify, and react to Claude Code plugin events so agents cannot execute unsafe or inappropriate tools and so sessions load relevant context automatically.

Core Features & Use Cases

  • Prompt-based and command hooks: Combine LLM-driven reasoning with deterministic shell checks for layered validation.
  • Event coverage: Handles PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, and Notification events.
  • Testing and validation utilities: Includes scripts to validate hooks.json, test hook scripts, and lint hook implementations for security and best practices.
  • Security and performance guidance: Best practices for input validation, path safety, timeouts, parallel execution, and environment persistence using $CLAUDE_ENV_FILE and ${CLAUDE_PLUGIN_ROOT}.

Quick Start

Add a prompt-based PreToolUse hook that blocks destructive bash commands and validates writes to system or credential files 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 validate Claude Code plugin hooks to block unsafe tool execution?

Claude Code plugin hooks validation combines LLM-driven reasoning with deterministic shell checks to block unsafe tool execution. You define PreToolUse and PostToolUse events that intercept destructive bash commands and validate file writes before execution.

What are Claude Code command hooks and when do I need them?

Claude Code command hooks are event-driven scripts triggered at lifecycle stages like SessionStart, UserPromptSubmit, and Stop. You need them to automate workflows, load project context, and enforce security policies when agents interact with tools.

Can I use prompt-based hooks alongside shell command hooks for layered validation?

Prompt-based hooks can be used alongside command hooks for layered validation in Claude Code. This combines LLM reasoning for complex context checks with deterministic shell scripts for strict security enforcement and structured JSON exit codes.

How do I test and lint Claude Code hook scripts for security best practices?

Testing and linting Claude Code hook scripts requires running included validation scripts against hooks.json configurations. These scripts check structured JSON outputs, verify timeout controls, and lint implementations for path safety and security best practices.

What environment variables and dependencies do I need for Claude Code hook automation?

Claude Code hook automation requires the jq and timeout dependencies. You use environment variables like ${CLAUDE_PLUGIN_ROOT} for path resolution and $CLAUDE_ENV_FILE for environment persistence across hook events.

Why are my PreToolUse hooks not blocking destructive commands in Claude Code?

PreToolUse hooks fail to block destructive commands when they lack proper structured JSON outputs or correct exit codes. Ensure your command hooks implement timeout controls and input validation to enforce safe tool usage decisions properly.