Creating Hooks

Create event-driven hooks for Claude Code lifecycle events.

7|1|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/jack-michaud/faire --skill creating-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Creating Hooks
Source: https://github.com/jack-michaud/faire/tree/main/jack-software/skills/creating-hooks
Command: npx skills add https://github.com/jack-michaud/faire --skill creating-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Hooks enable event-driven automation for Claude Code lifecycle events (validation, setup, and automation).

Core Features & Use Cases

  • PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd
  • JSON input structures and environment checks
  • Guidance on using CLAUDE_PROJECT_DIR for scripts

Quick Start

Add a hook to .claude/settings.json and point it to a script; trigger an event to validate behavior.

Frequently Asked Questions about Creating Hooks

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

FAQPage Schema
How do I automate validation and environment checks in Claude Code workflows?

Hooks enable event-driven automation across Claude Code lifecycle stages. Create scripts in your project, reference them in .claude/settings.json with matcher-based configuration, and trigger them on PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, or SessionEnd events to validate inputs and verify environment state.

What lifecycle events can I hook into in Claude Code?

Claude Code supports five hook events: PreToolUse (before tool execution), PostToolUse (after tool execution), UserPromptSubmit (on user input), SessionStart (session initialization), and SessionEnd (session closure). Each event enables validation, logging, or resource lifecycle automation.

How do I reference project paths in Claude Code hook scripts?

Use the $CLAUDE_PROJECT_DIR environment variable in your hook scripts for environment-agnostic path resolution. This ensures scripts locate project files correctly regardless of where Claude Code runs.

Can I parse JSON input structures in Claude Code hooks?

Yes. Hooks support JSON input parsing, enabling you to structure validation rules and configuration. Define your input format in .claude/settings.json and process JSON payloads within your hook scripts.

How do I know if my hook script executed successfully?

Hook scripts report execution status via exit codes. Use standard exit code conventions—0 for success, non-zero for failure—to signal validation results and control downstream Claude Code behavior.

When should I use hooks versus manual task execution in Claude Code?

Use hooks for recurring validation, environment checks, or resource lifecycle tasks that must run automatically at fixed lifecycle points. Manual execution suits ad-hoc tasks or complex logic requiring user decision-making between steps.