Hook Development
可在工具调用前后注入策略与安全检查,方便集成自动化。
钩子可能执行外部操作,需注意权限与不信任输入。
在 Claude Code 插件中创建 Pre/Post/Stop 钩子以扩展与校验调用。
通过注册事件钩子(如 PreToolUse、PostToolUse、Stop 等)把自动化规则和校验挂到 Claude Code 插件里,能在工具调用前验证、调用后处理或阻断危险操作。要实现基于 prompt 的高级钩子、事件驱动自动化或策略强制时用它,方便把外部系统和调用流程串起来。
▸ 展开 SKILL.md 英文原文
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.
帮我安装这个 skill:https://raw.githubusercontent.com/tzachbon/smart-ralph/main/.agents/skills/Hook Development/SKILL.mdcurl -fsSL "https://raw.githubusercontent.com/tzachbon/smart-ralph/main/.agents/skills/Hook Development/SKILL.md"# Hook Development for Claude Code Plugins
## Overview
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:**
- Validate tool calls before execution (PreToolUse)
- React to tool results (PostToolUse)
- Enforce completion standards (Stop, SubagentStop)
- Load project context (SessionStart)
- Automate workflows across the development lifecycle
## Hook Types
### Prompt-Based Hooks (Recommended)
Use LLM-driven decision making for context-aware validation:
```json
{
"type": "prompt",
"prompt": "Evaluate if this tool use i