home / skills / 89jobrien / steve / claude-hooks

claude-hooks skill

/steve/skills/claude-hooks

This skill helps you create and configure Claude Code hooks for validation, logging, and automation to streamline workflows.

npx playbooks add skill 89jobrien/steve --skill claude-hooks

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.3 KB
---
name: claude-hooks
description: Claude Code hooks configuration specialist. Use when creating hooks for
  tool validation, logging, notifications, or custom automation in Claude Code.
author: Joseph OBrien
status: unpublished
updated: '2025-12-23'
version: 1.0.1
tag: skill
type: skill
---

# Claude Hooks Skill

Creates and configures hooks for Claude Code to automate workflows and extend functionality.

## What This Skill Does

- Creates PreToolUse validation hooks
- Sets up PostToolUse logging/cleanup
- Configures notification hooks
- Implements custom automation
- Documents hook patterns

## When to Use

- Tool execution validation
- Audit logging
- Custom notifications
- Workflow automation
- Security controls

## Reference Files

- `references/CLAUDE_HOOK.template.md` - Hook configuration examples and patterns

## Hook Events

| Event | Trigger | Use Case |
|-------|---------|----------|
| PreToolUse | Before tool executes | Validation, blocking |
| PostToolUse | After tool completes | Logging, cleanup |
| Notification | Claude sends notification | Alerts |
| Stop | Claude stops | Final reports |

## Configuration Location

Hooks are configured in `~/.claude/settings.json` under the `hooks` key.

## Best Practices

- Keep hooks fast (< 1 second)
- Handle errors gracefully
- Use specific matchers
- Test hooks independently
- Avoid verbose output

Overview

This skill configures and manages Claude Code hooks to validate tools, log activity, send notifications, and run custom automations. It provides patterns and templates to add PreToolUse, PostToolUse, Notification, and Stop hooks quickly and safely. Use it to enforce policies, capture audit trails, and automate cleanup or alerts.

How this skill works

The skill generates and updates hook definitions stored in the CLAUDE configuration file and supplies ready-to-use templates for common events. It wires PreToolUse hooks for input validation and blocking, PostToolUse hooks for logging and cleanup, Notification hooks for alerts, and Stop hooks for final reporting. It also includes matchers and examples to scope hooks to specific tools or contexts.

When to use it

  • Validate tool inputs or block unsafe executions
  • Capture audit logs and metadata after tool runs
  • Send alerts or notifications on specific events
  • Automate cleanup, retries, or follow-up tasks
  • Enforce security controls or policy checks

Best practices

  • Keep hook execution under 1 second to avoid slowing workflows
  • Scope hooks with specific matchers to limit blast radius
  • Handle errors gracefully and fail-safe (don’t block critical flows)
  • Test hooks independently before deploying to production
  • Log structured, minimal output to simplify auditing

Example use cases

  • PreToolUse validation that blocks sensitive data exfiltration attempts
  • PostToolUse logger that records tool outputs and runtime metadata for audits
  • Notification hook that sends Slack or email alerts when a failure pattern appears
  • Stop hook that compiles a final run report and posts to a dashboard
  • Automation hook that retries flaky tools or triggers downstream jobs

FAQ

Where are hooks stored?

Hooks are configured in the Claude settings file under the hooks key (typically ~/.claude/settings.json).

How do I limit a hook to a single tool?

Use specific matchers in the hook definition to target a tool name, tool type, or metadata field. Narrow match criteria to avoid unintended triggers.

What should a hook return on error?

Return a safe default and an error log entry. Avoid throwing uncaught exceptions—fail safe so the main workflow can continue if necessary.