SuperAPI AI 工具集

Writing Hookify Rules

写作与研究

查看项目

更新于 10-16 08:45

技能介绍

用途:当用户要求创建 hookify 规则、编写 hook 规则、配置 hookify 或添加 hookify 规则时使用,提供规则编写指导。

主要能力:规则为带 YAML frontmatter 的 Markdown 文件,存放于 .claude/hookify.{rule-name}.local.md。frontmatter 字段包括 name(必填,kebab-case 唯一标识)、enabled(必填,布尔)、event(必填:bash、file、stop、prompt、all)、action(可选:warn 默认或 block)、pattern(简单格式,Python 正则)。复杂规则可用 conditions 多条件,字段有 field、operator(regex_match、contains、equals、not_contains、starts_with、ends_with)、pattern,所有条件须同时匹配。frontmatter 之后的 Markdown 正文在触发时显示给 Claude。

使用方式:识别不期望行为,确定涉及工具,选择事件类型,编写正则,在项目根目录创建 .claude/hookify.{name}.local.md,规则在下次工具使用时动态读取。可用 python3 -c "import re; print(re.search(r'your_pattern', 'test text'))" 测试正则。禁用可设 enabled: false 或删除文件。建议将 .claude/*.local.md 加入 .gitignore。

适用场景:bash 事件匹配危险命令、提权、权限问题;file 事件匹配调试代码、安全风险、敏感文件、生成文件;stop 事件做完成检查清单;prompt 事件匹配用户输入。

限制:资料未提供收费、价格、平台等信息;正则需注意转义与过宽过窄问题,YAML 中建议使用不加引号的 pattern。