/comment-cleaner:comment-cleanerfrom comment cleaner
Clean up the comments in an existing codebase — remove the ones that only restate the code, shorten verbose or AI-written ones, and preserve the ones carrying real context. Load when the user asks to tidy, humanise, shorten, de-slop or clean comments or docstrings, mentions AI-generated comment noise, wants comments reviewed for a repo or directory, or says "comment-cleaner". Edits comments only, never program code, and tracks progress so a large repository can be worked through across several sessions.
Ships in comment cleaner. 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.
Comments rot in a particular way. Someone writes three sentences where one would do, an agent narrates every line it produced, and the genuinely useful note — the one explaining why a retry exists — ends up buried in filler nobody reads any more.
This cleans that up. It is a comment tool: it changes comments and docstrings, and it does not touch the program.
Never change code. Not a variable name, not an import, not a line of control flow, not formatting outside a comment. If a comment could only be improved by changing the code, leave both alone and move on.
This is not a matter of being careful — it is checked. scripts/verify.py reduces each file to its
code with comments stripped and compares before against after. Python goes through the real parser,
so a docstring edit is allowed but any change to a statement is caught. Run it after every batch:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/verify.py" --repo .
Exit 0 means comments only. Exit 2 means a file's code moved — revert that file. Exit 1 means a file could not be reduced to a skeleton, so it was never checked; read that one yourself rather than assuming it passed.
Three outcomes. When torn between them, choose the more conservative one — a comment left too long costs a few seconds of reading, a comment deleted wrongly costs knowledge nobody can recover.
Anything the code cannot say for itself:
Comments that carry nothing a reader could not get from the line beneath:
// increment the counter above counter++)// loop over the items)// ---- helpers ---- is a judgement call; keep if it aids
navigation in a long file)Useful, but three times longer than it needs to be. Preserve the meaning and the technical terms; cut the scaffolding. One sentence where possible, two if the reason genuinely needs it.
Read a few files first and match what you find. Keep the project's spelling convention, its abbreviations, its domain vocabulary, its level of formality. A repo that says "cancelled" keeps its second L. A repo whose comments are terse stays terse.
Write the way a competent colleague writes in a code review: direct, specific, no throat-clearing.
Avoid opening with "This function", "This method", "This code", "In order to", "Please note that", "As mentioned above", or a bare "Note:". Say the thing instead.
// Retry because the upstream service occasionally returns 503.
not
// This section of code implements a retry mechanism because the upstream service may
// occasionally return a 503 status code, which indicates that the service is temporarily
// unavailable and therefore retrying the request may allow it to succeed.
Everything you write must be supported by the existing comment, the surrounding code, the tests, or the repository. If a comment hints at a reason you cannot confirm, keep the hint rather than sharpening it into a claim. Uncertain means keep.
| Kind | Rule |
|---|---|
TODO / FIXME / HACK / XXX | Never delete. Tighten the wording, keep the marker, keep any ticket reference, owner and date. |
| Licence and copyright headers | Leave exactly as found. |
| Generated-file banners | Leave alone, and skip the file — the ledger already excludes files whose header says a machine wrote them. |
| Doc comments (JSDoc, TSDoc, docstrings, JavaDoc, XML doc, rustdoc, godoc) | Conservative. Cut filler prose, keep every documented parameter, return, error, unit and constraint. Never drop a tag that carries contract. |
| Inline trailing comments | Careful — they usually explain the one subtle part of an expression. Cut only when plainly redundant. |
| Commented-out code | Not prose. Leave it unless the user has explicitly asked for it to be removed this run. Never delete it silently. |
Disabled directives (eslint-disable, noqa, pragma, nolint, ts-ignore) | Functional, not commentary. Never touch. |
scripts/ledger.py keeps the state, in .comment-cleaner/ledger.json in the target repo. It stores
the hash of each file as it stood when you finished with it, which is what makes a long job
resumable: a file not in the ledger has never been done, and a file whose hash no longer matches has
been edited since and is due another look.
The scripts live in the plugin, not in the repository being cleaned, so always call them through
${CLAUDE_PLUGIN_ROOT} and pass the target repository with --repo.
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/ledger.py" plan --repo . --scope src/ --batch 25
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/ledger.py" record --repo . --path src/a.ts --status cleaned --removed 3 --rewrote 2 --kept 4
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/ledger.py" status --repo .
plan also reports what it excluded and why: vendored and generated files, minified bundles,
lockfiles, binaries, anything over 400 KB, any file type with no comment grammar, and markdown and
ignore files, which are prose or instructions to other tools rather than code comments. It reads the
file list from git ls-files, so .gitignore is respected without extra configuration.
Work in batches. Read each file, decide per comment, edit, then verify the batch before recording it. Do not record a file you have not verified.
ledger.py plan for the next batch.verify.py over the batch. Anything reporting code-changed gets reverted.ledger.py record for each file that passed.For a repository large enough that this runs long, delegate the per-batch reading to the
comment-auditor subagent so the main thread keeps its context for judgement and reporting.
references/languages.md — comment syntax per language, and what counts as a doc commentreferences/humanising.md — worked before-and-after examples, and the phrasing to avoidWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: author: Invalid input: expected object, received string, commands: Invalid input, agents: Invalid input, skills: Invalid input
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.