rule

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rule

规则

This skill turns a correction into a written rule. It writes the rule once in the right file, then fixes the code that already breaks it.
此 skill 会将一次纠正转化为书面规则。它会将规则写入正确的文件(仅写一次),然后修复现有代码中违反该规则的部分。

Twice is a rule

重复两次即成规则

When the user says "make it a rule", "always", "never" or "remember this", write it down. When they correct the same thing twice, propose a rule. A rule is a pair, short enough to read before every edit.
Following the rules while editing belongs to
scope
. Reviewing a codebase against all of them runs in
audit
.
当用户说“把它设为规则”“始终”“绝不”或“记住这一点”时,就将其写下来。当用户两次纠正同一问题时,应提出一条规则。规则采用成对形式,且应足够简短,以便每次编辑前都能读完。
编辑时遵循规则属于
scope
的职责。依据所有规则审查代码库则属于
audit
。

1. Read what exists

1. 读取现有规则

Read
AGENTS.md
,
CLAUDE.md
and the editor rule folders before acting. Acting against a written rule is
rule-read-before-acting
.
采取行动前,先读取
AGENTS.md
、
CLAUDE.md
和编辑器规则文件夹。未先读取书面规则就采取行动,属于
rule-read-before-acting
。

2. Write the pair

2. 写出配对示例

State the rule in one sentence, then the broken line and the line that replaces it. A rule with no example is
rule-write-the-pair
.
用一句话陈述规则,然后列出错误行及其替换行。缺少示例的规则属于
rule-write-the-pair
。

3. Keep it short

3. 保持简短

One rule is one to three sentences plus its pair. A paragraph of reasoning is
rule-keep-it-short
.
一条规则包含一到三句话,以及对应的错误行与替换行。一段推理说明属于
rule-keep-it-short
。

4. Give it one home

4. 设定唯一归属

Put the rule in the file that owns its topic. Copying it into a second file is
rule-one-home
. When a new rule contradicts an old one, replace the old one and say so. Two contradicting rules left side by side is
rule-resolve-conflicts
.
将规则放入负责该主题的文件中。将其复制到第二个文件属于
rule-one-home
。当新规则与旧规则冲突时,替换旧规则并说明此变更。并列保留两条互相矛盾的规则属于
rule-resolve-conflicts
。

5. Sweep the code

5. 全面检查代码

Search for code that breaks the new rule, fix it and list the files. A rule written with old violations left in place is
rule-sweep-existing
.
搜索违反新规则的代码,修复这些问题并列出相关文件。写入新规则却遗留既有违规项,属于
rule-sweep-existing
。

The pair

配对示例

Every check is a pair. The broken line sits beside the line that replaces it.
RuleBrokenReplacement
rule-read-before-acting
A pill button added in a repo whose rules forbid pillsRules read first, rounded button
rule-write-the-pair
"Use good casing""Labels take Title Case.
Add to library
becomes
Add to Library
"
rule-keep-it-short
A paragraph of reasoningOne sentence and a pair
rule-one-home
One rule in three filesOne file, the others point at it
rule-resolve-conflicts
"Use borders" beside "never use borders"The old rule replaced, the change noted
rule-sweep-existing
The rule added, twelve violations leftThe violations fixed and listed
每项检查都采用成对形式。错误行与替换行并排展示。
规则错误示例替换示例
rule-read-before-acting
在禁止胶囊形按钮的仓库中添加了胶囊形按钮先读取规则,使用圆角按钮
rule-write-the-pair
“使用恰当的大小写”“标签采用 Title Case。
Add to library
变为
Add to Library
”
rule-keep-it-short
一段推理说明一句话加一组配对示例
rule-one-home
同一条规则出现在三个文件中只放在一个文件中,其他文件指向它
rule-resolve-conflicts
“使用边框”与“绝不使用边框”并存替换旧规则,并说明变更
rule-sweep-existing
添加了规则,但遗留十二处违规修复并列出所有违规项

Reporting

报告

Severity.
HIGH
is an edit that breaks a written rule, or two rules that contradict.
MEDIUM
is a rule with no pair, or old violations left after a new rule.
LOW
is a rule longer than it needs.
Format. One finding per root cause:
file:line - [rule-id] what is wrong
Then a
Rule | Count | Severity
summary.
Block
when any
HIGH
remains,
Approve
otherwise. Mark every rule file you could not read as
Not verified
.
严重程度。
HIGH
表示某项编辑违反了书面规则,或存在两条相互矛盾的规则。
MEDIUM
表示规则缺少配对示例,或添加新规则后仍遗留既有违规项。
LOW
表示规则写得超出必要长度。
格式。 每个根本原因仅报告一项发现:
file:line - [rule-id] what is wrong
然后提供一份
Rule | Count | Severity
摘要。只要仍有任何
HIGH
项,就标记为
Block
;否则标记为
Approve
。将每个无法读取的规则文件标记为
Not verified
。