/review:writing-commentsfrom Review toolkit
What belongs in a code comment and what to cut. Use when writing comments or docblocks, trimming a diff before opening a PR, or reviewing comments in someone else's change.
Ships in Review toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Document the why. A comment earns its place only when no name, type, or signature can carry it.
This is not "self-documenting code needs no comments". A style guide that says to extract a commented block into a named method is talking about comments that explain what code does. A method name can absorb a what. It cannot absorb a why that lives outside the file: an upstream schema, a window between two deploys, a library default, a domain judgement.
So: if the comment would still be true after the code was rewritten a different way, it is a why. Keep it, and move it to the smallest scope it explains. If rewriting the code would make the comment false, it is a what. Extract, name it, delete the comment.
Comment syntax (// versus /* */, docblock markers) is the consuming project's concern. The laravel and inertia-react plugins in this marketplace ship rules for it. This skill is about content.
# comments, under the rules in Python{/* */}"""Comments and any report written about them follow references/style.md.
help(), Sphinx, and mkdocs read it. A WRONG docstring reaches users, so it outranks a wrong comment.Args:, Returns:, Raises:, Yields:, and their Sphinx and NumPy spellings) are judged the way @param descriptions are: the description is judged, and the section stays when the project's docstring convention requires it. Before ruling, read select and extend-select under [tool.ruff.lint], minus ignore and per-file-ignores, and the same keys under a legacy top-level [tool.ruff], in pyproject.toml, ruff.toml, or .ruff.toml (where the tables are [lint] and the top level), along with convention under [tool.ruff.lint.pydocstyle]. When the D rules are selected, a one-line docstring on a public symbol is KEEP even when it restates the name, because deleting it fails lint.# noqa, # type: ignore[...], # pragma: no cover, # fmt: off and # fmt: on, # pyright:, # mypy:, # ruff:, # isort:, # nosec, # complexipy: ignore, # pylint:, # ty:, # pyrefly:, # flake8:, # pyre-ignore, # pyre-fixme, # pytype:, # yapf:, # nosemgrep. The helper's DIRECTIVES tuple in comment-audit/scripts/python-comment-lines.py is the same list; change both together. When a directive carries a reason, as in # noqa: BLE001 - the handler must not drop the request, only the reason is judged, and it is KEEP whenever the project requires one, which CLAUDE.md says. Bandit reads the words after nosec as test ids, so a reason written after # nosec is WRONG, with the fix of moving it before the marker.parametrize ids= value are the comment, as Pest and Vitest names are. The reason= string of a pytest.mark.xfail or pytest.mark.skip is a comment and is judged.# type: int) is an annotation in every Python version and is never removed; the helper treats it as a directive for the same reason.deletion-patterns.md - Nine shapes that get cut:
what-survives.md - What no name can carry:
Prefer these three moves over deletion. Each keeps the reason and drops the prose.
Migrate it to where it is verified. A rationale about behaviour belongs on the test that guards that behaviour, not on the code. Relocate before you delete:
/* Cut from ConsentController::show(), kept on the test that fails if it regresses: */
/*
* toJourneyContext() resolves current() itself, so show() reading the id off
* the returned context is the whole journey resolution for the page. Asserted
* against the resolver rather than the upstream lookup because
* MemoizingAccountLookup is scoped: a duplicate current() would hit the
* memo and be invisible at the lookup, while still re-scanning the collection.
*/
Demote it to the right altitude. A class docblock explaining one property belongs on that property:
/* Carries only the cleaned value: exposing the raw nameReport alongside it would invite the wrong one being rendered. */
#[WithCast(DisplayProductNameCast::class)]
public readonly string $productName,
Lead with the imperative. When a comment exists to stop a future edit, the instruction goes first and the reasoning second. Write rehype-raw must never be added here. before the explanation, not after it. A rejected alternative survives when someone could still reach for it: Not final: ... Mockery cannot mock a final class. The test is "could a future edit do this?", not "is it a comparison?"
Name a role, not a class. Comments rot at their proper nouns. the envelope reader fails the read closed survives a refactor that UpstreamHistoryService resolves it with tryFrom() does not, and a comment describing a property (the throwing internal read) can even survive the code moving away and back. Name the class only where a reader needs to go there next, and prefer the behaviour to the location everywhere else.
Drop whole paragraphs before reaching for individual words, then rewrite what survives rather than trimming it. Let a surviving one-liner run past the normal wrap width instead of reflowing it into a block.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
6 skills in this plugin
/comment-auditAudit every comment, docblock, JSDoc, Python docstring, GraphQL description, and markdown line a branch adds and give each a verdict (DELETE, TRIM, MOVE, KEEP, UNSURE, WRONG). Use before opening a PR, when reviewing a PR's comments, or when asked to trim, audit, or clean up comments. Report only by default; `--apply` edits and commits./correctness-reviewHunt correctness defects in a diff through named angles (hunk scan, removed behaviour, callers and callees, language pitfalls, wrapper routing) and drop a candidate only when the code refutes it. Use for a correctness or bug review of a branch or PR, and as the first correctness pass of pr-review./pr-commentsUse when a code review report (the pr-review consolidated report, a single stage report, or pasted findings) has to become comments a pull request author reads, anchored to a file and line, graded for severity, and referenceable by a code. Also use when asked to format, post, clean up, or grade review findings for a PR./pr-reviewOrchestrate a three-stage review (correctness, type safety, comment audit) of one PR or a stack of PRs, delegating each stage to a subagent with a structural brief and consolidating one report. Use when asked for a comprehensive, full, or three-stage PR review, or to review a PR stack./type-safety-reviewReview a diff or a path for type-safety findings (mixed and any, unstructured arrays where a DTO belongs, array-shape pseudo-types without a reason, duplicate types, unchecked casts). Use during PR review, before opening a PR, or when asked about type coverage or type hierarchy. Calibrated on PHP and PHPStan first, with TypeScript and Python sections.npx claudepluginhub noppu-labs/ai-toolkit --plugin review