code-comments-that-last

Guides writing and reviewing code comments and docstrings that survive refactors.

1|Updated Jul 3, 2026
One-click install
npx skills add https://github.com/Nandansai08/skillz --skill code-comments-that-last-nandansai08
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-comments-that-last
Source: https://github.com/Nandansai08/skillz/tree/main/skills/software-engineering/code-comments-that-last
Command: npx skills add https://github.com/Nandansai08/skillz --skill code-comments-that-last-nandansai08

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code comments rot quickly: they contradict the code after refactors, narrate what the code already says, and mislead engineers debugging at 3am. This Skill provides a decision framework for what deserves a comment, how to phrase it so it survives refactors, and how to review comments in pull requests. ## Core Features & Use Cases - Comment triage workflow: A seven-step process covering when to comment (whys, constraints, external anchors), how to phrase comments against behavior rather than positions, and when to delete instead of update. - Docstring guidance: Documents contracts (edge cases, exceptions, side effects) instead of restating signatures, plus TODO hygiene requiring a ticket or owner. - Review checklist and red flags: A three-question review pass, a rationalizations table countering common excuses, and a verification checklist for PRs. - Use Case: While reviewing a PR full of narration comments like "// increment i", apply the review pass to delete redundant comments, rewrite the one durable constraint comment with an external anchor, and flag bare TODOs missing ticket references. ## Quick Start Review the comments and docstrings in my pull request diff and tell me which ones to keep, rewrite, or delete.

Frequently Asked Questions about code-comments-that-last

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decide what code deserves a comment?▼

Comment only what code cannot express: why something is done, constraints and invariants, non-obvious consequences, external anchors like spec sections or bug links, and deliberate deviations. If a comment explains what the code does, rename variables or extract a function instead.

How do I write comments that survive refactoring?▼

Phrase comments against behavior and contracts, not line positions or names likely to change. References like "the function below" break when code is inserted, while "callers of parse_row" stays true. When a change makes a comment wrong, fix it or delete it.

What should a good docstring include?▼

A docstring should document the contract, not narrate the signature: parameters only where the type is insufficient (units, ranges, ownership), return values with edge cases, exceptions callers should catch, and side effects. Skip restating parameter names in sentence form.

When should I delete a code comment instead of updating it?▼

Delete a comment when the code already says the same thing, when it narrates a diff for reviewers, or when your change makes it wrong and no corrected version adds value. Wrong comments actively mislead debuggers, so nothing may rely on a comment.

Are TODO comments without tickets acceptable in code review?▼

No. Every TODO should carry an owner or ticket reference, such as TODO(#4231) with context. A bare TODO is a wish rather than a plan, and reviewers should ask for the ticket or the fix before approving.