Docs
HomeClaude Code PRO
Blog

Getting Started

  • Documentation
  • Claude Code Setup
  • Claude Code Configuration
  • Claude Code Security

Claude Code PRO

  • guideCheatsheet
  • skill/apex
  • skill/brainstorm
  • skill/debug
  • skill/clean-code
  • skill/review-code
  • skill/ci-fixer
  • skill/claude-memory
  • skill/create-prompt
  • skill/create-slash-commands
  • skill/prompt-creator
  • skill/create-skills-workflow
  • skill/skill-creator
  • skill/hook-creator
  • skill/subagent-creator
  • scriptStatusline
  • scriptCommand Validator
  • scriptAuto-Rename Session
  • scriptClaude Code AI
  • agentSnipper
  • agentCode Reviewer
  • agentExplore Codebase
  • agentExplore Docs
  • agentAction
  • agentWeb Search
  • cmd/oneshot
  • cmd/refactor
  • cmd/ultrathink
  • cmd/commit
  • cmd/create-pr
  • cmd/fix-pr-comments
  • cmd/merge
  • cmd/fix-errors
  • cmd/utils/fix-grammar
  • cmd/copywriting

/hook-creator

Expert guidance for creating, configuring, and using Claude Code hooks for event-driven automation.

The /hook-creator skill teaches you how to create and configure Claude Code hooks for event-driven automation.

What are Hooks?

Hooks are shell commands or LLM-evaluated prompts that execute in response to Claude Code events. They provide programmatic control over Claude's behavior without modifying core code.

Quick Start Workflow

  1. Create hooks config file:
    • Project: .claude/hooks.json
    • User: ~/.claude/hooks.json
  2. Choose hook event (when it fires)
  3. Choose hook type (command or prompt)
  4. Configure matcher (which tools trigger it)
  5. Test with claude --debug

Example: Log All Bash Commands

.claude/hooks.json:

JSON
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r '.tool_input.command' >> ~/.claude/bash-log.txt"
          }
        ]
      }
    ]
  }
}

This hook:

  • Fires before (PreToolUse) every Bash tool use
  • Executes a command (not an LLM prompt)
  • Logs the command to a file

Hook Types

EventWhen it FiresCan Block?
PreToolUseBefore tool executionYes
PostToolUseAfter tool executionNo
UserPromptSubmitUser submits a promptYes
StopClaude attempts to stopYes
SubagentStopSubagent attempts to stopYes
SessionStartSession beginsNo
SessionEndSession endsNo
PreCompactBefore context compactionYes
NotificationClaude needs inputNo

Hook Types

Command Hooks

Execute shell commands:

JSON
{
  "type": "command",
  "command": "echo 'Tool used' >> log.txt"
}

Prompt Hooks

Use LLM to evaluate:

JSON
{
  "type": "prompt",
  "prompt": "Is this command safe to run?"
}

Blocking Hooks

Blocking hooks can return "decision": "block" to prevent actions:

JSON
{
  "type": "command",
  "command": "if [[ \"$COMMAND\" == *\"rm -rf\"* ]]; then echo '{\"decision\": \"block\", \"reason\": \"Dangerous command\"}'; fi"
}

Use Cases

  1. Logging - Track all tool usage
  2. Validation - Block dangerous commands
  3. Notifications - Alert on specific events
  4. Context injection - Add information before tools run
  5. Workflow automation - Trigger actions after completion
/skill-creator/subagent-creator