naming-and-comments
Skill1 starsChanged 6 months agoMITView on GitHub
Names and comments are the primary channel through which code communicates intent to the next engineer. Use when choosing an identifier ("what should I call this", "rename this", "is this name clear"), deciding whether to add a comment ("should I comment this", "does this need explaining"), or auditing existing prose ("clean up the comments", "too many comments", "comment slop"). Also fires when a name is hard to pick — that difficulty is a design smell, not a vocabulary problem (Ousterhout: Hard to Pick Name).
In this repository9 other files it gives its agents.
- code-smellsSkill
- data-and-state-evolutionSkill
- dry-and-reuseSkill
- effects-and-puritySkill
- production-gradeSkill
- right-sized-designSkill
- robustness-at-boundariesSkill
- supply-chain-hygieneSkill
- trustworthy-testsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 51
Comments explain WHY, not WHAT: Document rationale, units, invariants, gotchas, and non-obvious trade-offs.
- Distinctive: line 77
Ask: "Could a stranger reading only this name — no body, no context — guess what it is and does?" If not, rename.
- Distinctive: line 79
Check for noise words and abbreviations.
- Distinctive: line 80
Check that the same concept is named consistently elsewhere in the codebase.
- Distinctive: line 83
Ask: "Does this add information the code doesn't already carry?" If no, delete it.
- Distinctive: line 85
If the *what* is unclear, fix the name.
- Very specific: line 86
If the comment is a # TODO or # hack, either fix it now or convert it to a tracked ticket and link the ticket number.
- Very specific: line 89
When a name is hard to pick: stop naming and investigate the abstraction.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
naming-and-comments — names carry intent; comments carry why
Purpose: names and comments are where code either communicates or hides its
intent. AI agents produce vague names (data, result, handle, manager,
temp, item, process) and comment slop that restates the line below it.
Both are noise; noise degrades every engineer who reads the code after you.
The workspace rule is explicit: the diff is the comment — a comment that only describes what the code does is banned. Comments must carry why: rationale, units, invariants, non-obvious trade-offs, links to tickets or requirements. If the what is unclear, fix the name; don't add a comment to compensate.
A name that is hard to pick signals unclear design (Ousterhout's red flag: Hard to Pick Name). Don't push through; investigate the abstraction.
Reflex card (the heuristics)
- Intention-revealing names. A reader should infer purpose without reading
the body. Name by what the thing means in the domain, not its type or
mechanics (
expireStaleSessionsOlderThannotprocessData). - Length proportional to scope. A loop-local
iis fine; a module-level export needs a full, unambiguous name. The wider the scope, the higher the naming bar. - Ban noise words.
Manager / Helper / Util / Processor / Handler / Info / Data / Object / temp / objadd syllables and no information. Cut them or replace them with the actual concept. - No unexplained abbreviations.
sesExpis not a name.sessionExpiryMsis. Exception: universally understood acronyms (http,url,id). - Booleans are predicates.
isActive,hasAccess,canRetry— notactive,access,retry(those read as nouns or verbs, not conditions). - Functions are verbs; things are nouns.
expireSession()notsessionExpiry();SessionCachenotManageSession. - One term per concept across the codebase. Pick one of
fetch / get / load / retrievefor the same operation and stick to it. Mixed vocabulary forces readers to wonder if they're different things. - Named constants for magic literals.
SESSION_EXPIRY_MS = 30 * 60 * 1000not a bare1800000. The name is the documentation. - Comments explain WHY, not WHAT. Document rationale, units, invariants, gotchas, and non-obvious trade-offs. Delete comments that restate the code.
- A comment apologizing for code means fix the code.
# this is a hack because...→ fix the hack, or open a ticket and link it. - Keep comments next to what they describe; update them with the code. A stale comment is worse than no comment — it is an active lie.
Red flags
- Single-letter or opaque names outside tiny local scopes.
Manager / Helper / Util / Processor / data / result / temp / obj / itemin any identifier that crosses a function boundary.- A comment that says exactly what the next line says (
# increment iabovei += 1). - Commented-out dead code committed to the repo.
- A boolean named as a noun (
activeinstead ofisActive). - The same concept called three different things in three files.
- A magic number or string literal with no name and no comment explaining it.
- A name you struggled to choose (Ousterhout: Hard to Pick Name — investigate the design before you commit to any name).
- A
Vague Name(Ousterhout): too imprecise to convey useful information (handle,process,do).
The procedure
For each new identifier:
- Ask: "Could a stranger reading only this name — no body, no context — guess what it is and does?" If not, rename.
- Check for noise words and abbreviations; eliminate both.
- Check that the same concept is named consistently elsewhere in the codebase.
For each comment:
- Ask: "Does this add information the code doesn't already carry?" If no, delete it.
- If the what is unclear, fix the name. Don't add a comment to compensate.
- If the comment is a
# TODOor# hack, either fix it now or convert it to a tracked ticket and link the ticket number.
When a name is hard to pick: stop naming and investigate the abstraction. A
module with one clear responsibility names itself; one that does two things
can't be named without an And.
Before / after
# BEFORE — vague name, comment restates the code
def proc(d):
# loop through data
for item in d:
if item["ts"] < time.time() - 1800:
del_item(item)
# AFTER — intention-revealing name, comment carries WHY
# 30-minute threshold per §AUTH-112: tokens issued before this window
# cannot be rotated without a full re-auth, so we purge them proactively
# rather than let them accumulate and slow the next gc sweep.
SESSION_EXPIRY_SECS = 30 * 60
def expire_stale_sessions(sessions: list[Session]) -> None:
cutoff = time.time() - SESSION_EXPIRY_SECS
for session in sessions:
if session.issued_at < cutoff:
session_store.delete(session)Changes: proc → expire_stale_sessions (verb + domain noun); d →
sessions (type-and-domain); item → session; 1800 → SESSION_EXPIRY_SECS
(named constant); comment deleted (restated the loop) and replaced with one that
explains the why — the requirement reference and the gc motivation.
Critique mode
For each identifier: state whether a stranger could infer its purpose from the name alone. For each comment: state whether it adds information the code doesn't carry. Recommend rename or delete as appropriate. Tag findings:
[naming-and-comments · vague-name · SEV]
[naming-and-comments · comment-repeats-code · SEV]
[naming-and-comments · hard-to-pick-name · SEV]
hard-to-pick-name findings should also trigger a design investigation —
recommend the caller open a right-sized-design review on the surrounding
abstraction.
References
- Vague Name, Hard to Pick Name, Comment Repeats Code, Nonobvious Code:
../../references/PRINCIPLES.md§B (Ousterhout red flags table) - Rule 9 ("Names carry intent; comments carry why"):
../../RULES.md - Workspace house rule: "the diff is the comment" —
../../RULES.mdDefinition of Done - Right-sizing abstractions that produce hard-to-name modules:
../right-sized-design/SKILL.md
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.

