Create Claude Code plugin hooks for tool validation and event-driven automation.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "hook-development" skill from askskill: 1. Download https://raw.githubusercontent.com/anthropics/claude-plugins-official/main/plugins/plugin-dev/skills/hook-development/SKILL.md 2. Save it as ~/.claude/skills/hook-development/SKILL.md 3. Reload skills and tell me it's ready
Create a PreToolUse prompt hook for a Claude Code plugin that matches Write|Edit. Before file writes, check for system paths, credential exposure, path traversal, or sensitive content, and return only approve or deny. Provide the configuration for plugin hooks/hooks.json.
A plugin hooks.json snippet with PreToolUse, a matcher, and a prompt-type hook.
Generate a command hook example that runs bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh during PreToolUse with a 60-second timeout. Also explain whether the format is for plugin hooks.json or .claude/settings.json.A command hook configuration using ${CLAUDE_PLUGIN_ROOT}, plus the corresponding configuration format.
I want to automatically load project context when a Claude Code session starts. Provide a SessionStart hook example and explain the wrapper format required by plugin hooks.json.
A SessionStart hook example and an explanation of the plugin wrapper structure with description and hooks.
When adding governance to a Claude Code plugin, developers can use this skill to design hooks such as PreToolUse or Stop to validate, block, or enforce rules around tool usage.
When automatic actions should run on events like SessionStart, PostToolUse, or SessionEnd, this skill helps configure event-driven hooks to connect validation, context loading, and external integrations.
If a team wants context-aware decisions through natural-language rules instead of relying entirely on Bash scripts, this skill can be used to implement prompt-based hooks.
The document explains how to develop hooks for Claude Code plugins. It describes hooks as event-driven automation scripts that can validate tool calls, enforce policies, load context, and integrate external tools. It compares prompt-based hooks with command hooks, outlines when each is appropriate, and clarifies the two configuration formats: the wrapped plugin hooks/hooks.json format and the direct .claude/settings.json format, along with core events such as PreToolUse, Stop, and SessionStart.
Hooks are event-driven automation scripts that execute in response to Claude Code events. Use hooks to validate operations, enforce policies, add context, and integrate external tools into workflows.
Key capabilities:
Use LLM-driven decision making for context-aware validation:
{
"type": "prompt",
"prompt": "Evaluate if this tool use is appropriate: $TOOL_INPUT",
"timeout": 30
}
Supported events: Stop, SubagentStop, UserPromptSubmit, PreToolUse
Benefits:
Execute bash commands for deterministic checks:
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh",
"timeout": 60
}
Use for:
For plugin hooks in hooks/hooks.json, use wrapper format:
{
"description": "Brief explanation of hooks (optional)",
"hooks": {
"PreToolUse": [...],
"Stop": [...],
"SessionStart": [...]
}
}
Key points:
description field is optionalhooks field is required wrapper containing actual hook eventsExample:
{
"description": "Validation hooks for code quality",
"hooks": {
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/validate.sh"
}
]
}
]
}
}
For user settings in .claude/settings.json, use direct format:
{
"PreToolUse": [...],
"Stop": [...],
"SessionStart": [...]
}
Key points:
Important: The examples below show the hook event structure that goes inside either format. For plugin hooks.json, wrap these in {"hooks": {...}}.
Execute before any tool runs. Use to approve, deny, or modify tool calls.
Example (prompt-based):
{
"PreToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "prompt",
"prompt": "Validate file write safety. Check: system paths, credentials, path traversal, sensitive content. Return 'approve' or 'deny'."
}
]
}
]
}
Output for PreToolUse:
{
"hookSpecificOutput": {
"permissionDecision": "allow|deny|ask",
"updatedInput": {"field": "modified_value"}
},
"systemMessage": "Explanation for Claude"
}
Execute after tool completes. Use to react to results, provide feedback, or log.
Example:
{
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "prompt",
"prompt": "Analyze edit result for potential issues: syntax errors, security vulnerabilities, breaking changes. Provide feedback."
}
]
}
]
}
Output behavior:
Execute when main agent considers stopping. Use to validate completeness.
Example:
{
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "prompt",
…
It helps create and implement hooks for Claude Code plugins, focusing on event-driven automation, tool-use validation, and the advanced prompt-based hooks API.
According to the docs, prompt hooks are suited for context-aware LLM decisions and flexible logic, while command hooks run Bash commands and are better for deterministic checks, file operations, and external tool integrations.
No. Plugin hooks/hooks.json uses a wrapper format with a required hooks field and an optional description, while .claude/settings.json places hook events directly at the top level with no wrapper.
Package a local MCP server into a runtime-bundled .mcpb file.
Browse Anthropic’s official directory of quality Claude Code plugins.
Helps developers plan the right MCP server architecture and build approach.
Build single-file interactive HTML playgrounds with live preview and prompt export.
Create and structure reusable slash commands for Claude Code workflows.
This skill should be used when the user asks about "plugin settings", "store plugin configuration", "user-configurable plugin", ".local.md files", "plugin state files", "read YAML frontmatter", "per-project plugin settings", or wants to make plugin behavior configurable. Documents the .claude/plugin-name.local.md pattern for storing plugin-specific configuration with YAML frontmatter and markdown content.
Discover curated Claude Code skills, plugins, and workflows to extend AI coding
Build, update, test, and release Claude Code plugins efficiently end to end.
Get official guidance for Claude Code CLI, MCP, plugins, and configuration.
Discover Claude Code plugins to extend commands, agents, hooks, and MCP tools.
Set up Claude Code skills, hooks, agents, and memory in one command.
Create hook JSON files for policy enforcement and agent lifecycle automation.