code-comments
Skill0 starsChanged 23 days agoMITView on GitHub
Write code comments that explain why, never what, and strip comment noise from existing code: comment constraints, invariants, workarounds, and rejected alternatives; delete narration, section banners, and restated names; match the codebase's comment density. Use whenever writing a code comment, writing code that may need comments, editing code that has them, writing docstrings or API docs, or asked to clean up, reduce, or improve comments. Pairs with naming (the fix for a comment explaining a bad name is a better name) and writing-docs (the same what-versus-why judgment in docs).
28 other projects use a version of this.
Adopted by
Most recently taken up by
- caidanw/skillstheir own version, first seen Nov 8, 2026
- bmsuisse/skillstheir own version, first seen Nov 6, 2026
- AllayMC/Allaytheir own version, first seen Nov 1, 2026
- pumpkit-io/sdlctheir own version, first seen Nov 1, 2026
- gabrielbauman/skillsword for word, first seen Nov 1, 2026
- YKDZ/skillstheir own version, first seen Nov 1, 2026
Used with
Projects with it also use api-design, changelog and 4 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillapi-design
Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.
Also in 3 projects that use this
HashiCorpSkillchangelog
Add a `.changelog/<PR_NUMBER>.txt` entry for a GitHub Pull Request, commit, and push.
Also in 3 projects that use this
GoogleSkillimprove-codebase-architecture
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
Also in 4 projects that use this
GoogleSkillcodebase-design
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
Also in 3 projects that use this
MicrosoftSkillhandoff
Compact the current conversation into a handoff document for another agent to pick up.
Also in 3 projects that use this
- +1 more from google
Other versions28 projects use a version of this.
Word for word · 1
- gabrielbauman/skills★ 1100% same
Edited · 0
None found.
Wrote their own version · 27
- bholmesdev/hubble.md★ 1.5ksame name
- overmind-core/overmind★ 752same name
- AllayMC/Allay★ 348same name
- pensarai/apex★ 323same name
- portabletext/editor★ 285same name
- petekp/claude-code-setup★ 48same name
- keitakn/engineering-skills★ 14same name
- caidanw/skills★ 11same name
- ARTPARK-SAHAI-ORG/calibrate-backend★ 4same name
- karlhorky/agent-skills★ 4same name
17 more not listed
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 repository9 other files it gives its agents.
- agent-browserSkill
- broSkill
- cache-network-transfersSkill
- correctSkill
- dry-listsSkill
- nix-for-toolsSkill
- read-readmesSkill
- sharpenSkill
- unslopSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 24 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 38
If none of the above apply and the code still seems to need a comment to be understood, the fix is code, not prose: a better name, an …
- Distinctive: line 125
Remove noise comments in code you are already touching.
- Distinctive: line 132
Update any comment your edit makes wrong.
- Distinctive: line 134
Never delete a comment stating a constraint you don't understand.
“Common” is measured: kept by at least 6 in 10 of the 24 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
Code comments
Code is the behaviour. A comment that restates it says nothing and rots: the code gets edited, the comment doesn't, and now the file lies. The only comments worth writing carry what the code cannot: the reason, the constraint, the history. Agents fail in both directions at once, narrating every step ("// increment the counter") while leaving the actual trap (the API that returns milliseconds where everything else uses seconds) undocumented. Default to zero comments, then add back only the ones below.
When a comment is warranted
- A non-obvious constraint or invariant: "callers hold the lock", "must stay in sync with the enum in proto/status.proto", "list is sorted, bisect depends on it".
- A workaround, with a link to what it works around: the upstream bug, the broken client version, the platform quirk. Without the link, the next reader can't tell when it's safe to remove.
- Why an obvious-looking alternative was rejected: "regex here backtracks catastrophically on real inputs, hence the hand-rolled parser". This is the comment that stops the next person from "simplifying" the code back into the bug.
- Units, formats, or ranges the type system can't express: "timeout in milliseconds", "amount in cents", "0.0 to 1.0 inclusive".
- Why risky code is safe: for
unsafeblocks, lock-free code, and security-sensitive paths, state the invariant the safety rests on and who maintains it: "SAFETY: ptr was allocated by this Vec and len <= capacity". Rust's standard library requires these; the discipline transfers to any language where one wrong assumption corrupts memory or leaks data.
Refactor before you comment
If none of the above apply and the code still seems to need a comment to be understood, the fix is code, not prose: a better name, an extracted function, a stronger type, an assertion. A comment explaining confusing code patches the symptom and starts rotting immediately; the rename fixes the cause and can't drift.
var d int // days since last refreshvar daysSinceLastRefresh intThe exception is a call site you can't restructure. An argument whose meaning is invisible at the call is best fixed with keyword arguments or an options struct, but when the signature isn't yours to change,
render(label, true /* primary */, false /* disabled */)beats a bare render(label, true, false) and beats a comment on the line
above, because it can't drift away from the argument it labels.
What is noise
- Narrating the next line:
// increment the counterabovecounter += 1. - Section banners:
// ---- helpers ----,// Validation section. - Restating a name:
// UserService handles usersonclass UserService. - Comments addressed to the reviewer instead of the next reader: "fixed the bug here", "per feedback", "new function to handle retries", "changed from the old approach". These describe the diff, not the code; they are stale the moment the PR merges. If the change history matters, it belongs in the commit message.
- Comments explaining why your change is correct. Same problem: that is an argument to the reviewer, and it is noise to everyone after.
Bad, then good
# Loop through the retries and try the request
for attempt in range(5): # 5 retries
resp = fetch(url)
if resp.ok:
break
time.sleep(2 ** attempt) # exponential backoff# Upstream rate-limits bursts; 5 tries with backoff covers their
# longest observed throttle window (issue #482).
for attempt in range(5):
resp = fetch(url)
if resp.ok:
break
time.sleep(2 ** attempt)Three noise comments deleted, one constraint added. The good version has fewer comments and more information.
Docstrings and API docs
A docstring is a contract, not narration: what the function promises (arguments, return value, errors raised, side effects, thread-safety), never how the body works. "Uses a dict internally" is implementation detail that breaks the doc when the implementation changes. Follow the codebase's existing convention for which symbols get docstrings; a private helper whose name says everything doesn't need one just because a linter can count.
Match the codebase
Comment density and idiom are house style like anything else. In a sparsely
commented codebase, a fully narrated function is as out of place as a
reformatted file. Match what surrounds your change: density, tone, doc
comment format, tag conventions (TODO(name):, FIXME:, # NOTE:).
TODOs
A TODO with no owner and no issue link is a wish. Write TODO(alice): ...
or TODO(#482): ... so it can be chased, or file the issue and skip the
comment. Never leave a TODO describing work the user asked you to finish
now.
Editing existing code
- Remove noise comments in code you are already touching; leave the rest of the file alone. Comment cleanup across untouched code is its own change.
- Some comments are read by tools, not people: linter and formatter
directives (
# noqa,eslint-disable-next-line), coverage pragmas, process tags like ADR references. They say nothing to a reader and are still load-bearing; leave them unless you mean to change what they control. - Update any comment your edit makes wrong. A stale comment is worse than none.
- Never delete a comment stating a constraint you don't understand. It may be the only record of why the code survives production. If it looks wrong, say so to the user instead of removing it.
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.

