pre-merge-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pre-Commit Clean

预提交清理

Two tiers by authority:
  1. Pre-commit pass (automatic, every commit) — clean the staged diff. May edit, but only within code the current change adds or modifies.
  2. Deep cleanup (explicit intent only) — proven cuts anywhere in scope per
    references/cleanup.md
    and
    references/structure.md
    .
Measure twice, cut once — and never force a deletion to look productive. Zero cuts is a valid outcome.
按权限分为两个层级:
  1. 预提交检查(自动执行,每次提交)——清理暂存区的代码差异。可进行编辑,但仅能修改当前变更新增或改动的代码。
  2. 深度清理(仅在明确要求时执行)——根据
    references/cleanup.md
    references/structure.md
    中的规则,对范围内的代码进行经验证的删减。
三思而后行——切勿为了显得有成效而强制删除代码。零删减也是合理结果。

Pre-commit pass

预提交检查

Mandatory before EVERY commit, push, merge, or PR submission — even when nobody asks, and even for trivial or single-file changes. Only formatting-only changes may skip.
  1. Tidy the staged diff: remove dead code the diff introduces, obvious duplication within it, leftover debris (commented-out code, unused imports/variables, debug output), and structural bloat the diff adds (thin wrappers, needless indirection, one-off flags tangling existing flow).
  2. Cut only what the diff itself added or modified, and only with proof: no production consumers, unreachable, no behavior contract touched. Anything reaching beyond the diff is deep cleanup, not this pass.
  3. Run the smallest targeted checks covering the change (typecheck, lint, touched tests).
  4. Report what was cleaned — files/contracts removed, net reduction, check failures; the user still owns the commit itself.
每次commit、push、merge或PR提交前必须执行——即使无人要求,即使是微小的或单文件变更也不例外。仅涉及格式修改的情况可跳过。
  1. 整理暂存区的代码差异:移除差异中引入的死代码、明显的重复代码、遗留冗余内容(注释掉的代码、未使用的导入/变量、调试输出),以及差异新增的结构性冗余(薄包装层、不必要的间接调用、打乱现有流程的一次性标记)。
  2. 仅删减差异本身新增或改动的代码,且必须有依据:确保代码没有生产环境使用者、不可访问、未涉及行为契约。超出当前差异范围的操作属于深度清理,不属于此步骤。
  3. 针对变更运行最小范围的定向检查(类型检查、代码规范检查、受影响的测试)。
  4. 报告清理内容——移除的文件/契约、代码净减少量、检查失败情况;提交操作仍由用户负责。

Deep cleanup

深度清理

Only on explicit user intent; never escalate into edits on your own. Survey the scope first, then apply every safe, proven, in-scope cut end to end per
references/cleanup.md
(deletion proof, protected surfaces) and
references/structure.md
(red lines, simplification targets), without per-item approval, then re-verify the cleanup diff.
仅在用户明确要求时执行;切勿自行升级为编辑操作。首先梳理范围,然后根据
references/cleanup.md
(删除依据、受保护区域)和
references/structure.md
(红线规则、简化目标)中的规则,从头到尾应用所有安全、经验证的范围内删减操作,无需逐项审批,之后重新验证清理后的代码差异。

Honesty rules

诚信规则

  • A candidate is not a deletion; never cut without proof.
  • Never force a deletion to look productive, or equate deletion volume with value.
  • Never equate green tests with proof.
  • 不能仅凭猜测就删除代码;删除必须有依据。
  • 切勿为了显得有成效而强制删除代码,也不要将删除代码的数量等同于价值。
  • 切勿将测试通过等同于删除依据。