技能 claude-hooks
�
Claude Code 钩子可在 AI 工具执行期间启用自动驗證、記錄和通知功能。此技能提供配置 PreToolUse、PostToolUse、Notification 和 Stop 钩子的模板和最佳实践。
支持: Claude Code(CC)
1
下载技能 ZIP
2
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
3
开启并开始使用
测试它
正在使用“claude-hooks”。 How do I create a hook that logs every file that Claude writes?
预期结果:
- Add this to your ~/.claude/settings.json under the 'hooks' key:
- • Use PostToolUse event to capture writes after they complete
- • Matcher pattern 'Write' targets only file write operations
- • Command uses $CLAUDE_FILE_PATH environment variable
- • Appends each file path to ~/.claude/file_log.txt
安全审计
安全v3 • 1/10/2026
This skill contains only markdown documentation files with hook configuration templates. No executable code, scripts, network calls, or file system access. Pure reference content for Claude Code hook configuration.
2
已扫描文件
146
分析行数
0
发现项
3
审计总数
未发现安全问题
审计者: claude 查看审计历史 →
质量评分
41
架构
100
可维护性
81
内容
21
社区
100
安全
87
规范符合性
你能构建什么
审核工具执行
記錄所有 Claude Code 工具调用以进行合规审核和安全审查
强制执行编码标准
在执行前驗證代码更改以强制执行团队约定
自定义通知
当特定工具完成或失败时向外部系统发送警报
试试这些提示
创建驗證钩子
Show me how to create a PreToolUse hook that validates Bash commands before they run
设置日志记录
Create a PostToolUse hook that logs all file write operations to a file
通知集成
Configure a Notification hook that sends alerts to Slack when Claude completes tasks
匹配器模式
Explain the different matcher patterns I can use to target specific tools like Bash(git:*) or MCP tools
最佳实践
- 保持钩子快速(1 秒内)以避免阻塞 Claude Code 执行
- 使用特定的匹配器模式而非通配符来仅定位需要的工具
- 使用适当的 shell 错误处理优雅地处理错误以防止级联故障
避免
- 在钩子中使用冗长日志记录而向对话上下文添加过多输出
- 创建没有超时处理而无限期阻塞的钩子
- 为所有工具 (*) 配置钩子而仅需要特定工具自动化
常见问题
哪些 Claude 版本支持钩子?
Hooks require Claude Code version 0.9.0 or later. Check your installation with 'claude --version'.
钩子的最大执行时间是多久?
Hooks should complete in under 1 second. Long-running hooks will block Claude Code tool execution.
钩子如何与 MCP 工具集成?
Use matcher pattern 'mcp__*' to target all MCP tools, or specific MCP tool names for individual tools.
钩子是否安全?
Hooks run as your user with your permissions. Only install hooks from trusted sources and review commands before use.
为什么我的钩子没有触发?
Check that your settings.json has correct JSON syntax, the event name matches (PreToolUse, PostToolUse), and matcher patterns are valid.
钩子与自定义指令有何不同?
Hooks execute shell commands automatically on events, while custom instructions affect Claude's behavior through prompt context.
开发者详情
许可证
UNLICENSED
引用
main
文件结构