Communitygithub.com

rules-distill

扫描已安装的技能,提取跨技能出现的通用原则,并将其提炼为规则文件——追加、修订或新建规则文件。适合在多个技能中反复出现相同原则时应使用。

rules-distill 是什么?

Rules Distill 是一种用于维护和优化 AI 代理技能规则的元技能。它的核心价值在于解决技能库膨胀导致的规则碎片化和重复问题:当同一原则在多个技能中反复出现时,将其提升为全局规则,避免重复定义并确保一致性。该技能遵循「确定性收集 + LLM 判断」的设计原则:首先通过 Shell 脚本穷举扫描已安装的技能和现有规则文件,生成完整的存货清单;然后利用 LLM 的上下文理解能力,对技能集群进行跨读分析,识别出应该在 2 个以上技能中出现的跨领域原则,并给出追加、修订或创建新规则文件的裁决。整个过程分为三个阶段:盘点(确定性收集)、跨读与裁决(LLM 判断)、用户审核与执行。最终结果以结构化的 JSON 保存,并在应用任何规则变更前要求用户审核,避免自动修改。支持 Claude Code 等通过 SKILL.md 管理技能的代理平台,且兼容任何 bash 可用的环境。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/rules-distill

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Rules Distill

扫描已安装的技能,提取跨多个技能出现的通用原则,并将其提炼为规则——追加到现有规则文件、修订过时的内容或创建新的规则文件。

应用「确定性收集 + LLM 判断」原则:脚本穷举收集事实,然后 LLM 跨读完整上下文并做出裁决。

何时使用

  • 定期进行规则维护(每月一次或安装新技能后)
  • 在技能库盘点后发现可抽象为规则的模式时
  • 当前规则相对正在使用的技能感觉不完整时

工作原理

规则提炼过程分为三个阶段:

阶段 1:盘点(确定性收集)

1a. 收集技能清单

bash ~/.claude/skills/rules-distill/scripts/scan-skills.sh

1b. 收集规则索引

bash ~/.claude/skills/rules-distill/scripts/scan-rules.sh

1c. 向用户展示

规则提炼 —— 阶段 1:盘点
────────────────────────────────────────
技能:{N} 个文件已扫描
规则:{M} 个文件({K} 个标题已索引)

正在进入跨读分析...

阶段 2:跨读、匹配与裁决(LLM 判断)

提取和合并在一次遍历中完成。规则文件足够小(总计约 800 行),可以将全文提供给 LLM——无需 grep 预过滤。

分批处理

根据技能描述将其分组为主题集群。在子代理中分析每个集群,并提供完整的规则文本。

跨批合并

所有批次完成后,跨批次合并候选规则:

  • 对包含相同或重叠原则的候选规则去重
  • 使用所有批次的证据重新检查「2+ 个技能」要求——一个原则在每个批次中仅出现在 1 个技能中,但总计出现在 2+ 个技能中是有效的

子代理提示词

使用以下提示词启动通用代理:

你是一名分析师,跨读技能以提取应提升为规则的原则。

## 输入
- 技能:{此批次中所有技能的全文}
- 现有规则:{所有规则文件的全文}

## 提取条件

仅当以下条件**全部**满足时才包含候选规则:

1. **出现在 2 个以上技能中**:仅出现在一个技能中的原则应保留在该技能中
2. **可操作的行为变更**:可以写成「做 X」或「不要做 Y」——而非「X 很重要」
3. **明确的违规风险**:如果忽略此原则会出现什么问题(一句话)
4. **尚未出现在规则中**:检查完整的规则文本——包括以不同措辞表达的概念

## 匹配与裁决

对于每个候选规则,与完整的规则文本进行比较,并给出裁决:

- **追加**:添加到现有规则文件的现有章节
- **修订**:现有规则内容不准确或不充分——提出修正
- **新章节**:向现有规则文件添加新章节
- **新文件**:创建新的规则文件
- **已涵盖**:现有规则已充分涵盖(即使措辞不同)
- **过于具体**:应保持在技能层面

## 输出格式(每个候选规则)

```json
{
  "principle": "1-2 句话,采用「做 X」/「不要做 Y」形式",
  "evidence": ["技能名称: §章节", "技能名称: §章节"],
  "violation_risk": "一句话",
  "verdict": "追加 / 修订 / 新章节 / 新文件 / 已涵盖 / 过于具体",
  "target_rule": "文件名 §章节, 或 '新文件'",
  "confidence": "高 / 中 / 低",
  "draft": "为追加/新章节/新文件裁决提供的草稿文本",
  "revision": {
    "reason": "现有内容不准确或不充分的原因(仅修订时)",
    "before": "要替换的当前文本(仅修订时)",
    "after": "建议的替换文本(仅修订时)"
  }
}
```

## 排除

- 已在规则中的明显原则
- 语言/框架特定的知识(属于特定语言的规则或技能)
- 代码示例和命令(属于技能)

裁决参考表

