claude-code-hooks

Automate Claude Code hook setup for validation, formatting, and auditing events.

73|16|Updated Nov 14, 2025
One-click install
npx skills add https://github.com/vasilyu1983/AI-Agents-public --skill claude-code-hooks-vasilyu1983
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-code-hooks
Source: https://github.com/vasilyu1983/AI-Agents-public/tree/main/frameworks/claude-code-kit/framework/skills/claude-code-hooks
Command: npx skills add https://github.com/vasilyu1983/AI-Agents-public --skill claude-code-hooks-vasilyu1983

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defines hooks for PreToolUse, PostToolUse, Stop, and other events to govern automation.

Core Features & Use Cases

  • Hook types: PreToolUse, PostToolUse, Stop, SessionStart/End.
  • Templates: Hook scripts for validation, formatting, and auditing.
  • Security: Guardrails around tool execution.

Quick Start

Add a pre-tool guard script to block dangerous commands and a post-tool formatter.

Frequently Asked Questions about claude-code-hooks

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

FAQPage Schema
How do I automate Claude Code hook setup for CI/CD pipelines?

Automate Claude Code hook setup by defining PreToolUse, PostToolUse, Stop, SessionStart, and SessionEnd events in a structured settings.json file with bash scripts, environment variables, and matchers. This governs validation, formatting, auditing, and lifecycle management across your CI/CD pipeline without manual configuration.

What are PreToolUse and PostToolUse hooks and how do they work?

PreToolUse and PostToolUse hooks are event-driven handlers that execute before and after tool execution. PreToolUse applies security guards to block dangerous commands; PostToolUse applies formatters and auditors to validate results. Both use bash scripts and exit codes defined in hook templates to enforce guardrails.

How can I add security guards to prevent dangerous Claude Code commands?

Add a PreToolUse hook with a guard script in settings.json that validates commands against security matchers and exits with a non-zero code to block execution. This governs tool execution and enforces security policy without manual intervention during CI/CD workflows.

Can I use hooks for validation, formatting, and auditing in automation workflows?

Yes. Hooks support validation through PreToolUse matchers, formatting through PostToolUse scripts, and auditing through event handlers. Define bash scripts and environment variables in settings.json to orchestrate security guards, formatters, and auditors across SessionStart, SessionEnd, and UserPromptSubmit events.

What input files and configuration do I need to set up Claude Code hooks?

You need a structured settings.json file defining hook types, bash scripts, environment variables, matchers, and exit codes, plus hook templates for each event type. These inputs orchestrate security guards, formatters, auditors, and lifecycle management across PreToolUse, PostToolUse, Stop, and session events.

What happens when a hook script exits with a non-zero code?

A non-zero exit code blocks execution—PreToolUse hooks reject tool invocation, and PostToolUse hooks mark results as invalid. This enforces validation and security policy in your automation workflow without requiring additional configuration steps.