| name | comment-cleanup |
| description | Apply this skill after every code change. Reviews and cleans up comments ONLY in the code that was just modified — never touches pre-existing comments outside the changed scope. Enforces lean, context-aware commenting: structural markers, genuine clarification, and non-obvious reasoning only. Strips conversation artifacts, redundant labels, and anything a fresh reader would find confusing or meaningless.
|
Comment Cleanup — After Every Change
Run this after every code modification, before considering the task done.
Scope is strict: only touch comments in lines/blocks you just wrote or edited.
Leave everything else alone.
The core test — read as a stranger
Before keeping any comment, ask:
"If someone who was NOT in this conversation reads this comment cold,
does it make complete sense on its own?"
If the answer is no — rewrite or delete it.
What to DELETE immediately
Conversation artifacts
Comments that reference what happened during the chat session. These mean nothing
to anyone reading the code later.
Labels that just repeat the code
function normalizeQuote(raw: DeribitRaw): OptionsQuote { ... }
const ws = new WebSocket(url);
return result;
Commented-out code
TODO comments without context
Defensive/apologetic comments
Version / changelog comments
What to KEEP and how to write it
1. Structure markers — for long files or complex blocks
Only when the file is long enough that navigation genuinely helps.
Keep them minimal — one line, no decoration.
private connect(): void { ... }
private disconnect(): void { ... }
private scheduleReconnect(): void { ... }
private handleMessage(raw: unknown): void { ... }
private handleError(err: unknown): void { ... }
Not needed for files under ~80 lines. Don't add structure to code that isn't complex.
2. Non-obvious reasoning — the WHY, never the WHAT
const iv = raw.mark_iv != null ? raw.mark_iv / 100 : null;
const receivedAt = (raw.ts / 1_000) as UnixMs;
const delay = baseMs * 2 ** attempt + Math.random() * 200;
ws.onerror = () => { logger.warn("WS error on", this.url); };
3. Hard-won external knowledge — things you can't see in code
private readonly HEARTBEAT_INTERVAL_MS = 30_000;
const MAX_SYMBOLS_PER_CONNECTION = 200;
if (this.ws.readyState !== WebSocket.OPEN) return;
4. JSDoc — only on exported public functions
Only when the signature alone doesn't tell the full story.
Do NOT restate the types — they're already in the signature.
export function normalizeDeribitQuote(raw: DeribitQuoteData, ts: UnixMs): OptionsQuote
Do NOT write JSDoc on:
- Private functions
- Internal helpers
- Anything not exported
- Functions where the name + types are self-explanatory
The rewrite checklist — apply to every comment in changed code
For each comment in code you just touched, answer these in order:
- Conversation artifact? → Delete. No exceptions.
- Repeats what the code already says? → Delete.
- Commented-out code? → Delete (or add specific retention reason).
- Vague TODO? → Add ticket/owner or delete.
- Explains WHAT instead of WHY? → Rewrite to explain WHY, or delete.
- Would a stranger understand this with zero context from our chat? → If no, rewrite.
- Passes the stranger test? → Keep.
Quick reference — patterns to find and fix
| Pattern | Action |
|---|
// NO SDK, // without library, // native X | Delete or rewrite with actual reason |
// Removed X, // Added X back, // Changed to Y | Delete — git history owns this |
// This function does X where function is named doX | Delete |
// TODO: fix with no ticket | Delete or add // TODO(#N): specific thing |
// old version, // v2, // updated YYYY-MM-DD | Delete |
// hacky, // not ideal, // works for now | Fix the code or explain the real constraint |
| Long inline comment restating logic step by step | Delete — code should be readable |
| Comment referencing "the user", "we decided", "per request" | Delete |