一键导入
cmd-rules-distill
Scan installed skills to extract cross-cutting principles and distill them into rules — append, revise, or create new rule files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scan installed skills to extract cross-cutting principles and distill them into rules — append, revise, or create new rule files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Audit all installed OpenClaw skills for quality: content overlap, freshness, and uniqueness. Supports Quick Scan (changed only) and Full Stocktake modes.
Cluster MEMORY.md entries by theme and optionally generate SKILL.md drafts.
Export MEMORY.md to a timestamped markdown file for sharing or backup.
Import memory entries from a markdown export file, merging with MEMORY.md without duplicating.
Show current workspace memory: MEMORY.md contents, pending recalls, and index status.
List all OpenClaw agent workspaces with memory and session statistics.
| name | cmd_rules_distill |
| description | Scan installed skills to extract cross-cutting principles and distill them into rules — append, revise, or create new rule files. |
| user-invocable | true |
| origin | openclaw-mas |
| argument-hint | <project-path> [--apply] |
The first argument is the project path. Before doing anything else:
Scan installed skills, extract cross-cutting principles that appear in multiple skills, and distill them into rules — appending to existing rule files, revising outdated content, or creating new rule files.
Applies the "deterministic collection + LLM judgment" principle: bash commands collect facts exhaustively, then a subagent cross-reads the full context and produces verdicts.
/skill cmd_rules_distill <project-path> # Analyze and present candidates
/skill cmd_rules_distill <project-path> --apply # Analyze and auto-apply approved candidates
Enumerate all installed skill files:
find ~/.openclaw/skills/ <project-path>/skills/ -name "SKILL.md" 2>/dev/null
For each SKILL.md, extract the first 30 lines (frontmatter + opening context):
find ~/.openclaw/skills/ -name "SKILL.md" 2>/dev/null \
| while read f; do echo "=== $f ==="; head -30 "$f"; echo; done
Count total skills found.
Enumerate all rule files:
find ~/.claude/rules/ -name "*.md" 2>/dev/null
For each rule file, count ##-level headings:
find ~/.claude/rules/ -name "*.md" 2>/dev/null \
| while read f; do echo "$(grep -c '^##' "$f") headings: $f"; done
Read all rule files in full (they are small — typically <800 lines total).
Rules Distillation — Phase 1: Inventory
────────────────────────────────────────
Skills: <N> files scanned
Rules: <M> files (<K> headings indexed)
Proceeding to cross-read analysis...
Rules files are small enough that the full text can be provided to the LLM — no grep pre-filtering needed.
Group skills into thematic clusters based on their descriptions. Analyze each cluster in a subagent with the full rules text.
After all batches complete, merge candidates across batches:
Launch a general-purpose Agent with the following prompt:
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)
| Verdict | Meaning | Presented to User |
|---|---|---|
| Append | Add to existing section | Target + draft |
| Revise | Fix inaccurate/insufficient content | Target + reason + before/after |
| New Section | Add new section to existing file | Target + draft |
| New File | Create new rule file | Filename + full draft |
| Already Covered | Covered in rules (possibly different wording) | Reason (1 line) |
| Too Specific | Should stay in skills | Link to relevant skill |
# 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 injection risks. Current security.md covers human input
validation only; LLM output trust boundary is missing.
# Bad
Append to security.md: Add LLM security principle
# Rules Distillation Report
## Summary
Skills scanned: <N> | Rules: <M> files | Candidates: <K>
| # | Principle | Verdict | Target | Confidence |
|---|-----------|---------|--------|------------|
| 1 | ... | Append | security.md §Input Validation | high |
| 2 | ... | Revise | testing.md §TDD | medium |
| 3 | ... | New Section | coding-style.md | high |
| 4 | ... | Too Specific | — | — |
## Details
(Per-candidate details: evidence, violation_risk, draft text)
User responds with numbers to:
Never modify rules automatically. Always require user approval.
If --apply is passed, present the summary table first and ask the user to approve
candidates by number before writing anything.
Store results in <project-path>/rules-distill-results.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"
}
}
}
Get the current UTC timestamp:
date -u +%Y-%m-%dT%H:%M:%SZ
See skill: [name] references so readers
can find the detailed How.The first argument is the project path. Before doing anything else:
Use this only if you still invoke /rules-distill. The maintained workflow lives in skills/rules-distill/SKILL.md.
rules-distill skill directly.$ARGUMENTS
Apply the rules-distill skill and follow its inventory, cross-read, and verdict workflow instead of duplicating that logic here.