Code comments

From danielraffel/pulp · View interactive version

Code comments is an AI agent skill from the GitHub repository danielraffel/pulp. How to write source comments, doc comments, and test names/tags that have lasting value, and what never to write. Consult before adding or editing comments in core/**, examples/**, tools/**, test/**, docs/**, or any shipped source. Handles "write a comment", "is this comment ok", "comment hygiene",

How to use this skill

Skill file

Writing Durable Comments

For prose voice in general (plain words, no em dashes, no padding), follow the

crisp-writing skill when it is installed (~/.agents/skills/crisp-writing;

its scripts/check.py --diff origin/main checks a branch). This skill keeps the

Pulp-specific rules below: what counts as a breadcrumb here, and how Pulp's lint

treats comments and test tags.

A comment earns its place by explaining something the code cannot say for

itself and that will still be true next year: current behavior, an invariant, a

non-obvious "why", an upstream/vendor/host quirk, a security or compat

constraint, a regression- or RT-safety guard. It must not encode *how the code

got here*. That provenance belongs in the commit message, planning/,

docs/reports/, the changelog, or a commit trailer. This repo will be

open-sourced; every comment is read by strangers with no access to our issue

tracker or session history.

This skill exists so new code stops adding the exact provenance the repo-wide

cleanup is removing. The cleanup backlog + classification rules are parked at

planning/2026-07-02-comment-hygiene-PAUSED.md.

Never write these (the "Remove" category)

4f-style sub-phase labels, Tier A Slice 7, Feature 3, plan item 7.2,

item 6.12 follow-up. [phaseN] / [phase3-large] Catch2 tags are forbidden.

Capital-letter+digit plan tags (C2, D6, M1) are the same kind of

breadcrumb. The lint can't safely match them (they collide with MIDI note

names and register labels), so it's on you to keep them out of comments.

[codex-*], "per the reviewer", "sub-PR", "slice N of".

selector tags; no "added for coverage".

trail lives in the Reference-Lineage: independent … commit trailer, never

in a source comment. Describe the DAW/host behavior, not how you derived it.

issue explains a still-live invariant, state the invariant; a durable

[issue-NNN] anchor on a regression test is fine (note: # is reserved in

Catch2 tags, so use [issue-NNN]).

TODO-for-a-someday-feature. (Real example removed: a `Future v2 license-key

payloads (post-RSA migration)` bullet that was already inaccurate: current

crypto is AES-256-GCM.)

it) or it's a tracked task (put it in planning/).

than none (real example removed: an orphaned CMAKE_BUILD_TYPE paragraph in a

test that no longer checks a build-type field).

Always safe to write (the "Keep" category)

thread", "denormals flushed here").

Rewrite, don't delete, when there's a real invariant

Provenance that encodes a stable fact gets restated as current behavior,

stripped of the phase/PR wrapper. Real before → after cases from the cleanup:

| Before (process provenance) | After (durable behavior) |

|---|---|

| Phase 4d adds feedback | feedback needs a previous-block slot |

| pulp_build_info.hpp (Tier A Slice 7) | Build info |

| test header macOS plan item 7.2 / 7.1b | header describing the current coverage |

| MPE header naming a phase | "describes UMP status handling and shared factories" |

| raw-MIDI sysex case naming a PR | "describes aborted-sysex recovery" |

Test names and tags

anchor, and behavioral tags for what the test covers: [rt-safety],

[parity], [thread]. Never [phaseN], [codecov], [coverage],

[requested], [codex-*], "which session shipped it".

added.

Self-check before you commit

Scan your own diff for the breadcrumbs above. That is cheaper than a cleanup PR later:

# stale provenance in ADDED lines of the staged/working diff
git diff --cached -U0 | rg '^\+' | \
  rg -n -iE '\b(phase\s?[0-9]|slice [0-9]|tier [a-z] slice|plan item|sub-?pr|codex (p[012]|review)|\[(phase[0-9a-z-]*|codecov|coverage|requested|codex[a-z0-9-]*)\]|future v[0-9]|WIP|clean-?room)\b' \
  && echo "reconsider the lines above (see the code-comments skill)" || echo "clean"

# repo-wide evergreen-scope lint (docs/reference/** + skills)
python3 tools/scripts/docs_noise_lint.py --mode=report

Enforcement: docs_noise_lint.py scans docs and skills, and the comments and

test tags of source files, on changed lines only (CI and pre-push). The rg

self-check above catches the same patterns before you push.

The rule in one line

Write the comment as a present-tense statement of what the code does, why it's

non-obvious, or what external constraint it honors. The narrative of how it was

built goes in the commit and planning/.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.