Analyze and fix redundant or self-explanatory inline comments — remove noise, promote genuine documentation to TSDoc
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-you-might-not-need-a-comment-1ebcfc0562a7 ,按照其中的说明把「you-might-not-need-a-comment」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Arguments:
User arguments: $ARGUMENTS
A comment must add information the code cannot express itself. Code says what and how; a comment earns its place only by explaining why — a non-obvious constraint, a workaround, a decision, a gotcha. If deleting the comment loses no information a competent reader wouldn't recover from the code in seconds, delete it.
This codebase's convention: TSDoc for documentation; an inline // only for a terse non-obvious why or a script-enforced annotation; no ==== separators. Genuine documentation belongs in a /** ... */ block on the declaration; everything that survives as an inline // comment must be a real why, kept terse.
// increment counter above counter++, // return the result above return result, // loop over items. Delete.fetchUserById, the comment says // fetches a user by id. The identifier already said it. Delete.// ==== Helpers ====, // --- state ---, // #region. Against convention. Delete (the code's structure is the structure).// takes a string and returns a number when the signature already says so. Delete.// added by X, // TODO(2021): ... long-stale, // fix for bug. Delete unless it encodes a live, actionable constraint.// block on a declaration: a real explanation of what an exported function/type/const is for, but written as stacked // lines instead of TSDoc. Convert to a /** ... */ TSDoc block on the declaration.// comment that explains a non-obvious why: a workaround for an upstream bug, an ordering constraint, a perf reason, a spec/edge-case the code can't self-document (// first-match wins — matches the old find() semantics)./** ... */ blocks on declarations — leave them (only tighten if verbose).// boundary-raw-fetch:, // double-cast-allowed:, // boundary-raw-json:, // untyped-response:, // migration-safe:, // rq-lint-allow:, // client-boundary-allow: and any other <kebab-tag>: <reason> annotation a script under scripts/ greps for, in line-comment or block-comment form (e.g. the /** svg-path-precision-exception: ... */ directive on icon paths) — these are load-bearing, never touch them.// biome-ignore, // eslint-disable, // @ts-expect-error and other tooling directives.// TODO / // FIXME that point at real, still-open work.Prefer deletion over rewriting, and no comment over a comment when the code is already clear. When a comment is genuine documentation, prefer promoting it to terse TSDoc over leaving a loose // block. Never add new comments in this pass — this is a reduction pass. When unsure whether a comment encodes a real why, keep it.