Skip to content
Skills Library
Programming · Review & audit

code-comments

/code-comments

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.

Repository
editor ↗
Licence
MIT
Last repository change
21.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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.

Original author description

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.

How it works

  1. The bar
  2. The rules
  3. JSDoc is consumer documentation
  4. Not comments: machine-read directives
Original SKILL.md headings · 40 lines, 629 words
SKILL.md preview
---
name: code-comments
description: 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.
---

# 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

Versions

RepositoryScoreLicence
This page · portabletext/editor100MIT
zenobi-us/dotfiles100MIT
rp1-run/rp1100Apache-2.0
petekp/claude-code-setup100MIT
caidanw/skills100MIT
caidanw/skills100MIT
izumin5210/dotfiles95MIT
overmind-core/overmind90AGPL-3.0
Amey-Thakur/AI-SKILLS90MIT

Database snapshot: 13.11.2026 · package version b215a2573056 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100documentation
    In-code documentation, folder READMEs, code comments. Use when: "document this", "add JSDoc", "write a README", "explain this code", or writing README.md/JSDoc.
  • 95jsdoc-guide
    JSDoc writing rules for AI-powered documentation generation. Use when writing JSDoc, documenting functions, or adding code comments.
  • 100writing-comments
    How to write JSDoc (/** */) and inline (//) comments in the Astro codebase, for contributors reading the source — not end users. Use whenever writing or editing comments in .ts/.js source, including comments added incidentally while fixing bugs or building features. Does not…
  • 100changesets
    How to write changesets in the Portable Text Editor monorepo. Use whenever adding a .changeset/*.md file or deciding whether a change needs one. Covers bump selection (patch/minor/none), the subject-mirrors-commit rule, consumer-facing prose style, and API changesets, with real…
  • 100writing-comments
    How to write JSDoc (/** */) and inline (//) comments in the Astro codebase, for contributors reading the source — not end users. Use whenever writing or editing comments in .ts/.js source, including comments added incidentally while fixing bugs or building features. Does not…
  • 100jsdoc-comment-generator
    Generate jsdoc comment generator operations. Auto-activating skill for Technical Documentation. Triggers on: jsdoc comment generator, jsdoc comment generator Part of the Technical Documentation skill category. Use when working with jsdoc comment generator functionality. Trigger…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.