claude-hooks-reference-2026
БесплатноБез исполняемых скриптовНе проверенComplete reference for Claude Code hooks system (January 2026). Use when creating hooks, understanding hook events, matchers, exit codes, JSON output control…
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
Claude Code Hooks System - Complete Reference (January 2026)
Hooks execute custom commands or prompts in response to Claude Code events. Use for automation, validation, formatting, and security.
All Hook Events
| Event | When Fired | Matcher Applies | Common Uses |
|---|---|---|---|
PreToolUse |
Before tool execution | Yes | Validation, blocking |
PermissionRequest |
When user shown permission dialog | Yes | Auto-approval policies |
PostToolUse |
After successful tool execution | Yes | Formatting, linting |
PostToolUseFailure |
After tool fails | Yes | Error handling |
Notification |
When Claude wants attention | Yes | Custom notifications |
UserPromptSubmit |
User submits prompt | No | Input validation |
Stop |
Claude finishes response | No | Cleanup, final checks |
SubagentStart |
When spawning a subagent | No | Subagent initialization |
SubagentStop |
Subagent (Task tool) completes | No | Result validation |
PreCompact |
Before context compaction | Yes | State backup |
Setup |
Repository setup/maintenance | Yes | One-time operations |
SessionStart |
Session begins or resumes | Yes | Environment setup |
SessionEnd |
Session ends | No | Cleanup, persistence |
Configuration
Configuration Locations (Precedence highest to lowest)
- Managed -
managed-settings.json(enterprise) - Local -
.claude/settings.local.json(gitignored) - Project -
.claude/settings.json(shared via git) - User -
~/.claude/settings.json(personal) - Plugin -
hooks/hooks.jsonor frontmatter - Capability - Skill/Command/Agent frontmatter
Note: Enterprise administrators can use allowManagedHooksOnly to block user, project, and plugin hooks.
Structure
Hooks are organized by matchers, where each matcher can have multiple hooks:
{
"hooks": {
"EventName": [
{
"matcher": "ToolPattern",
"hooks": [
{
"type": "command",
"command": "your-command-here"
}
]
}
]
}
}
Fields:
- matcher: Pattern to match tool names, case-sensitive (only for
PreToolUse,PermissionRequest,PostToolUse)- Simple strings match exactly:
Writematches only the Write tool - Supports regex:
Edit|WriteorNotebook.* - Use
*to match all tools. Also accepts empty string ("") or omitmatcher
- Simple strings match exactly:
- hooks: Array of hooks to execute when pattern matches
type:"command"for bash commands or"prompt"for LLM evaluationcommand: (Fortype: "command") The bash command to executeprompt: (Fortype: "prompt") The prompt to send to the LLMtimeout: (Optional) Seconds before canceling (default: 60 for commands, 30 for prompts)
Project-Specific Hook Scripts
Use $CLAUDE_PROJECT_DIR to reference scripts in your project:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check-style.sh"
}
]
}
]
}
}
Events Without Matchers
For UserPromptSubmit, Stop, SubagentStop, and SessionEnd, omit the matcher:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "/path/to/prompt-validator.py"
}
]
}
]
}
}
Plugin Hooks
Plugins can provide hooks that integrate with user and project hooks. For complete plugin documentation including plugin.json schema, directory structure, and component integration, see ./claude-plugins-reference-2026/SKILL.md.
How Plugin Hooks Work
- Plugin hooks defined in
hooks/hooks.jsonor custom path viahooksfield in plugin.json - When plugin enabled, its hooks merge with user and project hooks
- Multiple hooks from different sources can respond to same event
- Plugin hooks run alongside custom hooks in parallel
Plugin Hook Configuration
Hooks can be configured in hooks/hooks.json or inline in plugin.json:
{
"description": "Automatic code formatting",
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/
Установить claude-hooks-reference-2026 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл claude-hooks-reference-2026?
Complete reference for Claude Code hooks system (January 2026). Use when creating hooks, understanding hook events, matchers, exit codes, JSON output control, environment variables, plugin hooks, or implementing hook scripts.
Как установить скилл claude-hooks-reference-2026?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл claude-hooks-reference-2026 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic