Home / Market / lean comments

lean comments

Audits, writes, and refines maintained first-party source-code comments and declaration-level documentation across languages. Use when adding, editing, reviewing, cleaning up, or auditing comments, doc comments, docstrings, TODO, FIXME, NOTE, suppressions, or other source commentary, including while modifying code and deciding whether a comment is warranted at all. Defaults to no comment unless it preserves meaningful, non-obvious information that cannot reasonably be recovered from the code or

skill★ 417940 dlgithubMITInstall in CosmosUpstream Source

Documentation & Preview

--- name: lean-comments description: 'Audits, writes, and refines maintained first-party source-code comments and declaration-level documentation across languages. Use when adding, editing, reviewing, cleaning up, or auditing comments, doc comments, docstrings, TODO, FIXME, NOTE, suppressions, or other source commentary, including while modifying code and deciding whether a comment is warranted at all. Defaults to no comment unless it preserves meaningful, non-obvious information that cannot reasonably be recovered from the code or nearby repository context.'

---

Lean Comments

Goal

Keep the smallest amount of high-value commentary necessary to make a codebase easier and safer to understand and maintain.

The default is no comment.

A comment must preserve meaningful information that a competent maintainer cannot reasonably recover from the code, names, types, signatures, structure, tests, configuration, or nearby context.

Comments are not labels, narration, decoration, declaration summaries, change logs, or substitutes for clear code.

Reader model

Write for a competent maintainer reading the repository at HEAD months later, without access to the current conversation, prompt, diff, pull request, issue discussion, review discussion, or implementation process.

Document the durable state, contract, constraint, or rationale of the code as it exists. Do not assume the reader knows what changed, what came before, or what was discussed unless that context is deliberately preserved in a reliable project source.

Authority and evidence

Use this skill as the comment-policy authority when it is active.

Use language, framework, library, or infrastructure skills to determine whether a non-obvious constraint is real, not to override this skill's necessity test.

Honor explicit current repository requirements, public API documentation requirements, tooling contracts, and generated-source rules. Do not infer a documentation requirement merely from existing comment density or precedent.

Base retained or newly written rationale on evidence from the repository, tests, configuration, official API behavior, project documentation, issue tracker, ADRs, specifications, or another reliable source.

Never invent a security reason, performance reason, business rule, compatibility requirement, API constraint, historical reason, architectural rationale, or external limitation to justify commentary.

If no supported non-obvious reason exists, remove or omit it.

Core decision rule

Before retaining or adding ordinary commentary, mentally remove it and ask:

> Would a competent maintainer lose meaningful, non-obvious information if this comment did not exist?

If no, remove or omit it.

If uncertain, prefer no comment unless repository evidence demonstrates that the information matters.

If yes, retain only the minimum information necessary.

Never preserve a comment merely because it is correct, harmless, already present, grammatically polished, written as a warning, related to security or validation, related to internal or public state, or attached to an exported declaration.

The information itself must justify the comment.

Decision order

Evaluate existing and proposed commentary in this order:

  1. Delete or omit if the information is already clear without it
  2. Express through code if a tiny behavior-preserving readability improvement removes the need for it
  3. Shorten if it is necessary but contains unnecessary information or words
  4. Rewrite if it is necessary but unclear, inaccurate, stale, awkward, or inconsistent
  5. Use declaration documentation if the information belongs to the declaration's contract, semantics, or intended usage
  6. Keep unchanged only if it is already necessary, minimal, accurate, durable, and correctly styled

Always decide necessity before wording.

Do not polish an unnecessary comment or convert one into documentation.

What deserves an implementation comment

Use an implementation comment when it preserves non-obvious information such as:

Prefer comments that explain why something matters.

Comments that merely explain what the code does should normally be removed.

Remove low-value commentary

Remove comments that merely:

Words such as Never, Always, Important, Security, Internal, Public, or Required do not make a comment valuable.

Judge the information, not how serious the wording sounds.

Prefer self-explanatory code

When a comment compensates for unnecessarily confusing code, consider a tiny local behavior-preserving improvement such as improving a local name, extracting a clearly named boolean, simplifying local control flow, or removing redundant local structure.

Keep such changes minimal and directly related to clarity.

Do not turn comment cleanup into a general refactor or change behavior, architecture, public APIs, dependencies, or unrelated code merely to eliminate comments.

Comment and documentation forms

Apply the same necessity test across languages and syntaxes.

Relevant forms may include:

Do not treat comment-like text inside string literals, regular expressions, URLs, snapshots, fixtures, templates, or test data as source comments merely because it contains comment syntax.

Implementation comments

Use the language's normal implementation-comment form for brief rationale, constraints, invariants, workarounds, or other non-obvious local context.

Prefer one concise line when one line is sufficient.

Declaration documentation

Use the language's declaration-documentation form only when the information belongs to the declaration itself and forms part of its contract, semantics, or intended usage.

For TypeScript, use TSDoc-compatible documentation when warranted. For JavaScript, follow intentional repository JSDoc conventions. For other languages, follow the language and repository's real documentation conventions without creating coverage for its own sake.

Module and file documentation

Add module, package, or file-level documentation only for a durable architectural concept, boundary, invariant, terminology, lifecycle rule, or design rationale that is not apparent from the contents.

Do not add file headers that merely summarize exports or describe an obvious file purpose.

Runtime-visible documentation

Some documentation forms, especially Python docstrings, can be observable at runtime through introspection or tooling.

Before removing or materially changing runtime-visible documentation, verify that doing so does not change a supported runtime contract, generated documentation surface, or external API expectation.

Declaration documentation rules

This is not a documentation coverage exercise.

Do not document declarations merely because they are exported or public, and do not assume every language-level export in application code is an intentionally supported external API.

Use declaration documentation when consumers or maintainers need non-obvious information about:

Apply a stronger documentation bias to published libraries, SDKs, packages, plugins, extension APIs, and intentionally external interfaces.

Apply a stronger no-documentation bias to internal helpers, simple CRUD methods, straightforward adapters, composables, plain data shapes, DTOs, and internal utilities.

Do not repeat the type system

Do not add documentation that merely restates names, types, signatures, obvious values, or structure already expressed by the language.

Do not mechanically add tags such as @param, @returns, @throws, @example, @remarks, or @see. Use a tag only when it contributes information beyond the declaration and type system.

Plain interfaces, records, DTOs, structs, types, and obvious data shapes normally require no documentation unless they contain non-obvious semantics, invariants, formats, units, relationships, external constraints, or compatibility requirements.

Style

Single-line prose implementation comments

For a necessary single-line prose implementation comment, regardless of comment delimiter:

Example:

// Preserve source order for positional matching

Not:

// Preserve source order for positional matching.

These prose rules do not apply to machine-consumed syntax, technically significant punctuation, or genuine multi-line declaration documentation.

Declaration documentation

Use normal sentence punctuation for genuine multi-sentence declaration documentation.

Keep it concise and focused on meaningful contract or semantic information. Do not add prose, tags, examples, or sections merely to make documentation appear complete.

High-value examples

<examples>

<example> Delete:

// A watchlist row
export interface FlickWatchlistItem {
  media: FlickMedia;
  added_at: string;
}

Correct:

export interface FlickWatchlistItem {
  media: FlickMedia;
  added_at: string;
}

The declaration already communicates the concept. Do not shorten the comment or convert it into declaration documentation. </example>

<example> Usually delete:

// Never copy a raw internal message into the public response

Do not preserve this merely because it contains `