rule
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRule
规则
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 . Reviewing a codebase against all of them runs in .
scopeaudit当用户说“把它设为规则”“始终”“绝不”或“记住这一点”时,就将其写下来。当用户两次纠正同一问题时,应提出一条规则。规则采用成对形式,且应足够简短,以便每次编辑前都能读完。
编辑时遵循规则属于 的职责。依据所有规则审查代码库则属于 。
scopeaudit1. Read what exists
1. 读取现有规则
Read , and the editor rule folders before acting. Acting against a written rule is .
AGENTS.mdCLAUDE.mdrule-read-before-acting采取行动前,先读取 、 和编辑器规则文件夹。未先读取书面规则就采取行动,属于 。
AGENTS.mdCLAUDE.mdrule-read-before-acting2. 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-pair3. 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-short4. Give it one home
4. 设定唯一归属
Put the rule in the file that owns its topic. Copying it into a second file is . When a new rule contradicts an old one, replace the old one and say so. Two contradicting rules left side by side is .
rule-one-homerule-resolve-conflicts将规则放入负责该主题的文件中。将其复制到第二个文件属于 。当新规则与旧规则冲突时,替换旧规则并说明此变更。并列保留两条互相矛盾的规则属于 。
rule-one-homerule-resolve-conflicts5. 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-existingThe pair
配对示例
Every check is a pair. The broken line sits beside the line that replaces it.
| Rule | Broken | Replacement |
|---|---|---|
| A pill button added in a repo whose rules forbid pills | Rules read first, rounded button |
| "Use good casing" | "Labels take Title Case. |
| A paragraph of reasoning | One sentence and a pair |
| One rule in three files | One file, the others point at it |
| "Use borders" beside "never use borders" | The old rule replaced, the change noted |
| The rule added, twelve violations left | The violations fixed and listed |
每项检查都采用成对形式。错误行与替换行并排展示。
| 规则 | 错误示例 | 替换示例 |
|---|---|---|
| 在禁止胶囊形按钮的仓库中添加了胶囊形按钮 | 先读取规则,使用圆角按钮 |
| “使用恰当的大小写” | “标签采用 Title Case。 |
| 一段推理说明 | 一句话加一组配对示例 |
| 同一条规则出现在三个文件中 | 只放在一个文件中,其他文件指向它 |
| “使用边框”与“绝不使用边框”并存 | 替换旧规则,并说明变更 |
| 添加了规则,但遗留十二处违规 | 修复并列出所有违规项 |
Reporting
报告
Severity. is an edit that breaks a written rule, or two rules that contradict. is a rule with no pair, or old violations left after a new rule. is a rule longer than it needs.
HIGHMEDIUMLOWFormat. One finding per root cause:
file:line - [rule-id] what is wrongThen a summary. when any remains, otherwise. Mark every rule file you could not read as .
Rule | Count | SeverityBlockHIGHApproveNot verified严重程度。 表示某项编辑违反了书面规则,或存在两条相互矛盾的规则。 表示规则缺少配对示例,或添加新规则后仍遗留既有违规项。 表示规则写得超出必要长度。
HIGHMEDIUMLOW格式。 每个根本原因仅报告一项发现:
file:line - [rule-id] what is wrong然后提供一份 摘要。只要仍有任何 项,就标记为 ;否则标记为 。将每个无法读取的规则文件标记为 。
Rule | Count | SeverityHIGHBlockApproveNot verified