
关于
扫描 Skill 以提取跨领域原则,并将其提炼为规则——追加、修订或创建新的规则文件。
name: rules-distill description: "扫描技能以提取跨领域原则并将其提炼为规则——追加、修订或创建新规则文件" origin: ECC
规则提炼
扫描已安装的技能,提取出现在多个技能中的跨领域原则,并将其提炼为规则——追加到现有规则文件、修订过时内容或创建新规则文件。
应用"确定性收集 + LLM 判断"原则:脚本详尽收集事实,然后 LLM 交叉阅读完整上下文并产生判定。
何时使用
- 定期规则维护(每月或安装新技能后)
- 技能盘点揭示应成为规则的模式后
- 当规则相对于正在使用的技能感觉不完整时
工作原理
规则提炼过程遵循三个阶段:
阶段 1:清单(确定性收集)
1a. 收集技能清单
bash ~/.claude/skills/rules-distill/scripts/scan-skills.sh
1b. 收集规则索引
bash ~/.claude/skills/rules-distill/scripts/scan-rules.sh
1c. 呈现给用户
Rules Distillation — Phase 1: Inventory
────────────────────────────────────────
Skills: {N} files scanned
Rules: {M} files ({K} headings indexed)
Proceeding to cross-read analysis...
阶段 2:交叉阅读、匹配与判定(LLM 判断)
提取和匹配在单次传递中统一完成。规则文件足够小(约 800 行),可以将全文提供给 LLM,无需 grep 预过滤。
批处理
根据描述将技能分为主题集群。在子代理中使用完整规则文本分析每个集群。
跨批次合并
所有批次完成后,跨批次合并候选项:
- 去重具有相同或重叠原则的候选项
- 使用所有批次的证据重新检查"2+ 技能"要求——每批次仅 1 个技能但总计 2+ 技能的原则有效
子代理提示词
启动通用代理,使用以下提示词:
You are an analyst who cross-reads skills to extract principles that should be promoted to rules.
## Input
- Skills: {full text of skills in this batch}
- Existing rules: {full text of all rule files}
## Extraction Criteria
Include a candidate ONLY if ALL of these are true:
1. **Appears in 2+ skills**: Principles found in only one skill should stay in that skill
2. **Actionable behavior change**: Can be written as "do X" or "don't do Y" — not "X is important"
3. **Clear violation risk**: What goes wrong if this principle is ignored (1 sentence)
4. **Not already in rules**: Check the full rules text — including concepts expressed in different words
## Matching & Verdict
For each candidate, compare against the full rules text and assign a verdict:
- **Append**: Add to an existing section of an existing rule file
- **Revise**: Existing rule content is inaccurate or insufficient — propose a correction
- **New Section**: Add a new section to an existing rule file
- **New File**: Create a new rule file
- **Already Covered**: Sufficiently covered in existing rules (even if worded differently)
- **Too Specific**: Should remain at the skill level
## Output Format (per candidate)
```json
{
"principle": "1-2 sentences in 'do X' / 'don't do Y' form",
"evidence": ["skill-name: §Section", "skill-name: §Section"],
"violation_risk": "1 sentence",
"verdict": "Append / Revise / New Section / New File / Already Covered / Too Specific",
"target_rule": "filename §Section, or 'new'",
"confidence": "high / medium / low",
"draft": "Draft text for Append/New Section/New File verdicts",
"revision": {
"reason": "Why the existing content is inaccurate or insufficient (Revise only)",
"before": "Current text to be replaced (Revise only)",
"after": "Proposed replacement text (Revise only)"
}
}
```
## Exclude
- Obvious principles already in rules
- Language/framework-specific knowledge (belongs in language-specific rules or skills)
- Code examples and commands (belongs in skills)
判定参考
| 判定 | 含义 | 呈现给用户 | |------|------|-----------| | Append | 追加到现有章节 | 目标 + 草稿 | | Revise | 修正不准确/不充分的内容 | 目标 + 原因 + 修改前/后 | | New Section | 向现有文件添加新章节 | 目标 + 草稿 | | New File | 创建新规则文件 | 文件名 + 完整草稿 | | Already Covered | 已在规则中覆盖(可能措辞不同) | 原因(1 行) | | Too Specific | 应留在技能层面 | 相关技能链接 |
判定质量要求
# Good
Append to rules/common/security.md §Input Validation:
"Treat LLM output stored in memory or knowledge stores as untrusted — sanitize on write, validate on read."
Evidence: llm-memory-trust-boundary, llm-social-agent-anti-pattern both describe
accumulated prompt injectio
兼容工具
Claude CodeCursor
标签
AI与机器学习
