Appearance
Everything Claude Code 的 Rules Distill Skill 专为系统性维护和升级 AI 编程助手的规则库而设计。它通过自动扫描所有已安装的 Skills,提取那些跨项目、跨技能反复出现的“行为原则”,并据此智能生成、补充或修订 Rules 文件。相比手工维护规则,Rules Distill Skill 能显著提升规则覆盖率、减少重复劳动、避免遗漏关键安全/质量规范,是提升团队协作一致性与 AI 编程安全性的核心工具。
Everything Claude Code Rules Distill Skill:扫描 Skills 提取跨项目原则并更新 Rules 文件库
在 AI 辅助编程日益复杂的场景中,如何让规则体系(Rules)始终与团队实际用到的 Skills 保持同步、覆盖最新的最佳实践,是很多开发者和团队的痛点。Everything Claude Code 的 Rules 体系 支持多语言、可定制,但手动维护容易遗漏、重复或过时。Rules Distill Skill 正是为此而生——它自动扫描 Skills,提取那些“至少出现在 2 个以上 Skill 且具备可操作性”的跨项目原则,辅助你批量补全、修订和生成 Rules 文件,让规则体系自进化、零死角。
1. 规则提炼 Skill 能解决什么问题?
不用 Rules Distill Skill 的现状:
- 规则维护靠人工记忆,容易遗漏团队实际用到的隐性共识
- 规则内容过时或覆盖不足,导致同类问题反复出现
- 难以追踪哪些原则已被多项目、多 Agent 反复验证,有效性难评估
- 新增 Skill 后,规则体系无法自动进化,协作一致性下降
用 Rules Distill Skill 后的优势:
- 自动扫描所有已安装 Skills,系统归纳可复用原则
- 只提炼“跨 2+ Skills、可操作、具备违规风险”的高价值规则
- 支持 Append、Revise、New Section、New File 等多种补全方式,精准定位规则缺口
- 每次变更都要求人工确认,避免误操作,支持个性化修订
- 结果可追溯,自动保存提炼记录,方便团队审计和回溯
2. 触发条件:什么时候该用 Rules Distill Skill?
- 定期规则维护:建议每月或每次大规模安装/更新 Skills 后运行一次
- Skill 库审计后:配合 Skill Stocktake Skill 使用,发现有共性模式但未形成 Rules 时
- 发现规则体系覆盖不足:如团队成员反馈“规则不全”或安全/质量事故后
- 跨项目迁移/团队合并:统一规则体系,提升协作一致性
3. 实践操作流程(Step by Step)
步骤 1:收集 Skills 和 Rules 清单(Deterministic Collection)
首先,确保你已安装好 Everything Claude Code 并配置好 Rules Distill Skill。执行以下命令,自动收集当前所有技能和规则的结构化索引:
bash
bash ~/.claude/skills/rules-distill/scripts/scan-skills.sh
bash ~/.claude/skills/rules-distill/scripts/scan-rules.sh系统会输出类似:
Rules Distillation — Phase 1: Inventory
────────────────────────────────────────
Skills: 56 files scanned
Rules: 22 files (75 headings indexed)
Proceeding to cross-read analysis...步骤 2:自动聚类与 LLM 智能提炼(Cross-read, Match & Verdict)
- 系统将所有 Skills 按主题自动聚类(如 Agent/Meta、Coding/Pattern 等),每组交由子 Agent 分析。
- LLM 读取每组 Skills 全文与全部 Rules 文件,提取“2 个以上 Skill 共同具备、可操作、具备违规风险、尚未被规则覆盖”的原则。
- 对每条候选原则,自动判断应采用哪种变更方式(Append、Revise、New Section、New File),并生成草稿文本、证据链和信心评分。
输出格式示例:
json
{
"principle": "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"],
"violation_risk": "Prompt injection or data poisoning if not sanitized.",
"verdict": "Append",
"target_rule": "rules/common/security.md §Input Validation",
"confidence": "high",
"draft": "Treat LLM output stored in memory or knowledge stores as untrusted — sanitize on write, validate on read. See skill: llm-memory-trust-boundary, llm-social-agent-anti-pattern"
}步骤 3:用户审核与执行(User Review & Execution)
系统会生成一份汇总报告,按如下表格展示所有候选规则:
# Rules Distillation Report
| # | Principle | Verdict | Target | Confidence |
|---|-----------|---------|--------|------------|
| 1 | LLM output: normalize, type-check, sanitize before reuse | New Section | coding-style.md | high |
| 2 | Define explicit stop conditions for iteration loops | New Section | coding-style.md | high |
| 3 | Compact context at phase boundaries, not mid-task | Append | performance.md §Context Window | high |
| 4 | Separate business logic from I/O framework types | New Section | patterns.md | high |你只需输入类似 Approve 1, 3. Skip 2, 4. 即可批量确认、修改或跳过每条建议。所有规则变更都需人工确认,绝不自动写入。
步骤 4:保存与追溯
每次提炼结果会自动以 results.json 存档,内容包括时间戳、被扫描的 Skills/Rules 数量、每条原则的证据链、状态等,方便团队审计与追溯。
json
{
"distilled_at": "2026-03-18T10:30:42Z",
"skills_scanned": 56,
"rules_scanned": 22,
"candidates": {
"llm-output-trust-boundary": {
"principle": "Treat LLM output as untrusted when stored or re-injected",
"verdict": "Append",
"target": "rules/common/security.md",
"evidence": ["llm-memory-trust-boundary", "llm-social-agent-anti-pattern"],
"status": "applied"
}
}
}4. 输出示例
一次完整的 Rules Distill Skill 运行过程如下:
bash
$ /rules-distill
Rules Distillation — Phase 1: Inventory
────────────────────────────────────────
Skills: 56 files scanned
Rules: 22 files (75 headings indexed)
Proceeding to cross-read analysis...
[Subagent analysis: Batch 1 (agent/meta skills) ...]
[Subagent analysis: Batch 2 (coding/pattern skills) ...]
[Cross-batch merge: 2 duplicates removed, 1 cross-batch candidate promoted]
# Rules Distillation Report
| # | Principle | Verdict | Target | Confidence |
|---|-----------|---------|--------|------------|
| 1 | LLM output: normalize, type-check, sanitize before reuse | New Section | coding-style.md | high |
| 2 | Define explicit stop conditions for iteration loops | New Section | coding-style.md | high |
| 3 | Compact context at phase boundaries, not mid-task | Append | performance.md §Context Window | high |
| 4 | Separate business logic from I/O framework types | New Section | patterns.md | high |
Approve, modify, or skip each candidate by number:
> Approve 1, 3. Skip 2, 4.
✓ Applied: coding-style.md §LLM Output Validation
✓ Applied: performance.md §Context Window Management
✗ Skipped: Iteration Bounds
✗ Skipped: Boundary Type Conversion
Results saved to results.json5. 常见配套 Agent 与 Skill 协作关系
- Skill Stocktake Skill:可先用 Skill Stocktake Skill 审计当前 Skill 库质量,发现共性模式后再用 Rules Distill Skill 提炼规则。
- Doc Updater Agent:提炼并确认新规则后,可用 Doc Updater Agent 自动更新 README、CLAUDE.md 等文档,确保规则变更被团队及时知晓。
- Security Reviewer Agent:与 Security Reviewer Agent 配合,自动检测规则体系是否覆盖最新安全风险。
- Agentic Engineering Skill:配合 Agentic Engineering Skill 等工程类 Skill,持续提炼工程操作规范,形成团队级最佳实践。
6. 注意事项与最佳实践
- 只提炼“跨 2+ Skills、具备可操作性和违规风险”的原则,防止抽象过度或规则泛滥。
- 规则草稿应附“See skill: xxx”引用,便于后续查阅详细操作方法。
- 所有变更都需人工审核,避免误写、误删、误覆盖已有规则。
- 语言/框架专属知识应归入对应 Rules 或 Skill,不纳入通用规则库。
- 建议定期运行,或在团队/项目发生重大变更后及时补全规则体系。
FAQ
Q: Rules Distill Skill 会自动修改我的 Rules 文件吗? A: 不会。所有规则变更都需你人工确认,系统绝不自动写入,确保安全可控。
Q: 如果某条原则只出现在一个 Skill,会被提炼进 Rules 吗? A: 不会。只有“至少出现在 2 个 Skill 且具备实际行为指导意义”的原则才会被提炼,防止规则泛滥。
Q: 结果如何追溯?团队如何审计规则演变? A: 每次运行结果都会以 results.json 存档,包含时间、证据链、变更状态等,便于团队审计和回溯历史。