code-comments
Skill285 starsChanged 14 days agoMITView on GitHub
How to write and review code comments in the Portable Text Editor monorepo. Use when writing code comments or judging comment quality. Covers the why-only rule, JSDoc-as-consumer-docs, and untouchable directives.
28 other projects use a version of this.
Adopted by
Most recently taken up by
- gauravjuvekar/agent-skillstheir own version, first seen Nov 8, 2026
- 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/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 · 0
None found.
Edited · 0
None found.
Wrote their own version · 28
- bholmesdev/hubble.md★ 1.5ksame name
- overmind-core/overmind★ 752same name
- AllayMC/Allay★ 348same name
- pensarai/apex★ 323same 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
- ton-anywhere/my-favorite-prompts★ 4same name
18 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 repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- backportingSkill
- changesetsSkill
- commitsSkill
- next-branchSkill
- pr-descriptionsSkill
- reviewing-prsSkill
- writing-testsSkill
- product-copy-assistantSkill
- portable-text-editorSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 25 edited versions we read keep these.
0
Distinctive
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
- Very specific: line 21
Delete comments that restate the code.
- Very specific: line 25
Use backticks around code identifiers:
markDefs, not markDefs.
“Common” is measured: kept by at least 6 in 10 of the 25 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
PTE code comments
The bar
A comment is a failure of every better channel. Before writing one, check where the information actually belongs:
- The code. A name, an extracted helper, or a stronger assertion often removes the need. If the mechanism can be named, name it.
- The test. Structure that an assertion defends needs no prose: deleting the "mysterious" line makes the pinned expectation fail, and the failure explains the line better than a comment would.
- The commit body. Diagnosis, justification, comparison with what the code used to do: all diff-relative narrative lives there.
- Docs/skills. A house pattern gets documented once, where it is defined, never re-explained at every use site. The same comment appearing N times is a pattern that wants a name, not N comments.
What remains after those four channels is the legitimate comment: the fact a competent reader cannot recover from the code and would act wrongly without: a browser quirk, a spec constraint, a deliberate-looking-accidental choice, an invariant the code relies on but does not check. "Explains why" is necessary but not sufficient; comprehension speed alone does not earn one. The test is concrete: what wrong action does this comment prevent? No answer, no comment.
The rules
- Delete comments that restate the code.
// increment the counterabovecounter++is noise. So is any comment a rename would make redundant. - Never reference ticket IDs (Linear, Jira, anything) in code comments. The codebase stands on its own; a ticket system is invisible to external contributors, dies on migrations, and the commit that introduced the line already links the context. Name the CONDITION instead of the ticket: "once
mergeis a first-class operation, this becomes a correction", not "TICKET-123 promotesmerge...". Same rule as commits, branches, and PRs. - Comments describe the present, never the diff. A comment that argues for the new code against code that is no longer there ("Deterministic negative assert: ...", deterministic relative to a deleted sleep) is commit-body material wearing a comment's clothes. The tell: a label or contrast that only means something to someone who saw the old version.
- Comments for an if statement go inside the if statement, not above it.
- Use backticks around code identifiers:
`markDefs`, not markDefs. - Rewrites are dense one-liners where possible: present tense, mechanism not narrative, no "we need to" preamble. "Chrome collapses the selection on
blur; restore it before applying" beats three sentences of story. - A comment that mixes a real why with restated what gets rewritten down to the why, then re-tested against the bar: the residue must still prevent a wrong action, or it goes too.
JSDoc is consumer documentation
JSDoc on exported symbols (especially @public) is rendered by typedoc onto portabletext.org. It is not a code comment; it is the docs site. Different bar entirely:
- The why-only rule does not apply. Describe behavior at the surface the consumer sees, not internal mechanism.
- Deleting or trimming it changes the published docs, so removal is an API-documentation decision, never comment cleanup. When it is wrong, improve it.
@exampleblocks are valuable; keep and fix them rather than remove.@deprecatedtags and their migration pointers are API surface: consumers and tooling act on them. Keep them accurate.
Not comments: machine-read directives
Some things look like comments but are instructions to tools, and editing or deleting them changes behavior (suppressed errors resurface, coverage changes, formatting shifts). The rules above do not apply to:
- Directives:
@ts-expect-error,@ts-ignore,oxlint-disable,oxlint-disable-next-line,eslint-disable,prettier-ignore,/// <reference,v8 ignore,c8 ignore,istanbul ignore keep-in-syncpointers: they pin deliberate duplication across packages (see thewriting-testsskill), and deleting one silently breaks the contract that keeps the copies aligned
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.

