/whoislewys-skills:write-good-commentsfrom whoislewys-skills
Write and review code comments using Ousterhout's rule from A Philosophy of Software Design (Ch. 12-13) — a comment must carry what the code next to it cannot. Covers interface vs implementation comments, precision comments on declarations, intuition comments on blocks, and cross-module design notes. Use when writing comments or docstrings, reviewing a diff for comment quality, or documenting a public API.
Ships in whoislewys-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A comment earns its place only by describing what is not obvious from the code next to it. "Obvious" means obvious to a first-time reader, not to you.
Comments are how you hide complexity. A declaration alone is not an abstraction — callers can only avoid reading the body if the comment tells them what the body would have.
Every class, every class/instance variable, every method or function gets a comment block. Don't spend energy deciding whether one is needed; commenting everything is cheaper than the deliberation. Trivial getters/setters are the rare exception.
Follow the language's doc tool conventions (Javadoc, Doxygen, godoc, JSDoc, docstrings). If the project has none, copy a neighbouring project's.
After writing a comment, ask: could someone who has never seen this code have written this comment from the code beside it? If yes, it is a no-op — delete it or replace it.
Two reliable symptoms:
// Downcast PARAMETER to TYPE above downCastParameter(String parameter, String type) adds one word: "to".The fix is to change altitude. Every useful comment is either lower than the code (precision) or higher than the code (intuition).
Names and types are imprecise. On a variable, argument, or return value, answer whatever applies:
Document nouns, not verbs — what the variable represents, not how the code manipulates it. If your comment reads "toggled to TRUE when X, toggled to FALSE when Y", rewrite it as "true means X has happened since Y" and let the reader infer the writes.
// Vague:
uint32_t offset; // Current offset in resp buffer
// Precise:
// Position in this buffer of the first object that hasn't been
// returned to the client.
uint32_t offset;
Above a block, a loop, or a method body, say what the code is trying to do and why we get here — never how.
Ask: what is the simplest sentence that explains everything in this block? A good one gives the reader a framework ("append this key hash onto an existing RPC that hasn't been sent yet") from which the individual conditions become self-explanatory — and gives them a basis to judge whether the code is correct.
Short methods that do one thing need no implementation comments at all — the interface comment already said it.
Keep them separate. Interface = what a caller needs to use it. Implementation = how it works inside. A caller must never have to read implementation detail to use the thing.
A method's interface comment covers:
A class's interface comment covers the abstraction it provides, what one instance represents, and its limitations (e.g. "single-threaded; processes one request at a time"). No internals, no config-parameter tour, no "include this header" — the reader can guess that.
Red flag — implementation leaking into interface docs. Strip it; if it's still useful, move it inside the body.
Red flag — the interface comment has to describe the implementation. That's a design signal: the class or method is shallow. Fix the design, not the comment.
Also cut from interface comments anything invisible to the caller — crash recovery the system handles automatically, private constants, RPC names.
For a decision spanning several files (a protocol, an enum whose values must be registered in six places):
designNotes / CONTEXT.md section and leave one-line pointers at each dependent site: // See "Zombies" in designNotes. Never duplicate the prose.Work through the diff and apply, in order:
If a reader says a comment isn't obvious, it isn't obvious. Don't argue — find what confused them and fix the comment or the code.
Done when: every declaration in the diff is commented, no remaining comment could be reconstructed from the code beside it, and no interface comment mentions internals.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub whoislewys/skills --plugin whoislewys-skills12 skills in this plugin
/c4-architectureGenerate architecture documentation using C4 model Mermaid diagrams. Use when asked to create architecture diagrams, document system architecture, visualize software structure, create C4 diagrams, or generate context/container/component/deployment diagrams. Triggers include "architecture diagram", "C4 diagram", "system context", "container diagram", "component diagram", "deployment diagram", "document architecture", "visualize architecture"./task-diagramuse when user asks for a "task diagram", or asks for help in performing "Applied Cognitive Task Analysis"/commitCreate a conventional commit message/explain-diff-htmlUse when the user asks for a rich explanation of a code change, diff, branch, or PR. Produces HTML output./fix-dep-auditResolve dependency security audit findings by preferring minor version upgrades to base packages first, then targeted fixes, verifying with pnpm audit after each change. Use when fixing dependency vulnerabilities or remediating a dependency audit./improve-readabilityCode readability principles from John Ousterhout's A Philosophy of Software Design, drawing on Ch. 2 (Nature of Complexity), 4 (Modules Should Be Deep), 10 (Define Errors Out of Existence), 13 (Comments Describe What Isn't Obvious), 14 (Choosing Names), 17 (Consistency), and 18 (Code Should Be Obvious). Covers obvious code, strategic naming, why-not-what comments, eliminating special cases, and visual grouping. Use when improving readability, naming variables, writing comments, or reviewing code for clarity and cognitive load.