remove-dumb-comments

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Remove Dumb Comments

移除无意义注释

Flag comments that say what the code already says; keep every comment that explains why. The user chooses which flagged comments to remove.
标记那些仅说明代码「做了什么」的注释;保留所有解释代码「为什么这么做」的注释。由用户决定移除哪些被标记的注释。

Invocation

调用方式

CommandBehavior
/remove-dumb-comments
Find the 10 lowest-value comments.
/remove-dumb-comments <number>
Find that many lowest-value comments.
/remove-dumb-comments all
Find every low-value comment.
命令行为
/remove-dumb-comments
查找10条价值最低的注释。
/remove-dumb-comments <number>
查找指定数量的价值最低注释。
/remove-dumb-comments all
查找所有低价值注释。

Never Remove

禁止移除的注释类型

Keep any comment that carries a why the code cannot convey:
  • backports, compatibility, or version-specific behavior;
  • infrastructure, deployment, or architecture;
  • workarounds, gotchas, or non-obvious reasons;
  • documentation, specifications, RFCs, or ADRs;
  • bugs, issues, tickets, or contextual TODOs/FIXMEs;
  • intent, trade-offs, or constraints.
When unsure, keep it. Flag only pure restatements.
保留任何代码无法传达「原因」的注释:
  • 回退补丁、兼容性或特定版本行为相关内容;
  • 基础设施、部署或架构相关说明;
  • 临时解决方案、陷阱或非显而易见的实现原因;
  • 文档、规范、RFC或ADR相关内容;
  • 缺陷、问题工单或带上下文的TODO/FIXME标记;
  • 设计意图、权衡取舍或约束条件说明。
若不确定,保留该注释。仅标记纯粹复述代码的注释。

Workflow

工作流程

  1. Resolve the limit from the invocation (default 10).
  2. Search source files; skip generated output, vendored dependencies, lockfiles, and documentation.
  3. Rank candidates from most redundant to least.
  4. Get each candidate's age with
    git blame
    (see Comment Age).
  5. Present the table below, then ask whether to remove all recommended (see Feedback).
  6. If yes, treat every
    Remove
    item as approved. If no, ask
    Remove
    or
    Keep
    for each, naming it by its exact text, not its location.
  7. Remove only the approved comments.
  8. Run the project's lint and typecheck; fix anything the changes broke.
Delegate the read-only search to a fast, low-reasoning subagent when one is available: request at most the limit, each with exact path, line, comment text, and one to three adjacent code lines. Otherwise search directly.
  1. 根据调用指令确定处理数量上限(默认10条)。
  2. 搜索源码文件;跳过生成的输出文件、第三方依赖包、锁文件和文档。
  3. 按冗余程度从高到低排序候选注释。
  4. 使用
    git blame
    获取每个候选注释的存在时长(参见「注释时长」)。
  5. 展示下方格式的表格,然后询问是否移除所有推荐删除的注释(参见「用户反馈」)。
  6. 若用户选择「是」,则移除所有标记为「删除」的注释;若选择「否」,则针对每条注释询问「删除」或「保留」,需明确引用注释原文而非位置。
  7. 仅移除用户批准删除的注释。
  8. 运行项目的代码检查和类型校验;修复因注释移除导致的问题。
若有可用的快速低推理子Agent,将只读搜索任务委托给它:请求返回不超过上限数量的候选注释,每条需包含精确路径、行号、注释文本及1-3行相邻代码。否则直接执行搜索。

Comment Age

注释时长

For each candidate, run:
bash
git blame -L <line>,<line> --date=relative -- <file>
Use the relative date; mark uncommitted lines
uncommitted
.
对于每个候选注释,执行以下命令:
bash
git blame -L <line>,<line> --date=relative -- <file>
使用相对日期;未提交的行标记为
uncommitted

Required Output

输出格式要求

Use exactly these columns:
markdown
| Comment | Age | Why |
|---------|-----|-----|
| `// increment the counter` | 8 months ago | *Remove.* Restates `count++` verbatim. |
| `/** Returns the user id. */` | 3 weeks ago | *Remove.* Describes the function word by word. |
| `// debounce avoids hammering the API on each keypress` | 1 year ago | *Keep.* Explains intent, not mechanics. |
  • Comment: Include the exact comment text in backticks.
  • Age: Use the relative
    git blame
    age.
  • Why: Start with
    *Remove.*
    or
    *Keep.*
    , then give one short reason.
必须使用以下列:
markdown
| Comment | Age | Why |
|---------|-----|-----|
| `// increment the counter` | 8 months ago | *Remove.* Restates `count++` verbatim. |
| `/** Returns the user id. */` | 3 weeks ago | *Remove.* Describes the function word by word. |
| `// debounce avoids hammering the API on each keypress` | 1 year ago | *Keep.* Explains intent, not mechanics. |
  • 注释:将注释原文用反引号包裹。
  • 时长:使用
    git blame
    返回的相对日期。
  • 原因:以
    *Remove.*
    *Keep.*
    开头,后跟简短理由。

Feedback

用户反馈

After presenting the table, ask:
Remove all recommended?
  • Yes, remove all recommended
  • No, I want to review each comment
展示表格后,询问用户:
是否移除所有推荐删除的注释?
  • 是,移除所有推荐删除的注释
  • 否,我要逐一查看每个注释