Standardized configuration and pattern enforcement for AI agent hooks.

Install

mkdir -p .claude/skills/hooks && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2194" && unzip -o skill.zip -d .claude/skills/hooks && rm skill.zip

Installs to .claude/skills/hooks

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Hook Development Rules
22 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Register shell-to-TypeScript hooks
  • Configure pre-execution and post-execution tasks
  • Manage session start and stop events
  • Define event-specific matchers
  • Test hooks manually via shell scripts

How it works

Hooks use a shell wrapper to pipe input into a TypeScript handler via npx tsx, which processes the event and returns a JSON response.

Inputs & outputs

You give it
JSON payload from stdin
You get back
JSON object with result and message

When to use hooks

  • Register a custom PreToolUse hook
  • Configure a post-execution cleanup task
  • Define triggers for session start events

About this skill

Hook Development Rules

When working with files in .claude/hooks/:

Pattern

Shell wrapper (.sh) → TypeScript (.ts) via npx tsx

Shell Wrapper Template

#!/bin/bash
set -e
cd "$CLAUDE_PROJECT_DIR/.claude/hooks"
cat | npx tsx <handler>.ts

TypeScript Handler Pattern

interface HookInput {
  // Event-specific fields
}

async function main() {
  const input: HookInput = JSON.parse(await readStdin());

  // Process input

  const output = {
    result: 'continue',  // or 'block'
    message: 'Optional system reminder'
  };

  console.log(JSON.stringify(output));
}

Hook Events

  • PreToolUse - Before tool execution (can block)
  • PostToolUse - After tool execution
  • UserPromptSubmit - Before processing user prompt
  • PreCompact - Before context compaction
  • SessionStart - On session start/resume/compact
  • Stop - When agent finishes

Testing

Test hooks manually:

echo '{"type": "resume"}' | .claude/hooks/session-start-continuity.sh

Registration

Add hooks to .claude/settings.json:

{
  "hooks": {
    "EventName": [{
      "matcher": ["pattern"],  // Optional
      "hooks": [{
        "type": "command",
        "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/hook.sh"
      }]
    }]
  }
}

When not to use it

  • When direct TypeScript execution is sufficient without shell wrapping

Prerequisites

npx tsxShell environment

Limitations

  • Requires shell wrapper for execution
  • Limited to predefined hook events

How it compares

Unlike static configurations, this allows dynamic, event-driven logic execution before or after agent tool use.

Compared to similar skills

hooks side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
hooks (this skill)37moReviewIntermediate
bazel-build-optimization142moNo flagsAdvanced
github-workflow-automation112moReviewAdvanced
wolf-scripts-core59moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry