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
。