Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

create-hooks

БесплатноБез исполняемых скриптовНе проверен

Expert guidance for creating, configuring, and using Claude Code hooks. Use when working with hooks, setting up event listeners, validating commands…

glittercowboyот glittercowboy★ 1 987 звёзд на GitHub25 установок в других каталогах

Об этом скилле

Hooks are event-driven automation for Claude Code that execute shell commands or LLM prompts in response to tool usage, session events, and user interactions. This skill teaches you how to create, configure, and debug hooks for validating commands, automating workflows, injecting context, and implementing custom completion criteria.

Hooks provide programmatic control over Claude's behavior without modifying core code, enabling project-specific automation, safety checks, and workflow customization.

Hooks are shell commands or LLM-evaluated prompts that execute in response to Claude Code events. They operate within an event hierarchy: events (PreToolUse, PostToolUse, Stop, etc.) trigger matchers (tool patterns) which fire hooks (commands or prompts). Hooks can block actions, modify tool inputs, inject context, or simply observe and log Claude's operations. 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` **Log all bash commands**:

.claude/hooks.json:

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

This hook:

  • Fires before (PreToolUse) every Bash tool use
  • Executes a command (not an LLM prompt)
  • Logs command + description to a file
| Event | When it fires | Can block? | |-------|---------------|------------| | **PreToolUse** | Before tool execution | Yes | | **PostToolUse** | After tool execution | No | | **UserPromptSubmit** | User submits a prompt | Yes | | **Stop** | Claude attempts to stop | Yes | | **SubagentStop** | Subagent attempts to stop | Yes | | **SessionStart** | Session begins | No | | **SessionEnd** | Session ends | No | | **PreCompact** | Before context compaction | Yes | | **Notification** | Claude needs input | No |

Blocking hooks can return "decision": "block" to prevent the action. See references/hook-types.md for detailed use cases.

**Type**: Executes a shell command

Use when:

  • Simple validation (check file exists)
  • Logging (append to file)
  • External tools (formatters, linters)
  • Desktop notifications

Input: JSON via stdin Output: JSON via stdout (optional)

{
  "type": "command",
  "command": "/path/to/script.sh",
  "timeout": 30000
}
**Type**: LLM evaluates a prompt

Use when:

  • Complex decision logic
  • Natural language validation
  • Context-aware checks
  • Reasoning required

Input: Prompt with $ARGUMENTS placeholder Output: JSON with decision and reason

{
  "type": "prompt",
  "prompt": "Evaluate if this command is safe: $ARGUMENTS\n\nReturn JSON: {\"decision\": \"approve\" or \"block\", \"reason\": \"explanation\"}"
}
Matchers filter which tools trigger the hook:
{
  "matcher": "Bash",           // Exact match
  "matcher": "Write|Edit",     // Multiple tools (regex OR)
  "matcher": "mcp__.*",        // All MCP tools
  "matcher": "mcp__memory__.*" // Specific MCP server
}

No matcher: Hook fires for all tools

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [...]  // No matcher - fires on every user prompt
      }
    ]
  }
}
Hooks receive JSON via stdin with session info, current directory, and event-specific data. Blocking hooks can return JSON to approve/block actions or modify inputs.

Example output (blocking hooks):

{
  "decision": "approve" | "block",
  "reason": "Why this decision was made"
}

See references/input-output-schemas.md for complete schemas for each hook type.

Available in hook commands:
Variable Value
$CLAUDE_PROJECT_DIR Project root directory
${CLAUDE_PLUGIN_ROOT} Plugin directory (plugin hooks only)
$ARGUMENTS Hook input JSON (prompt hooks only)

Example:

{
  "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/validate.sh"
}
**Desktop notification when input needed**: ```json { "hooks": { "Notification": [ { "hooks": [ { "type": "command", "command": "osascript -e 'display notification \"Claude needs input\" with title \"Claude Code\"'" } ] } ] } } ```

**Block destru

Полный SKILL.md на GitHub

Установить create-hooks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/command-vs-prompt.mdreferences/examples.mdreferences/hook-types.mdreferences/input-output-schemas.mdreferences/matchers.mdreferences/troubleshooting.md

FAQ

Что делает скилл create-hooks?

Expert guidance for creating, configuring, and using Claude Code hooks. Use when working with hooks, setting up event listeners, validating commands, automating workflows, adding notifications, or understanding hook types (PreToolUse, PostToolUse, Stop, SessionStart, UserPromptSubmit, etc).

Как установить скилл create-hooks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл create-hooks запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить create-hooks с