关于 rule-catalog
Hookify 的预构建规则目录技能,按类别浏览并将现成规则安装到项目中,也可作为自定义规则的模板。适合希望先查找并采用标准规则、而非从头编写规则的场景。
主要功能
- 01按类别浏览预构建规则
- 02安装单条或整类规则
- 03支持 Python 脚本批量安装
- 04调整规则动作、启用状态和模式
适用场景
- 01阻止向主分支强制推送
- 02为 Python 和安全操作添加规则
- 03批量安装某一类别的规则
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ athola/ claude-night-market --skill rule-catalog安装后在 Claude Code 中输入/rule-catalog确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
rules/documentation/require-slop-scan-for-docs.mdwarn-slop-in-markdown.mdrules/git/block-destructive-git.mdblock-force-push.mdwarn-large-commits.mdwarn-risky-git.mdrules/performance/warn-large-file-ops.mdrules/python/block-dynamic-code.mdwarn-print-statements.mdrules/security/destructive-command-guard.mdrequire-security-review.mdrules/stewardship/campsite-check.mdrules/workflow/enforce-scope-guard.mdplan-before-large-dispatch.mdrequire-spec-before-code.md详细介绍
适用场景
- 按类别浏览可用的 hookify 规则
- 将标准预构建规则安装到项目中
- 编写自定义规则前,查找现成规则
不适用场景
- 从头编写自定义规则:请改用
hookify:writing-rules - 调试或修改已安装的规则
- 转换 Python SDK hooks:请改用
hookify:from-hook
Hookify 规则目录
适用于常见场景的预构建规则。可直接安装或用作模板。
快速安装
# Install a specific rule
Skill(hookify:rule-catalog) then install git:block-force-push
# Or use the Python installer for bulk operations
python3 plugins/hookify/scripts/install_rule.py git:block-force-push
python3 plugins/hookify/scripts/install_rule.py --category git
python3 plugins/hookify/scripts/install_rule.py --all
**验证:**运行 python --version,确认 Python 环境正常。
可用规则
git/ - Git 安全
| 规则 | 操作 | 默认状态 | 描述 |
|---|---|---|---|
block-force-push | 阻止 | 已启用 | 阻止强制推送到 main/master |
block-destructive-git | 阻止 | 已启用 | 阻止 reset --hard、checkout -- .、clean -fd 等操作 |
warn-risky-git | 警告 | 已启用 | 对 rebase -i、soft reset 等操作发出警告 |
warn-large-commits | 警告 | 已启用 | 对大型二进制文件发出警告 |
python/ - Python 质量
| 规则 | 操作 | 默认状态 | 描述 |
|---|---|---|---|
block-dynamic-code | 阻止 | 已启用 | 阻止危险的动态代码执行 |
warn-print-statements | 警告 | 已启用 | 鼓励使用日志记录,而不是 print() |
security/ - 安全门禁
| 规则 | 操作 | 默认状态 | 描述 |
|---|---|---|---|
require-security-review | 阻止 | 已启用 | 要求对身份验证代码进行审查 |
destructive-command-guard | 警告 | 已启用 | 对目标路径类似生产环境的破坏性命令发出警告 |
workflow/ - 工作流约束
| 规则 | 操作 | 默认状态 | 描述 |
|---|---|---|---|
enforce-scope-guard | 警告 | 已启用 | 防止过度设计(imbue) |
require-spec-before-code | 阻止 | 已禁用 | 规范优先开发 |
performance/ - 资源管理
| 规则 | 操作 | 默认状态 | 描述 |
|---|---|---|---|
warn-large-file-ops | 警告 | 已启用 | 监控大型文件写入 |
安装说明
方法 1:Claude 辅助安装(推荐)
调用此技能时,告诉 Claude 要安装哪些规则:
**Verification:** Run `git status` to confirm working tree state.
Install git:block-force-push
**验证:**使用 --help 标志运行命令,确认命令可用。
Claude 将:
- 从
skills/rule-catalog/rules/git/block-force-push.md读取规则 - 将其写入
.claude/hookify.block-force-push.local.md - 确认安装完成
方法 2:Python 脚本
适用于批量操作或自动化:
# Install single rule
python3 plugins/hookify/scripts/install_rule.py git:block-force-push
# Install all rules in category
python3 plugins/hookify/scripts/install_rule.py --category python
# Install all rules
python3 plugins/hookify/scripts/install_rule.py --all
# List available rules
python3 plugins/hookify/scripts/install_rule.py --list
# Install to custom directory
python3 plugins/hookify/scripts/install_rule.py git:block-force-push --target /path/to/.claude
**验证:**使用 --help 标志运行命令,确认命令可用。
方法 3:手动复制
- 在
plugins/hookify/skills/rule-catalog/rules/<category>/<rule>.md中找到规则 - 复制到
.claude/hookify.<rule-name>.local.md - 根据需要编辑
enabled: true/false
规则文件位置
规则存储在相对于此技能的位置:
**Verification:** Run the command with `--help` flag to verify availability.
skills/rule-catalog/
├── SKILL.md (this file)
└── rules/
├── git/
│ ├── block-force-push.md
│ ├── block-destructive-git.md
│ ├── warn-risky-git.md
│ └── warn-large-commits.md
├── python/
│ ├── block-dynamic-code.md
│ └── warn-print-statements.md
├── security/
│ ├── require-security-review.md
│ └── destructive-command-guard.md
├── workflow/
│ ├── enforce-scope-guard.md
│ └── require-spec-before-code.md
└── performance/
└── warn-large-file-ops.md
**验证:**使用 --help 标志运行命令,确认命令可用。
自定义规则
安装后,在 .claude/ 中编辑规则:
# Change action from warn to block
action: block
# Disable temporarily
enabled: false
# Modify pattern
pattern: your-custom-pattern
**验证:**使用 --help 标志运行命令,确认命令可用。
为新规则创建 Pull Request
要将规则加入目录:
- 在相应类别中创建规则文件
- 遵循命名约定:
kebab-case.md - 编写包含替代方案的详细说明
- 提交前进行全面测试
- 更新此 SKILL.md 目录表
相关内容
Skill(hookify:writing-rules)- 创建自定义规则/hookify:list- 显示已安装的规则/hookify:configure- 管理已安装的规则
退出条件
- 已安装的规则文件位于
.claude/hookify.<rule-name>.local.md,且其 frontmatter 中包含enabled: true - 规则无需重启会话即可触发;通过触发匹配模式并观察警告或阻止响应进行验证
- 通过 Python 脚本安装时,返回退出代码 0,且规则文件存在于目标路径
- 规则文件结构与目录源文件
skills/rule-catalog/rules/<category>/<rule>.md一致;安装过程中没有字段被静默丢弃
评论
支持 Markdown