agentleFS
portabletextportabletext/editor/.agents/skills/code-comments/SKILL.md

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

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.
  • MicrosoftSkill

    api-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

  • HashiCorpSkill

    changelog

    Add a `.changelog/<PR_NUMBER>.txt` entry for a GitHub Pull Request, commit, and push.

    Also in 3 projects that use this

  • GoogleSkill

    improve-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

  • GoogleSkill

    codebase-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

  • MicrosoftSkill

    handoff

    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

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
  1. Very specific:

    Delete comments that restate the code.

    line 21
  2. Very specific:

    Use backticks around code identifiers: markDefs , not markDefs.

    line 25

“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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PTE code comments

The bar

A comment is a failure of every better channel. Before writing one, check where the information actually belongs:

  1. The code. A name, an extracted helper, or a stronger assertion often removes the need. If the mechanism can be named, name it.
  2. 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.
  3. The commit body. Diagnosis, justification, comparison with what the code used to do: all diff-relative narrative lives there.
  4. 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 counter above counter++ 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 merge is a first-class operation, this becomes a correction", not "TICKET-123 promotes merge...". 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.
  • @example blocks are valuable; keep and fix them rather than remove.
  • @deprecated tags 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-sync pointers: they pin deliberate duplication across packages (see the writing-tests skill), and deleting one silently breaks the contract that keeps the copies aligned

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.