comment-patterns

Guides writing and reviewing code comments in C, Go, Rust, and Zig.

Updated Jul 4, 2023
One-click install
npx skills add https://github.com/kohdice/dotfiles --skill comment-patterns-kohdice
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: comment-patterns
Source: https://github.com/kohdice/dotfiles/tree/main/config/agents/skills/comment-patterns
Command: npx skills add https://github.com/kohdice/dotfiles --skill comment-patterns-kohdice

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code comments often restate the obvious, rot into misleading claims, or duplicate information that belongs in commits and tests. This Skill provides a clear policy for deciding whether a comment belongs, where each kind of explanation should live, and how to audit comment noise during reviews. ## Core Features & Use Cases - Documentation-layer policy: Routes each explanation to the right layer — code for how, tests for what, commits for why, and comments for why-not knowledge that prevents incorrect edits. - Defect catalog for reviews: Classifies restating, journal, banner, crutch, echo-doc, misleading, dead-TODO, and missing why-not comments, each with a concrete fix rule. - Per-language conventions: Applies Go doc-comment rules, Rust /// sections and safety justifications, Zig //////! style, and C project conventions without double-covering sibling idiom skills. - Use Case: While reviewing a Rust pull request, use this Skill to flag a stale doc comment whose contract contradicts the implementation, delete a redundant inline comment, and propose a why-not comment for a non-obvious workaround. ## Quick Start Review the comments in this Go file and flag any that are redundant, misleading, or misplaced according to the comment-patterns policy.

Frequently Asked Questions about comment-patterns

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

FAQPage Schema
How do I decide whether a code comment is worth keeping?▼

A comment earns its keep when it carries local knowledge the code cannot express, such as a rejected alternative, an unenforceable constraint, or a relevant external reference. If it merely restates the adjacent code, delete it rather than rewriting it.

How to review comments in Go, Rust, or Zig code?▼

Judge each language by its own conventions: Go doc comments per go.dev/doc/comment, Rust `///` sections including Safety and Errors, and Zig `///`/`//!` per the Zig Style Guide. Machine-read directives like `//go:build` are code and should never be flagged.

What belongs in a code comment versus a commit message?▼

Commits own why the change was made: motivation, tradeoffs, and history. Comments own why-not knowledge that prevents a future incorrect edit, such as why a simpler alternative fails or why an ordering constraint must hold.

When should I not flag a comment as redundant?▼

Never flag comments mandated by language idioms, such as Go doc comments on exported symbols, Rust safety justifications on unsafe blocks, or deprecation markers. Machine-read comments like build tags and lint suppressions are also exempt.

Why is a wrong comment worse than no comment?▼

Comments rot silently and mislead readers with authority, making misleading comments the most severe defect class. When changing code, updating or deleting every comment whose claim the change touches is part of the change itself.