art-of-comment
Skill1 starsChanged 3 months agoMITView on GitHub
Guide for editing existing and writing inline comments and JSDoc. Use when generating comments for documenting new components or functions, non-obvious code behaviour, or complex logic.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- delegation-assessmentSkill
- execute-planSkill
- fix-repository-diagnosticsSkill
- meaningSkill
- program-designSkill
- review-code-complexitySkill
- review-implementationSkill
- subagent-dispatchSkill
- writing-planSkill
- writing-unit-testSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
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 12
Comment only when needed: Add comments or JSDoc only when the code alone does not make the intent clear.
- Distinctive: line 14
Do not restate the code: If a comment only paraphrases names, conditions, or control flow, remove it.
- Distinctive: line 18
Document trade-offs and non-obvious behavior: If the code accepts a compromise, workaround, minimum threshold, ordering rule, or other …
- Distinctive: line 19
Treat hard-to-write comments as a design signal: If a comment is difficult to make both simple and clear, the code or API may need to be …
- Distinctive: line 20
Ground comments in evidence: Do not invent rationale. Base comments on code behavior, library docs, project conventions, or explicit user …
- Distinctive: line 21
Keep comments consistent with surrounding docs: Do not contradict nearby comments, and do not duplicate information already explained …
- Distinctive: line 26
Read the example file that matches the kind of comment you are writing or reviewing.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Overview
Every comment should earn its place. A good comment adds context the code alone cannot convey: why a decision was made, what trade-off was accepted, what side effect or constraint matters, or how a non-obvious piece fits the bigger picture. A comment that merely restates the code is noise and adds maintenance burden. When in doubt, prefer no comment over a redundant one.
Guidelines
- Comment only when needed. Add comments or JSDoc only when the code alone does not make the intent clear. If the code is self-explanatory, prefer no comment.
- Explain intent, rationale, or consequences. Good comments add information the code cannot: why a decision was made, what trade-off was accepted, what side effect, exception, or constraint a caller should know about.
- Do not restate the code. If a comment only paraphrases names, conditions, or control flow, remove it. Use words that add meaning, not synonyms for the code.
- Use JSDoc for reusable interfaces. Functions, types, and constants used elsewhere should use
/** ... */when hover documentation would help a caller understand purpose, important parameters, return semantics, side effects, or usage constraints. - Keep implementation detail out of interface docs. Declaration-level comments should describe what the symbol promises or why it exists, not internal steps that only matter to the implementation.
- Keep inline comments short. Inline comments should usually fit in 1-2 lines and explain why or why not, not narrate what the next line does.
- Document trade-offs and non-obvious behavior. If the code accepts a compromise, workaround, minimum threshold, ordering rule, or other surprising behavior, explain the rationale briefly.
- Treat hard-to-write comments as a design signal. If a comment is difficult to make both simple and clear, the code or API may need to be renamed, split, or refactored instead of further explained.
- Ground comments in evidence. Do not invent rationale. Base comments on code behavior, library docs, project conventions, or explicit user requirements, and ask for clarification when intent is uncertain.
- Keep comments consistent with surrounding docs. Do not contradict nearby comments, and do not duplicate information already explained elsewhere unless repetition helps the caller at that exact point.
- Update or remove stale comments. An outdated comment is usually worse than no comment.
Examples
Read the example file that matches the kind of comment you are writing or reviewing.
example-inline-comment-triage.md— Inline comment keep/remove decisions, duplicate comments, and trade-off comments. Read when deciding whether an inline comment earns its place.example-reusable-interface-docs.md— Reusable interface JSDoc that documents the caller-facing contract without leaking internals. Read when writing declaration-level docs for shared symbols.example-evidence-backed-comments.md— Evidence-backed workaround and compatibility comments. Read when documenting a browser bug, platform limitation, or reproduction note.example-design-signal.md— Cases where better names remove the need for comments. Read when a comment seems to compensate for unclear naming or structure.
The stale-comment rule does not need a dedicated example. Apply it whenever you modify code with existing 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.

