code-comment-discipline

code-comment-discipline is a skill for Claude Code from skyf0xx/hedgehog. It costs 79 tokens per session (486 once invoked), scanned A, original, MIT.

A set of writing rules for comments in source code. It says comments should explain hidden constraints, unusual behavior, or workarounds rather than repeat what the code already shows.

In plain words
What is it for?
It is for deciding when to add, revise, or remove comments while editing code.
Why use it?
It helps keep code readable by avoiding unnecessary comments and preserving only explanations that future maintainers need.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the hedgehog plugin — 22 skills, 5 agents, 1 hook shipped together

Good fit It is for deciding when to add, revise, or remove comments while editing code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/skyf0xx/hedgehog/code-comment-discipline
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add skyf0xx/hedgehog --skill code-comment-discipline
Clone the repo
git clone --depth 1 https://github.com/skyf0xx/hedgehog

Made for: Claude Code.

Or install hedgehog, the plugin that ships this one along with the rest of its 22 skills, 5 agents, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-comment-discipline

README.md
[![agentmods](https://agentmods.dev/badge/skills/skyf0xx/hedgehog/code-comment-discipline/github.svg)](https://agentmods.dev/skills/skyf0xx/hedgehog/code-comment-discipline)
Your own site
<a href="https://agentmods.dev/skills/skyf0xx/hedgehog/code-comment-discipline"><img src="https://agentmods.dev/badge/skills/skyf0xx/hedgehog/code-comment-discipline/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for code-comment-discipline

Your own site · 80×15
<a href="https://agentmods.dev/skills/skyf0xx/hedgehog/code-comment-discipline"><img src="https://agentmods.dev/badge/skills/skyf0xx/hedgehog/code-comment-discipline.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 486 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00079 $0.00486
Opus 5.5 $0.00032 $0.00194
Sonnet 5.5 $0.00016 $0.00097
Haiku 4.5 $0.00008 $0.00049

Measured 1mo ago against content hash 23aebafc13e7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-comment-discipline scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/skills/code-comment-discipline/SKILL.md · 48 lines

What it actually says

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.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 48 lines · 79 tokens per session scan A 23aebafc13e7

Subscribe to this mod's changes

code-comment-discipline is a skill published in the GitHub repository skyf0xx/hedgehog (46 stars, last pushed yesterday), licensed MIT. It adds 79 tokens to every session and 486 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-16.