comment-cleanup
Skill70 starsChanged 28 days agoApache-2.0View on GitHub
Prune and tighten code comments and docstrings without touching code. Run it over the unpushed commits before every `git push`, including the push that opens a PR. Also use when the user asks to clean up, trim, prune, audit or review comments; says comments are too verbose, noisy, or read like an AI wrote them; or wants a comment pass over a file, diff or PR. Also runs when invoked by name ("comment-cleanup", "/comment-cleanup").
- Commits and pushes
3 other projects use a version of this.
Adopted by
Most recently taken up by
- moisesrj97/skillstheir own version, first seen Nov 8, 2026
- TrimVis/skillstheir own version, first seen Aug 14, 2026
- Jinbae10/skillstheir own version, first seen Jul 7, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- TrimVis/skills★ 2same name
- moisesrj97/skills★ 1same name
- Jinbae10/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- create-bugSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 12 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
If anything changed, commit it on top as its own commit (chore: tidy comments), following the repo's commit conventions.
- Distinctive: line 29
Never rename, refactor, reorder or "fix" code, even when a comment exists only because the code is hard to read.
- Distinctive: line 31
Do not add comments where there were none.
- Distinctive: line 33
Before a push: only comments in the unpushed hunks (see above).
- Distinctive: line 36
Check before finishing: git diff (or the equivalent) must show nothing but comment and blank-line changes.
- Distinctive: line 44
When you are unsure:
- Distinctive: line 71
Ask: can the target change while the comment still points at it?
- Distinctive: line 83
If the code needed no comment in the first place (e.g.
- Distinctive: line 98
No doc covers it → keep it and flag it as a candidate to move into a doc.
- Distinctive: line 125
Keep by default. An issue ID is not required.
- Distinctive: line 135
Only restates the name and parameter types → delete or cut down.
- Distinctive: line 156
After editing, reply with:
- Distinctive: line 166
Don't list individual deleted narration comments.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Comment cleanup
Go through the comments in the target, delete the ones that add nothing, tighten the ones that stay, and report anything you saw but were not allowed to fix.
Before a push
This is the default run. The target is what the push would publish:
- Diff the branch against what the remote already has:
- branch exists on the remote →
git diff origin/<branch>...HEAD - never pushed →
git diff origin/main...HEAD
- branch exists on the remote →
- Clean up only the comments inside those hunks.
- If anything changed, commit it on top as its own commit (
chore: tidy comments), following the repo's commit conventions. Do not amend, rebase or squash it into earlier commits. - Report (see Report), then go ahead with the push. Stop and ask only if a flag needs the user's decision first, e.g. a TODO that looks like unfinished work in this push.
Ground rules
- Change only comments and docstrings. All executable code must stay byte-identical. The one exception: delete a blank line that only existed to separate a comment you removed.
- Never rename, refactor, reorder or "fix" code, even when a comment exists only because the code is hard to read. Keep that comment and flag the code as a refactor candidate.
- Do not add comments where there were none. Do not impose capitalisation or punctuation style.
- Scope:
- Before a push: only comments in the unpushed hunks (see above).
- Files: every comment in them.
- Staged/unstaged diff or PR: only comments inside changed hunks.
- Check before finishing:
git diff(or the equivalent) must show nothing but comment and blank-line changes. If anything else shows up, revert it.
What earns a comment
A comment stays if it tells the reader something the code cannot: why it is written this way, a constraint, a hazard, a workaround, or why the obvious alternative fails.
When you are unsure:
- about a comment that gives a reason → keep it.
- about a comment that describes the code → delete it.
A lost warning costs far more than a mediocre surviving comment.
Decide each comment
Walk every in-scope comment through these checks in order and stop at the first match.
- Narrates the code (repeats the next line, lists steps, echoes names or types, labels a closing brace) → delete.
- Talks to the reviewer, not the reader ("now uses the pool", "removed the retry", "per review", "fixed off-by-one") → delete. Test: does it make sense to someone opening this file cold in three years? If not, it is change history and belongs in the commit.
- False (the code no longer does what it says) → rewrite it to be true if the point still matters; otherwise delete.
- Leans on an unstable reference (see References) → state the actual fact inline, or delete.
- Valid reason, poorly packaged (wordy, a wall of text, misplaced) → tighten, split or move (see Tightening).
- Anything else → leave it exactly as it is.
Rewording a comment that is already correct and minimal only creates diff noise; don't. "Correct but wordy" is not minimal, so it goes to step 5.
References
Ask: can the target change while the comment still points at it?
| Stable, fine to cite | Unstable, don't cite |
| Ticket/issue IDs and links | "the spec", "the requirements" with no address |
| Permalinks, wiki pages at permanent URLs | Design docs (they get superseded) |
| Docs at a fixed path in this repo | Section/heading numbers in any editable document |
Published, versioned standards, section numbers included (RFC 9110 §8.3, ISO 8601, EIP-1559, CIP-30) |
- A citation backs up the content; it is never the content. Every surviving comment must
still be useful with its link deleted.
// see PAY-88→// refunds over the original charge are rejected by the processor (PAY-88)
- If the code needed no comment in the first place (e.g. "conforms to the spec"), delete it rather than rewriting it.
- Apply this inside docstrings too.
Tightening
Keeping a comment and keeping its wording are separate decisions. For every survivor:
- Cut it down to the one fact the reader needs at that line, in the fewest words that carry it. Drop what the code already shows, knock-on consequences, restated names, and context the reader already has. Sometimes the right size is zero.
- Break a long header block that covers several points into short comments, each placed beside the lines it governs.
- System-level narrative (architecture rationale, benchmark numbers, lifecycle overviews):
- A stable doc already covers it → delete it inline. No "see the doc" pointer.
- No doc covers it → keep it and flag it as a candidate to move into a doc. Do not write the doc.
- Inline, keep only the local constraint ("must stay under the health-check interval", "keep in sync with X"). A comment that is only a pointer to a doc gets deleted.
- Length is fine when every part carries weight, e.g. a workaround, the bug behind it, and when it can go. Never shorten by dropping information.
Example: a six-line block above a startup hook explaining the service's boot sequence, the history of a past outage, and that this hook must run before the connection pool opens becomes:
# must run before the connection pool opensProtected: looks deletable, keep it
- Sync links: "mirrors X", "same rule as Y", "keep in sync with Z". This is what stops copies drifting apart.
- Meaning of literals: units, ordering, encoding.
RETRY_DELAY = 250 # ms,origin = (51.5, -0.12) # (lat, lon),HEADER = 0x0A0B # big-endian. - Output contracts: formats an outside consumer depends on ("column order matches the billing import").
- Section dividers (
// ===== Serialisation =====): navigation aids. Keep unless the user says otherwise; any rationale inside them is protected like any other.
TODO / FIXME
- Keep by default. An issue ID is not required.
- The work is visibly already done → the TODO is false → delete.
- The TODO describes work that plausibly belongs in the current change (e.g.
# TODO: handle timeoutsabove a bare HTTP call) → keep and flag it. Deleting it would hide unfinished work.
Docstrings
Everything above applies, plus:
- Only restates the name and parameter types → delete or cut down.
- States a contract (units, valid ranges, side effects, failure behaviour, invariants, preconditions, what has already been done to the inputs) → keep. Collapse to one line only if no contract is lost.
- A one-line summary on a public function, endpoint or API is always fine: callers read it without reading the body.
Quick reference
| Before | After |
total += price # add price to total | comment deleted |
# now batches writes | deleted |
# per the requirements doc, section 3 above a non-obvious limit | # vendor API rejects batches over 500 rows |
# Per RFC 6749 §4.1.2, state must round-trip unchanged | unchanged |
# same validation as parse_invoice() in billing/io.py | unchanged |
# TODO: memoise above a function already wrapped in @cache | deleted |
x = (n & -n) # lowest set bit | unchanged; line flagged as refactor candidate |
Report
After editing, reply with:
- Per file: counts of comments removed / rewritten / kept.
- Flags (out of scope for this skill):
- refactor candidates
- TODOs that may hide unfinished work
- comments kept because you could not verify they are still true
- narrative worth moving into a doc
- Judgement calls: one line per borderline decision, so the user can override it.
Don't list individual deleted narration comments.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

