codify

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Codify

Codify

Move recurring review lessons into the standards file, its
## One-way doors
section, and checker configs. Propose, wait for approval, then write. Never stage, commit, branch, push, or comment on a PR.
将反复出现的评审经验移入标准文件、其
## One-way doors
部分以及 checker 配置。 提出方案,等待批准,然后再写入。 绝不暂存、提交、创建分支、推送,也绝不在 PR 上发表评论。

1. Pin the target and the window

1. 锁定目标与窗口

The target is
.agents/coding-standards.md
, or
CODING_STANDARDS.md
when only that exists. Never
CONTRIBUTING.md
.
The window takes at most one argument:
  • a PR number: that PR alone, merged or not
  • --since <YYYY-MM-DD>
    : PRs merged on or after that date
  • nothing: PRs merged after the newest default-branch commit whose subject starts with
    Codify
    , else the 10 most recently merged
With no GitHub access or an empty window, continue on the user's input alone.
目标是
.agents/coding-standards.md
;如果仅存在
CODING_STANDARDS.md
,则改用后者。 绝不选择
CONTRIBUTING.md
。
窗口最多接受一个参数:
  • PR 编号:仅处理该 PR,无论其是否已合并
  • --since <YYYY-MM-DD>
    :处理在该日期及之后合并的 PR
  • 不传参数:处理在最新一条主题以
    Codify
    开头的默认分支提交之后合并的 PR;如果不存在这样的提交,则处理最近合并的 10 个 PR
如果没有 GitHub 访问权限或窗口内没有 PR,则仅根据用户的输入继续。

2. Ask the user

2. 询问用户

Show the window and its PRs (at most 20), then ask exactly this and wait:
Which review comments did you catch yourself making, in these PRs or anywhere lately?
Each comment is a finding sourced
stated <today's date>
.
显示该窗口及其中的 PR(最多 20 个),然后原样询问以下内容并等待:
你最近在这些 PR 中或其他地方,发现自己提出了哪些反复出现的评审意见?
每条评论都作为一项发现,来源标记为
stated <today's date>
。

3. Gather findings

3. 收集发现

From each PR:
  • human comments (conversation, review, inline), skipping bots and bare approvals
  • review findings left open (such as
    Open:
    lines) in the PR body and commit bodies, plus fixed ones under an
    Address review
    commit subject or PR heading, never review-change
    Fixed:
    lines
  • commits pushed after merge that only the PR body describes, counted once
从每个 PR 中收集:
  • 人工发表的评论(会话评论、评审评论和行内评论),跳过机器人评论和未附带其他意见的批准
  • PR 正文和提交正文中仍未关闭的评审发现(例如
    Open:
    行),以及位于
    Address review
    提交主题或 PR 标题下的已修复发现;绝不采用评审变更中的
    Fixed:
    行
  • 合并后推送、但仅在 PR 正文中有所描述的提交,只计一次

4. Turn findings into rules

4. 将发现转化为规则

Rewrite each finding as the rule it implies, in this repo's own words; one-off bugs, spec gaps and user-only decisions imply none. Group narrowly: a reviewer reading only the rule must flag every finding in it. A rule recurs when the user stated it or its findings span two or more PRs.
Drop a rule a checker already enforces, a generic smell that is not repo-specific, or one the target already states (a sharpen if findings show it is missed). A surviving rule that does not recur goes on the watching list.
使用该仓库自身的措辞,将每项发现改写为其对应的规则;一次性缺陷、规格缺口和仅涉及用户的决策均不产生规则。 进行窄范围归组:仅阅读该规则的评审者必须能够标记出其中包含的每一项发现。 如果用户明确提出某项规则,或者其发现横跨两个或更多 PR,则该规则属于反复出现的规则。
排除以下规则:checker 已经强制执行的规则、不针对该仓库的通用坏味道,或目标文件中已经载明的规则(如果相关发现表明现有规则有所遗漏,则归为 sharpen)。 保留下来的规则如果未反复出现,则放入观察列表。

5. Choose where each recurring rule lands

5. 为每条反复出现的规则选择落点

