File contents Rule — Rules to rule
用规则统领代码与智能体输出质量
x rule 是 x-cmd 的质量治理框架。通过 YAML 规则集对代码和智能体输出进行质量检查、评分、修复和迭代。
核心命令
命令
作用
场景
x rule lint <file>
jq 静态验证 rule.yml 格式
提交前自检
x rule scan <target>
贪心快筛,1-5 条最严重问题
agent 内循环迭代
x rule check <target>
全局合规检查,输出所有违规
修复前确认
x rule audit <target>
逐条评分(0-100),出详细报告
最终验证
x rule fix <target>
自主修复循环
自动合规化
x rule refine <report>
根据报告精调规则
规则优化
x rule evolve <target>
根据代码适配规则集
规则扩展
规则文件格式
规则文件以 .rule.yml 结尾,每条规则包含:
rule-id:
name: rule-name # 可选,简短标签
apply: "shell files" # 可选,适用文件类型
level: error # error/must/warn/info/debug
desc: # 必填,规则描述(列表)
- 描述文字
tldr: # 可选,正确/错误示例
- wrong: 错误代码
right: 正确代码
memo: # 可选,补充说明
- 备注
示例
# 验证规则文件格式
x rule lint lib/po6/local.rule.yml
# 快筛代码问题
x rule scan src/
# 全量检查
x rule check -r lib/po6 src/
# 审计并出报告
x rule audit -o /tmp/report lib/
# 自主修复
x rule fix src/
内部工具
x rule ls — 列出规则集
x rule which — 显示规则集路径
x rule preset ls — 列出预设规则集
架构
rule/
├── lib/
│ ├── *.rule.yml # 规则文件(*.rule.yml 结尾)
│ ├── jq/lint.jq # jq 静态验证过滤器
│ ├── scan|check|audit|fix|refine|evolve|lint # 子命令
│ └── preset-data/ # 内置预设规则集
└── adv/index.yml # 命令行补全配置
关联
SKILL.md 在 /Users/l/.x-cmd.root/v/.repo/x-bash/rule/SKILL.md
story 在 .x-cmd/story/ 目录下
1 --- 2 name: rule 3 description: Rule — Rules to rule 4 --- 5 # Rule — Rules to rule 6 7 > 用规则统领代码与智能体输出质量 8 9 `x rule` 是 x-cmd 的质量治理框架。通过 YAML 规则集对代码和智能体输出进行质量检查、评分、修复和迭代。 10 11 ## 核心命令 12 13 | 命令 | 作用 | 场景 | 14 |------|------|------| 15 | `x rule lint <file>` | jq 静态验证 rule.yml 格式 | 提交前自检 | 16 | `x rule scan <target>` | 贪心快筛,1-5 条最严重问题 | agent 内循环迭代 | 17 | `x rule check <target>` | 全局合规检查,输出所有违规 | 修复前确认 | 18 | `x rule audit <target>` | 逐条评分(0-100),出详细报告 | 最终验证 | 19 | `x rule fix <target>` | 自主修复循环 | 自动合规化 | 20 | `x rule refine <report>` | 根据报告精调规则 | 规则优化 | 21 | `x rule evolve <target>` | 根据代码适配规则集 | 规则扩展 | 22 23 ## 规则文件格式 24 25 规则文件以 `.rule.yml` 结尾,每条规则包含: 26 27 ```yaml 28 rule-id: 29 name: rule-name # 可选,简短标签 30 apply: "shell files" # 可选,适用文件类型 31 level: error # error/must/warn/info/debug 32 desc: # 必填,规则描述(列表) 33 - 描述文字 34 tldr: # 可选,正确/错误示例 35 - wrong: 错误代码 36 right: 正确代码 37 memo: # 可选,补充说明 38 - 备注 39 ``` 40 41 ## 示例 42 43 ```bash 44 # 验证规则文件格式 45 x rule lint lib/po6/local.rule.yml 46 47 # 快筛代码问题 48 x rule scan src/ 49 50 # 全量检查 51 x rule check -r lib/po6 src/ 52 53 # 审计并出报告 54 x rule audit -o /tmp/report lib/ 55 56 # 自主修复 57 x rule fix src/ 58 ``` 59 60 ## 内部工具 61 62 - `x rule ls` — 列出规则集 63 - `x rule which` — 显示规则集路径 64 - `x rule preset ls` — 列出预设规则集 65 66 ## 架构 67 68 ``` 69 rule/ 70 ├── lib/ 71 │ ├── *.rule.yml # 规则文件(*.rule.yml 结尾) 72 │ ├── jq/lint.jq # jq 静态验证过滤器 73 │ ├── scan|check|audit|fix|refine|evolve|lint # 子命令 74 │ └── preset-data/ # 内置预设规则集 75 └── adv/index.yml # 命令行补全配置 76 ``` 77 78 ## 关联 79 80 - SKILL.md 在 `/Users/l/.x-cmd.root/v/.repo/x-bash/rule/SKILL.md` 81 - story 在 `.x-cmd/story/` 目录下
x-cmd/x-cmd/tree/main/mod/rule commit c354068e3f
Frequently asked questions How do I install the Rule skill? Run npx skillmds@latest add x-cmd/rule in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Rule skill do? Rule — Rules to rule It is listed under Coding & Dev Tools on SkillMD.
Is Rule safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Rule? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Rule free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Rule? x-cmd (@x-cmd) published this skill. Their other Agent Skills are listed on their SkillMD profile.