create-hooks

Create, configure, and debug Claude Code hooks for lifecycle events.

Updated Nov 23, 2025
One-click install
npx skills add https://github.com/kyldvs/setup --skill create-hooks-kyldvs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-hooks
Source: https://github.com/kyldvs/setup/tree/main/.claude/skills/create-hooks
Command: npx skills add https://github.com/kyldvs/setup --skill create-hooks-kyldvs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Manually overseeing every action in Claude Code can be time-consuming and prone to error. This Skill empowers you to automate tasks, validate actions, and inject context into Claude's workflow, ensuring safety, consistency, and efficiency without modifying core code.

Core Features & Use Cases

  • Event-Driven Automation: Execute shell commands or LLM prompts in response to specific events like tool use, session start/end, or user prompts.
  • Workflow Customization: Implement custom logic to validate commands (e.g., block destructive git operations), auto-format code after edits, or inject project-specific context at session start.
  • Use Case: Automatically log all Bash commands executed by Claude to an audit file for compliance, or set up a prompt hook to prevent accidental force pushes to your main branch.

Quick Start

To log all Bash commands, create a .claude/hooks.json file in your project. Inside, define a PreToolUse hook that matches "Bash" tools and executes a command to append the tool's command input to a log file.

Frequently Asked Questions about create-hooks

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

FAQPage Schema
How do I automate validation and block unsafe commands in Claude Code?

Event-driven hooks let you intercept tool use before execution. Create a PreToolUse hook that matches specific tools (like Bash or Git), then execute validation logic or block commands that don't meet your criteria—such as preventing force pushes or destructive operations.

What are Claude Code hooks and when should I use them?

Hooks are event listeners that trigger custom shell commands or LLM prompts at key workflow moments: before/after tool use, session start, or user prompt submission. Use them to automate repetitive tasks, enforce safety policies, log actions for compliance, or inject project context without modifying core code.

How do I set up a hook to log all Bash commands executed by Claude?

Define a PreToolUse hook in `.claude/hooks.json` that matches the Bash tool and executes a command appending the tool input to an audit log file. The hook receives the command details and can write them to your compliance or audit trail before Claude executes the action.

Can I inject project-specific context into Claude's workflow with hooks?

Yes. Use SessionStart hooks to execute commands or prompts that load project configuration, environment variables, or custom guidelines at the beginning of each session, ensuring Claude operates with your team's standards and context automatically.

Do hooks work with custom approval workflows for sensitive operations?

Hooks support approval workflows through blocking logic and manual intervention. Configure a PostToolUse hook to pause on sensitive operations, or use prompt-based hooks to require confirmation before destructive actions like git force pushes proceed.

What's the difference between command-based and prompt-based hooks?

Command-based hooks execute shell scripts for fast, deterministic automation like logging or file operations. Prompt-based hooks invoke Claude's reasoning to evaluate context, make decisions, or generate responses—useful for intelligent validation or dynamic policy enforcement.