mcpField
R
rule-catalog

rule-catalog

github.com/atholaAgent 工作流34397 次安装1 天前更新
代码仓库

关于 rule-catalog

Hookify 的预构建规则目录技能,按类别浏览并将现成规则安装到项目中,也可作为自定义规则的模板。适合希望先查找并采用标准规则、而非从头编写规则的场景。

主要功能

  1. 01按类别浏览预构建规则
  2. 02安装单条或整类规则
  3. 03支持 Python 脚本批量安装
  4. 04调整规则动作、启用状态和模式

适用场景

  1. 01阻止向主分支强制推送
  2. 02为 Python 和安全操作添加规则
  3. 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.md
warn-slop-in-markdown.md
rules/git/
block-destructive-git.md
block-force-push.md
warn-large-commits.md
warn-risky-git.md
rules/performance/
warn-large-file-ops.md
rules/python/
block-dynamic-code.md
warn-print-statements.md
rules/security/
destructive-command-guard.md
require-security-review.md
rules/stewardship/
campsite-check.md
rules/workflow/
enforce-scope-guard.md
plan-before-large-dispatch.md
require-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 将:

  1. 从 skills/rule-catalog/rules/git/block-force-push.md 读取规则
  2. 将其写入 .claude/hookify.block-force-push.local.md
  3. 确认安装完成
方法 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:手动复制
  1. 在 plugins/hookify/skills/rule-catalog/rules/<category>/<rule>.md 中找到规则
  2. 复制到 .claude/hookify.<rule-name>.local.md
  3. 根据需要编辑 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

要将规则加入目录:

  1. 在相应类别中创建规则文件
  2. 遵循命名约定:kebab-case.md
  3. 编写包含替代方案的详细说明
  4. 提交前进行全面测试
  5. 更新此 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