Files
review/skills/comment-cleanup/SKILL.md
jiantw83 ced541faa5 fix(review): 補上註解腳本路徑與缺漏的失敗分支
- 註解範圍腳本的路徑少一層目錄,照著寫會找不到檔案,補上 hooks 那一層。
- 建置測試跑完卻失敗時沒有分支可走,只寫得出「通過」。現在要指出指令、結束碼,並判斷失敗是不是本次改動造成的。
- 取得差異失敗時原本會安靜跳過,現在原樣帶出錯誤並停手。判不出範圍不等於沒有東西要審。
- 禁止清單原本抄了兩份,改成只指向註解範圍的正本,兩份不會各自演化。
- 第二組不再重掃樣式判得出來的項目。hook 關掉或沒接上時就沒有最後一道網,這件事寫進技能文件,不讓它默默消失。
- 差異只算一次,落成一份快照檔給六組共讀;檔名帶執行代號,同一台機器平行跑不會互相覆蓋。註解清理改成一個檔案一個 sub agent 平行跑。
2026-08-31 11:07:05 +08:00

5.6 KiB

name, description
name description
comment-cleanup Clean review traces and document-tracking noise from comments touched by the current change. Use when the user asks to clean comments, remove review traces, or when a pre-commit check finds process details in changed comments. It rewrites comments only, keeps code behavior unchanged, and uses references/comment-scope.md as the single source of banned and allowed content. Do not use for untouched legacy comments unless the user explicitly asks for that wider scope.

comment-cleanup

Clean comments changed in the current diff so they explain why the code exists, without carrying review traces, issue coordinates, wiki page ids, or other process-only details.

When to run

  1. User asks to clean comments: examples include "clean the comments", "remove review traces", or "do not leave review artifacts".
  2. Before commit: jsc-hooks reports comment scope warnings, or a changed comment clearly carries process-only details.
  3. Not for untouched legacy comments: only widen the scope when the user explicitly asks for legacy cleanup.

Single Source

Use references/comment-scope.md for the banned list, allowed list, and rewrite rules. Do not copy those lists into this skill.

Division of Labor

  • jsc-hooks/hooks/comment-scope.sh blocks pattern-detectable violations after writes.
  • jsc-review:code-review group 2 reports judgment-based cases that patterns cannot decide.
  • This skill cleans the changed comments. Do not report the same finding again when a hook or code review already reported it; either clean it or explain why it is outside this skill's scope.

Steps

  1. Define the scope with tools/changed-comments.sh, run from the repository being cleaned: no argument for uncommitted work, tools/changed-comments.sh {base} when an implementation is complete and the base branch is the comparison point. It prints one row per changed comment line — file, line number, content — so this step never judges by eye which lines are comments; that judgment lives in the script, next to the one jsc-hooks/hooks/comment-scope.sh already uses. Read its exit code: 0 its stdout is the cleanup scope, and step 2 hands each file its own rows; 1 this change added or modified no comment line, so report the literal 「無發現」 and stop, spawn no sub agent; 2 a parameter or environment error, so report the script's stderr verbatim and stop, spawn no sub agent, and never substitute a hand-read diff — a scope that could not be computed is not an empty scope. Widen to untouched legacy comments only when the user explicitly asked for that, and say so in the report. Completion condition: the cleanup scope is listed by file, or the run ended with 「無發現」 or with the script's error.
  2. Rewrite one file per sub agent, and every file MUST run as a sub agent. One file's comments never depend on another file's, so the sub agents run in parallel. Each sub agent is handed one file path and that file's scoped comment lines from step 1, and it compares each of them with references/comment-scope.md, removes process-only details, and keeps the real reason for the code. A comment that is only process detail with no real reason left is deleted whole. Each sub agent returns the file path, the categories it removed, and the line numbers it touched. Completion condition: every file's sub agent has returned, and every scoped comment is either unchanged with a stated reason, rewritten, or deleted.
  3. Each sub agent re-reads its own changed area before it returns. It confirms every sentence is complete, the logic still reads naturally, and no dangling fragment remains after a deletion; a fragment it cannot resolve is reported instead of left behind. Completion condition: every sub agent has confirmed its file, and no returned report names an unresolved fragment.
  4. Change comments and documentation strings only. Do not change executable behavior, identifiers, control flow, data shape, or tests except when a test fixture literally asserts the old comment text. jsc-hooks/hooks/write-guard.sh in review mode is the code-level backstop, but it covers this skill only as far as jsc-hooks can decide a comment line precisely: where that decision is not precise, the guard is limited to jsc-review:code-review and jsc-review:api-doc, which write nothing at all, and this skill runs unguarded. Only claude has a PreToolUse hook in the first place, so on codex, copilot, antigravity, and kiro this step's prose is the only constraint. Completion condition: git diff shows comment-only or documentation-string-only edits.
  5. Run the smallest relevant build or test command once for the whole changed project, after every sub agent in step 2 has returned. Read the exit code. 0 — verification passed. Non-zero — the command ran and failed, so name the command, its exit code, and the failing output, then decide whether this run caused it: a failure that names a file this run touched is treated as caused here, so restore that file's comment syntax and re-run the command once; if it fails the same way again, revert this run's edits in that file and report the revert. A failure that names no file this run touched is reported as pre-existing, and the cleanup edits stay. If no project command is available, run syntax checks for the touched scripts and report the gap. Completion condition: the command exited 0, or the report states the command, its exit code and whether the failure belongs to this run, or the exact missing command is reported.
  6. Report the cleanup by category, not by full diff. Completion condition: the report names which categories were removed, which files were touched, and whether verification passed.