claude-hooks
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaude Hooks Skill
Claude Hooks Skill
Creates and configures hooks for Claude Code to automate workflows and extend functionality.
为Claude Code创建并配置钩子,以实现工作流自动化并扩展功能。
What This Skill Does
本技能功能
- Creates PreToolUse validation hooks
- Sets up PostToolUse logging/cleanup
- Configures notification hooks
- Implements custom automation
- Documents hook patterns
- 创建PreToolUse验证钩子
- 配置PostToolUse日志记录/清理
- 设置通知钩子
- 实现自定义自动化
- 记录钩子模式
When to Use
使用场景
- Tool execution validation
- Audit logging
- Custom notifications
- Workflow automation
- Security controls
- 工具执行验证
- 审计日志
- 自定义通知
- 工作流自动化
- 安全控制
Reference Files
参考文件
- - Hook configuration examples and patterns
references/CLAUDE_HOOK.template.md
- - 钩子配置示例与模式
references/CLAUDE_HOOK.template.md
Hook Events
钩子事件
| Event | Trigger | Use Case |
|---|---|---|
| PreToolUse | Before tool executes | Validation, blocking |
| PostToolUse | After tool completes | Logging, cleanup |
| Notification | Claude sends notification | Alerts |
| Stop | Claude stops | Final reports |
| 事件 | 触发条件 | 使用场景 |
|---|---|---|
| PreToolUse | 工具执行前 | 验证、拦截 |
| PostToolUse | 工具完成后 | 日志记录、清理 |
| Notification | Claude发送通知时 | 告警 |
| Stop | Claude停止时 | 最终报告 |
Configuration Location
配置位置
Hooks are configured in under the key.
~/.claude/settings.jsonhooks钩子配置在的键下。
~/.claude/settings.jsonhooksBest Practices
最佳实践
- Keep hooks fast (< 1 second)
- Handle errors gracefully
- Use specific matchers
- Test hooks independently
- Avoid verbose output
- 保持钩子执行快速(< 1秒)
- 优雅处理错误
- 使用特定匹配器
- 独立测试钩子
- 避免冗余输出