Skip to content
Back to skills

Code Comment Discipline

ASecurity

Apply whenever writing or editing source code in any core's build agent (backend-eng, ui-builder, or equivalent). Governs when a comment belongs at all and what it may say. Default is no comment; a comment is only for the non-obvious. Never restates what the code does, never narrates the task, fix, or conversation that produced it.

  • 43 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 20, 2026
ai-agentsgoapibackend

Works with

  • api

Security analysis

A100/100

Scanned September 20, 2026

npx -y skills add skyf0xx/hedgehog --skill code-comment-discipline --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Comment Discipline?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Comment Discipline
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/skyf0xx-code-comment-discipline/badge)](https://www.skillsdirectory.com/skills/skyf0xx-code-comment-discipline)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: code-comment-discipline
description: Apply whenever writing or editing source code in any core's build agent (backend-eng, ui-builder, or equivalent). Governs when a comment belongs at all and what it may say. Default is no comment; a comment is only for the non-obvious. Never restates what the code does, never narrates the task, fix, or conversation that produced it.
---

# Code Comment Discipline

Well-named identifiers and clear structure explain what code does. A
comment earns its place only when it explains something the code cannot:
a hidden constraint, a non-obvious invariant, a workaround for a specific
external bug, or behavior that would surprise a reader.

## Default: no comment

Most lines, functions, and blocks need zero comments. Before writing one,
check whether the same clarity is reachable by renaming a variable or
function instead — prefer that over a comment every time.

## When a comment is allowed

Only for the non-obvious:

- A constraint imposed from outside the code (an API's undocumented
  limit, a browser quirk, a platform requirement) that isn't visible at
  the call site.
- An invariant the code relies on that isn't implied by types or names
  (e.g. "callers must hold the lock before this runs").
- A deliberate workaround for a specific bug in a dependency, with enough
  detail to know when it's safe to remove.
- Behavior that looks like a mistake but is intentional.

## What a comment must never say

- What the code does — that's the identifier's job, not the comment's.
- Why *this* task needed the change, who asked for it, or which ticket,
  issue, or conversation prompted it.
- History: "used to be X," "changed from Y," "removed Z," "previously,"
  "now we," or any other before/after narration. A comment states the
  current state and its non-obvious reason only, never how it got there.
- A restatement of the function/variable name in prose ("increments the
  counter" above `counter++`).

## Applying to existing comments

When editing a file that already has comments violating these rules,
remove or rewrite them as part of the same change rather than leaving
them in place — don't let a nearby edit normalize the pattern.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.