First fit wins:
  1. check: enable or tighten a rule an installed checker already ships; anything needing a new plugin, custom rule or test is a follow-up, never written
  2. one-way door: a change reverting the code cannot undo, under
    ## One-way doors
  3. standard: everything else, under
    ## Rules
A coding rule in a tracked
AGENTS.md
or
CLAUDE.md
is a move: deleted there, added to the target. Process rules stay.
Above 40 entries under
## Rules
, pair every new standard with a proposed cut or merge.
按以下顺序匹配,命中第一项即停止:
  1. check:启用或收紧已安装 checker 内置提供的规则;任何需要新插件、自定义规则或测试的内容都属于 follow-up,绝不写入
  2. one-way door:代码回退也无法撤销的改动,放在
    ## One-way doors
    下
  3. standard:其他所有规则,放在
    ## Rules
    下
已被 Git 跟踪的
AGENTS.md
或
CLAUDE.md
中的编码规则属于 move:从原位置删除,并添加到目标文件。 流程规则保持不变。
当
## Rules
下的条目超过 40 个时,每项新标准都必须与一项拟议的 cut 或 merge 配对。

6. Propose

6. 提出方案

text
Codify: <window>, PRs <#a, #b> | your input: <n comments | none>
Target: <path> (<n rules | will be created>)

Proposed:
1. [standard | one-way door | sharpen <name> | move <file:line>]
   <the entry, exactly as it will be written>
2. [check] <config>: <change> - <sources>
3. [cut] <name> - <why>

Follow-ups, not written:
- <what to build> - <sources>

Watching, one PR only:
- <rule> - <source>
Sources are PR numbers or
stated <date>
; an empty section reads
- none
; an empty
Proposed
ends the run. Otherwise ask exactly this and wait:
Approve, edit, or drop each numbered item. Reply with the numbers and what to do with each.
text
Codify: <window>, PRs <#a, #b> | your input: <n comments | none>
Target: <path> (<n rules | will be created>)

Proposed:
1. [standard | one-way door | sharpen <name> | move <file:line>]
   <the entry, exactly as it will be written>
2. [check] <config>: <change> - <sources>
3. [cut] <name> - <why>

Follow-ups, not written:
- <what to build> - <sources>

Watching, one PR only:
- <rule> - <source>
来源可以是 PR 编号或
stated <date>
;空的小节写作
- none
;如果
Proposed
为空,则结束本次运行。 否则,原样询问以下内容并等待:
请逐项批准、修改或舍弃每个编号项。请回复各编号以及对应的处理方式。

7. Write what was approved

7. 写入已批准的内容

If the target is missing, create it from references/new-standards-file.md.
Every standard and one-way door is exactly two lines:
markdown
- **<Short name>**: <the rule, one sentence, a must or a never where it is one>
  Why: <one sentence> (<sources>).
Keep the bold name short and unique: other skills cite it. A sharpen replaces in place; a cut deletes.
If a checker config changed, run the project's check command once and report violations in existing code without fixing them.
如果目标文件不存在,则根据 references/new-standards-file.md 创建。
每条标准和 one-way door 都必须恰好写成两行:
markdown
- **<Short name>**: <the rule, one sentence, a must or a never where it is one>
  Why: <one sentence> (<sources>).
保持粗体名称简短且唯一,其他 skill 会引用该名称。 sharpen 原地替换相应内容,cut 则删除相应内容。
如果 checker 配置发生变化,则运行一次项目的 check 命令,并报告现有代码中的违规项,但不要修复。

8. Report

8. 报告

  • changed files, from
    git status --short
  • the check result, or
    not run: no config change
  • follow-ups and watching list
  • a commit message,
    Codify: <#a, #b>
    , which marks where the next window starts
  • a warning if
    git check-ignore <target>
    says the target is gitignored
  • 来自
    git status --short
    的变更文件列表
  • 检查结果,或
    not run: no config change
  • 后续事项与观察列表
  • 一条提交消息
    Codify: <#a, #b>
    ,用于标记下一个窗口的起始位置
  • 如果
    git check-ignore <target>
    表明目标文件被 gitignore,则给出警告