裁决含义向用户展示
追加添加到现有章节目标 + 草稿
修订修复不准确/不充分的内容目标 + 原因 + 修改前后对照
新章节向现有文件添加新章节目标 + 草稿
新文件创建新的规则文件文件名 + 完整草稿
已涵盖已包含在规则中(可能措辞不同)原因(一行)
过于具体应保留在技能中指向相关技能的链接

裁决质量要求

# 好
追加到 rules/common/security.md §输入验证:
「将存储在内存或知识库中的 LLM 输出视为不受信任——写入时清理,读取时验证。」
证据:llm-memory-trust-boundary, llm-social-agent-anti-pattern 都描述了
积累的提示注入风险。当前的 security.md 仅覆盖了人类输入验证;LLM 输出信任边界缺失。

# 差
追加到 security.md:添加 LLM 安全原则

阶段 3:用户审核与执行

汇总表

# 规则提炼报告

## 摘要
技能已扫描:{N} | 规则:{M} 个文件 | 候选规则:{K}

| # | 原则 | 裁决 | 目标 | 置信度 |
|---|-----------|---------|--------|------------|
| 1 | ... | 追加 | security.md §输入验证 | 高 |
| 2 | ... | 修订 | testing.md §TDD | 中 |
| 3 | ... | 新章节 | coding-style.md | 高 |
| 4 | ... | 过于具体 | — | — |

## 详细信息
(每个候选规则的详细信息:证据、违规风险、草稿文本)

用户操作

用户输入编号做出响应:

  • 批准:按原样将草稿应用到规则中
  • 修改:在应用前编辑草稿
  • 跳过:不应用此候选规则

切勿自动修改规则。始终需要用户批准。

保存结果

将结果存储在技能目录(results.json)中:

  • 时间戳格式:date -u +%Y-%m-%dT%H:%M:%SZ(UTC,秒级精度)
  • 候选规则 ID 格式:根据原则派生的 kebab-case(例如 llm-output-trust-boundary)
{
  "distilled_at": "2026-03-18T10:30:42Z",
  "skills_scanned": 56,
  "rules_scanned": 22,
  "candidates": {
    "llm-output-trust-boundary": {
      "principle": "将 LLM 输出在存储或重新注入时视为不受信任",
      "verdict": "追加",
      "target": "rules/common/security.md",
      "evidence": ["llm-memory-trust-boundary", "llm-social-agent-anti-pattern"],
      "status": "已应用"
    },
    "iteration-bounds": {
      "principle": "为所有迭代循环定义明确的停止条件",
      "verdict": "新章节",
      "target": "rules/common/coding-style.md",
      "evidence": ["iterative-retrieval", "continuous-agent-loop", "agent-harness-construction"],
      "status": "已跳过"
    }
  }
}

示例

端到端运行

$ /rules-distill

规则提炼 —— 阶段 1:盘点
────────────────────────────────────────
技能:56 个文件已扫描
规则:22 个文件(75 个标题已索引)

正在进入跨读分析...

[子代理分析:批次 1(代理/元技能)...]
[子代理分析:批次 2(编码/模式技能)...]
[跨批合并:已移除 2 个重复项,已提升 1 个跨批候选规则]

# 规则提炼报告

## 摘要
技能已扫描:56 | 规则:22 个文件 | 候选规则:4

| # | 原则 | 裁决 | 目标 | 置信度 |
|---|-----------|---------|--------|------------|
| 1 | LLM 输出:在使用前进行归一化、类型检查和清理 | 新章节 | coding-style.md | 高 |
| 2 | 为迭代循环定义明确的停止条件 | 新章节 | coding-style.md | 高 |
| 3 | 在阶段边界处压缩上下文,而非任务中途 | 追加 | performance.md §上下文窗口 | 高 |
| 4 | 将业务逻辑与 I/O 框架类型分离 | 新章节 | patterns.md | 高 |

## 详细信息

### 1. LLM 输出验证
裁决:在 coding-style.md 中新建章节
证据:parallel-subagent-batch-merge, llm-social-agent-anti-pattern, llm-memory-trust-boundary
违规风险:LLM 输出的格式漂移、类型不匹配或语法错误会导致下游处理崩溃
草稿:
  ## LLM 输出验证
  在使用前对 LLM 输出进行归一化、类型检查和清理...
  参见技能:parallel-subagent-batch-merge, llm-memory-trust-boundary

[... 候选规则 2-4 的详细信息 ...]

请按编号批准、修改或跳过每个候选规则:
> 用户:批准 1、3。跳过 2、4。

✓ 已应用:coding-style.md §LLM 输出验证
✓ 已应用:performance.md §上下文窗口管理
✗ 已跳过:迭代边界
✗ 已跳过:边界类型转换

结果已保存到 results.json

设计原则

  • 是什么,而非怎么做:只提取原则(规则领域)。代码示例和命令保留在技能中。
  • 向后链接:草稿文本应包含「参见技能:[名称]」引用,以便读者找到详细的「怎么做」。
  • 确定性收集,LLM 判断:脚本保证穷尽性;LLM 保证上下文理解。
  • 反抽象防护:三层过滤器(2+ 技能证据、可操作行为测试、违规风险)防止过于抽象的原则进入规则。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能