From ruler-engine
Use when editing .claude-rules/ruler.yml or .claude-rules/rules/*.md files, or when the user asks to add/modify a project rule, write a ruler entry, or debug why a rule did not trigger. Teaches the ruler.yml schema, matching semantics, best practices, and the ruler-engine CLI (lint + dry-run).
How this skill is triggered — by the user, by Claude, or both
Slash command
/ruler-engine:ruler-authoringThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write rules that the `ruler-engine` plugin injects into Claude's prompt automatically.
Write rules that the ruler-engine plugin injects into Claude's prompt automatically.
.claude-rules/ruler.yml:
version: 1
rules:
- id: <unique-id>
when: always # OR single condition OR array of conditions
inject: rules/<rule-file>.md
when 三种合法形态(互斥)| 形态 | 含义 | 触发时机 |
|---|---|---|
always | 无条件 | 每轮 UserPromptSubmit |
{tool: X, ...} | 单条件 | PreToolUse,且工具=X 时 |
[{...}, {...}] | 多条件 OR | PreToolUse,任一命中即触发 |
不允许混合:[always, {...}] 非法。
<condition> 字段tool(必填):Edit / Write / Read / Bash(首版仅此 4 个)file_glob:bash glob,匹配 file_path;与 Edit/Write/Read 搭配
*(单段通配)、**(跨目录)、?、[abc]command_regex:POSIX 正则,匹配 Bash 的 command 参数file_glob 和 command_regex 互斥每条 rule 一个 md 文件,≤200 字,结构化:
Rule: <一句话核心主张>
Why: <这条规则存在的原因 —— 历史教训 / 领域约束>
How to apply: <如何落到具体动作>
小粒度:一个文件一条规则,不要堆砌。
when: always 数量 ≤5(每轮付 token 成本敏感)file_glob 写宽一点,rule 正文自判边界when: [...] 数组,不要复制粘贴ruler-engine-lint# 校验当前项目的 ruler
ruler-engine-lint
# 模拟 UserPromptSubmit 注入
ruler-engine-dry-run --always
# 模拟 PreToolUse(Edit 场景)
ruler-engine-dry-run --tool=Edit --file=src/App.vue
# 模拟 PreToolUse(Bash 场景)
ruler-engine-dry-run --tool=Bash --command="mysql -u root"
ruler.yml 顶层加 debug: true(后续版本)让 hook 在 stderr 输出匹配过程。当前版本用 ruler-engine-dry-run 手动模拟。
ruler-engine-dry-run 模拟目标场景tool 名拼写(大小写敏感,必须是 Edit 不是 edit)file_glob:单 * 不跨目录,跨目录要 **when: always 规则,或缩减单条 rule 文件长度rule 文件内容会被 hook 注入到 Claude 的 prompt。不要信任外部来源的 rule 文件。.claude-rules/ 必须经 git code review。
npx claudepluginhub djvdio/claude-tools --plugin ruler-engineGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.