用途:指导编写 Hookify 规则。规则是带 YAML frontmatter 的 Markdown 文件,定义监控模式及匹配时给 Claude 的消息,存放于 .claude/hookify.{rule-name}.local.md 文件。
主要能力:frontmatter 字段含 name(必填,kebab-case、动词开头)、enabled(必填,布尔)、event(必填,bash|file|stop|prompt|all)、action(可选,warn 默认或 block)、pattern(简单正则)。复杂规则用 conditions 多条件,字段 field 可选 command(bash)、file_path/new_text/old_text/content(file)、user_prompt(prompt);operator 支持 regex_match、contains、equals、not_contains、starts_with、ends_with,所有条件需同时满足。frontmatter 之后的 Markdown 正文为触发时展示的消息。
使用方式:按事件类型选择模式。bash 匹配命令;file 匹配编辑操作;stop 用于完成检查;prompt 匹配用户输入。规则按需动态读取,修改后下次工具使用即生效;可在 frontmatter 设 enabled: false 临时禁用,或删除文件永久移除。建议将 .claude/*.local.md 加入 .gitignore。测试正则可用 python3 -c "import re; print(re.search(r'your_pattern', 'test text'))"。
适用场景与限制:适用于危险命令、console.log、敏感文件编辑、完成前检查清单等提示与拦截。正则需注意转义与宽窄度,YAML 中建议使用不带引号的模式以避免双反斜杠问题。具体整合与配置细节暂未提供。