Gives every source file one header comment block that answers what it does, why it exists, how it works and why no other implementation was chosen, and moves the scattered body comments out of the way. Use when a file's comments must be written or gathered into one header.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Annotate?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/uniterra-solutions-annotate)
---
name: annotate
description: "Gives every source file one header comment block that answers what it does, why it exists, how it works and why no other implementation was chosen, and moves the scattered body comments out of the way. Use when a file's comments must be written or gathered into one header."
version: 2.0.0
author: Tsz Kin Lai (LaiTszKin), Hermes Agent
license: MIT
platforms: [linux, macos, windows]
metadata:
hermes:
tags: [software-development, comments, documentation, design-rationale]
related_skills: [plan, explain]
---
# Annotate — one header per file, four questions
## Context
Collect this before writing a single line of header, because each item is the only source a correct answer can come from.
- **The file in full.** A header written from the file's name describes the name rather than the mechanism.
- **What the file does.** The responsibility it holds, the entry points it exposes, and what a caller gets back. A responsibilty is stated as the outcome a caller receives, not as the list of functions exported.
- **Why the file exists.** What breaks if it is deleted, and which neighbour could not absorb it. A file kept for one caller names that caller.
- **How it works.** The mechanism in the order a reader needs it: the shape of the data, the steps a call goes through, the state kept between calls, and the boundary the file does not cross.
- **Why the alternatives lost.** The implementation that was plausible here and the constraint that ruled it out, taken from the commits, the PRD, an issue or the user — never invented.
- **Every comment already in the file**, each a candidate for the header, for a test, for a type, or for deletion (`references/what-stays-inline.md`).
- **The language's attachment rule**, because a Python module docstring, Rust's `//!`, a Go package comment and JSDoc attach in different places (`references/header-per-language.md`).
## Goal
Every file opens with one header block that answers the four questions in order and nothing else (`references/header-content.md`), and nothing inside the body remains but what a machine reads or a symbol's contract requires.
The four answers, as the shape the header must reach:
1. **What the file does** — one sentence naming the responsibility and the entry points, describing the outcome rather than the contents. A file with two unrelated responsibilities cannot be answered in one sentence, and that is a finding about the file rather than an obstacle to the header.
2. **Why the file exists** — what breaks if it is deleted, and the second half: why a neighbour could not absorb it.
3. **How it works** — the mechanism, the surprising part stated plainly, and the boundary named: what the file deliberately does not do, handle or know.
4. **Why no other implementation was chosen** — the alternative a competent reader would have considered, the constraint that ruled it out, and the cost the choice still carries.
What stays inline is a closed list: a machine-read directive, the licence header, the generated marker, and a doc comment the language attaches to a public symbol (`references/what-stays-inline.md`). Everything else that currently sits in a body comment has a better home or none — rationale moves into the header, a warning about the file's shape is a property of the file, an invariant becomes an assertion or a test, a stale TODO becomes an issue or nothing, a changelog or author or date becomes git.
## Constraints
- **Every answer states something the code does not say**, because a header that restates the signature has moved the code rather than explained it. A header that restates the file name, or describes the language rather than this file's use of it, is the same failure (see the weak/strong pairs in `references/header-content.md`).
- **The fourth answer names a plausible alternative and the constraint that ruled it out**, because a rejected option nobody would have picked explains nothing. "Chosen for simplicity" is not an answer.
- **An answer the evidence does not support is asked of the user or marked `unknown`**, because an invented rationale survives longer than the truth.
- **The header fits on one screen**, because a header nobody reads to the end is a comment in the way.
- **Do not narrate the history** — who wrote it, when, which ticket, which refactor — because git holds that with more precision than a comment can carry.
- **Do not promise a behaviour the code does not guarantee**, because a header that over-claims is read as the contract.
- **Do not keep a second copy of the code's reasoning inline**, because the two then disagree and the older one is the one a reader finds.
- **Before deleting a comment that looks load-bearing, ask what would catch the defect it was preventing** — a test, an assertion or a type — because the comment is redundant when one exists, and the missing check is the thing to write when none does.
- **The file still compiles and its tests still pass**, because a header edit that changes behaviour is a refactor wearing a comment.