🔗Composition

Hook fires skill

Composition example: PostToolUse hook detects a command and queues a slash command for the next turn.

Surfaces
hook · skill · trigger
Complexity
advanced
Trigger
hook
Est. tokens
2,000

What It Does

When Claude runs a DB migration command, a PostToolUse hook detects it and appends a slash command (e.g. /verify-migration) to the prompt queue. On Claude's next turn, the verification skill runs automatically. The hook does the detection; the skill does the verification.

When It Triggers

  • PostToolUse on Bash commands matching migration patterns (alembic upgrade, prisma migrate)
  • Fires after the migration completes — verification runs next

SKILL.md

markdown
---
name: hook-fires-skill
description: Example of a PostToolUse hook that invokes a skill after specific tool calls. Wires a Bash-run migration to auto-trigger a verification skill.
---

# Hook Fires Skill

## Flow
1. User runs a DB migration via Bash
2. PostToolUse hook detects `alembic upgrade` or `prisma migrate`
3. Hook appends `/verify-migration` to the user's prompt queue
4. Claude picks up the slash command on its next turn and runs the skill

## Install
See `settings.json` in the files section.

settings.json

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "commandMatcher": "(alembic upgrade|prisma migrate)",
        "command": "echo '/verify-migration' >> \"$CLAUDE_PROMPT_QUEUE\""
      }
    ]
  }
}

Why Two Primitives

Hooks are deterministic shell commands — fast, free of tokens, perfect for detection. Skills are Claude-powered workflows — good for verification, reasoning, and structured output. Combining them keeps detection cheap and verification smart.