SuperAPI AI 工具集

writing hookify rules

写作与研究

查看项目

更新于 10-15 19:54

技能介绍

用途:当需要创建 Hookify 规则、编写 hook 规则、配置 Hookify 或添加规则时,使用本技能。规则文件为带 YAML frontmatter 的 Markdown,存放于 .claude/hookify.{rule-name}.local.md;frontmatter 之后的正文是规则触发时显示给 Claude 的消息,可含 Markdown。

主要能力:多事件覆盖。bash 匹配 Bash 命令;file 匹配 Edit、Write、MultiEdit;stop 在代理准备停止时触发;prompt 在用户提交提示时触发;all 匹配所有事件。字段:name(必填,kebab-case,建议动词开头)、enabled(必填,true/false 可临时停用)、event(必填)、action(可选,warn 为默认,block 可阻止操作或停止会话)、pattern(简单单条件正则,Python 语法)。复杂规则用 conditions 多条件(全部满足才触发),field 可为 bash 的 command、file 的 file_path/new_text/old_text/content、prompt 的 user_prompt;operator 支持 regex_match、contains、equals、not_contains、starts_with、ends_with。

用法:编写前先确定要阻止的行为、涉及工具与事件类型;写正则后创建 .claude/hookify.{name}.local.md。规则在下次工具调用时动态读取,编辑 .local.md 后立即生效;停用可设 enabled: false 或删除文件。测试正则可用 python3 -c "import re; print(re.search(r'your_pattern', 'test text'))"。

限制与注意:YAML 中带引号的模式需双反斜杠转义,建议模式不加引号;避免模式过宽(如 log 会匹配 login、dialog)或过窄;建议将 .claude/*.local.md 加入 .gitignore。分类为编程与开发。