Purges comments from a codebase by lexing, classifying as tautology/stale/excuse/decision record, deleting stale/tautology comments, filing issues for excuses, and encoding decision records into ADRs or code. Use for /delete-comment or when asked to audit or remove all comments.
Ships in delete-comment. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill removes the comments a codebase does not need and keeps the facts that some comments carry. It runs in four phases:
The scanner, scripts/comments.py, does the mechanical work: it finds comments with a real lexer, keeps the comments that tools read, deletes only what the verdicts allow, and checks that no code token changed. You do the judgment: what each comment is, and where its fact goes.
| Category | The comment… | Action |
|---|---|---|
| Tautology | says what the code already says: a name, a type, the next line, a section divider | Delete |
| Stale | is false now: it names code that moved, describes old behavior, or is commented-out code | Delete |
| Excuse | admits or excuses a defect: TODO, FIXME, HACK, "workaround", "for now", "not ideal", "legacy" | File an issue, then delete |
| Decision record | states a non-obvious decision or an outside fact that a change must respect | Encode it in code or a test if you can; otherwise write an ADR. Then delete |
Apply the tests in this order, and take the first that fits:
The test between the two hard categories: an excuse says this should be different; a decision record says this must stay as it is. "Sleep 2 s because the ready event is not wired up yet" is an excuse. "Sleep 2 s: the vendor rate-limits bursts and returns 429 without a Retry-After" is a decision record.
Some comments are read by tools, so deleting them changes behavior. The scanner gives them the kind directive or license and never deletes them:
# /// script blocksnoqa, type: ignore, pyright:, eslint-disable, @ts-expect-error, prettier-ignore, fmt: off, pragma: no cover, istanbul ignore, NOLINT, nolint, shellcheck disable=, rubocop:disable, and more//go:build, //go:generate, {-# LANGUAGE … #-}, /// <reference …>, /* @__PURE__ */, // fallthrough, Fortran !$ompgitleaks:allow, pragma: allowlist secret, nosec), Makefile ## help text, Dockerfile parser directivesThe list errs toward keeping. A false directive keeps one comment; a missed directive deletes something a tool needs. Pass a repository's own directives with --allow REGEX.
Two other things stay out of scope by default:
help(), Sphinx, doctests, and CLI frameworks read them at run time./** */, ///, //!, Go comments on declarations, @param blocks) feed IDE hovers and generated API docs. The scanner reports them as kind doc. Include them only when the user asks; then classify them like plain comments.Detect what you can and propose defaults. Ask the user only about the rest, in one message:
| Setting | How to detect it | Default |
|---|---|---|
| Scope | the user's words | the whole repository |
| Doc comments | the user's words | keep them |
| Issue tracker | gh repo view, Linear tools, the tracker named in CONTRIBUTING | ask |
| ADR directory | docs/adr, doc/adr, docs/decisions, docs/architecture/decisions, adr | docs/adr/ |
Filing issues publishes text outside the repository, so confirm before you file. Commit only when the user asks.
Define a shell function once, so the command works in bash and zsh. --no-config keeps the target repository's uv settings out of the script's own dependency install:
comments() { uv run --no-config --script "<this skill's directory>/scripts/comments.py" "$@"; }
work=$(mktemp -d) # inventory, verdicts, and issue drafts live here
comments estimate src tests # the numbers, before any edit
comments inventory src tests > "$work/comments.jsonl"
comments inventory src --format tsv | less # a skimmable view
Keep the working files outside the repository, so they do not land in the change. Run the commands from the repository root, and note the paths you scan: Phase 4 measures the same paths. --exclude GLOB skips paths, and --language NAME limits the scan to one pygments language; both repeat.
Without uv, python3 scripts/comments.py works when pygments is installed.
Give the user the estimate first: it answers "how many lines will this remove" before any work. Report the numbers as the scanner states them:
x = 1 # why) shortens a line but removes none.--exclude or --language if the user wants code only.Classify every plain item in $work/comments.jsonl (and every doc item if doc comments are in scope). For each item:
hints as leads, not verdicts: todo and excuse suggest an excuse, code suggests commented-out code, divider suggests a tautology."prose": true is a directive with an explanation attached (# noqa: E501 # the URL cannot wrap). The directive stays; treat the explanation like a plain comment and edit it by hand if it must go. The scanner keeps every directive, even one that no longer suppresses anything; Ruff's RUF100 and ESLint's --report-unused-disable-directives find those.Write one JSON line per verdict. Copy the inventory record and add category, plus ref and note where they apply:
{"id": "3f9c0a1b2c4d", "path": "src/billing.py", "category": "excuse", "ref": "", "note": "sleep stands in for the ready event"}
category is one of tautology, stale, excuse, decision, or keep. Use keep only when the comment must stay and the scanner missed why, such as a directive it does not know. Then pass a matching --allow pattern on later runs, so the scanner agrees.
Large scopes. Split the inventory by directory and give each part to a subagent with this brief: the policy table, the order of tests, the four steps above, and the verdict format. Then audit a sample of each part yourself. Check every tautology that sits on a guard, a lock, a retry, a sleep, a magic number, or an ordering, because those are usually decision records. Also check the evidence behind every stale verdict.
Then run comments estimate --verdicts "$work/verdicts.jsonl" and show the user the lines per category before you change anything.
ref: a URL, owner/repo#N, #N, a tracker key such as ENG-341, or a file that holds the draft. The delete command refuses to delete an excuse without one.Each issue states:
First try to move the fact into the code, where it cannot drift from what it describes:
timeout_ms instead of timeout # milliseconds; MAX_UPSTREAM_RETRIES = 2 instead of 2 # the vendor allows two.Cents type instead of # amounts are in cents.test_retries_stop_after_two_attempts_because_vendor_bans_the_third. This is the strongest home for a guard, a lock, or an ordering, because the test protects the behavior, not only its explanation.Do not move prose into a string, an unused variable, or a log message. That is a comment in disguise.
When no name, type, or test can carry the fact, write an ADR. references/adr.md has the template, numbering, how to recover the decision's history with git, and how to keep ADRs findable once the code cannot point to them. Merge comments that record the same decision into one ADR. Once the comment is gone, nothing in the code points to the ADR, so add one line to the repository's AGENTS.md or CLAUDE.md (whichever exists; if neither does, create AGENTS.md): before changing a file, search the ADR directory for its path.
Put the ADR path, the path of the test or code that now carries the fact, or a URL in the verdict's ref. The delete command refuses to delete a decision record without a ref that exists.
comments delete --verdicts "$work/verdicts.jsonl" --dry-run
comments delete --verdicts "$work/verdicts.jsonl"
delete removes tautologies and stale comments, and excuses and decision records that have a ref. It removes a full-line comment with its line, and a trailing comment with the spaces before it. It never removes a directive or license item. Before it writes a file, it lexes the result again and requires the same code tokens; for Python it also requires the same AST. It leaves a file unchanged when either check fails, and it reports ids that no longer match because the file changed since the inventory.
Then run the repository's formatter, linter, type checker, and tests. When one fails because of a deletion, restore that file with git checkout -- <path>, find the comment the failure depends on, change its verdict to keep with a note that names the failure (or fix the code it was propping up), and run delete again. Watch for:
no-empty accepts catch (e) { /* ignore */ } but rejects the empty block once the comment is gone. Fix the code (handle or log the error), not the linter.Split the work so that each commit is easy to review:
Measure; do not repeat the estimate. Run comments estimate again on the Phase 1 paths and compare. Report:
This skill is the repeatable process. Run it again on the paths you scanned: the plain comments that remain are the worklist. To pin the repository's settings for the next run (the scope, the exclusions, the tracker, the ADR directory), add a short section to the repository's AGENTS.md or CLAUDE.md. If the team does not install this skill, write a repository-local skill instead, at .claude/skills/delete-comment/SKILL.md (or .agents/skills/ for other agents): the settings, the policy table, the order of tests, and the commands, run against a copy of scripts/comments.py in the repository (for example tools/comments.py), so it works without this skill.
| Command | What it does |
|---|---|
inventory [PATH …] [--kinds plain,doc|all] [--format jsonl|tsv] | One record per comment item |
estimate [PATH …] [--verdicts FILE] [--json] | Lines per kind, the lines a purge removes, and lines per verdict category |
delete --verdicts FILE [--dry-run] | Delete what the verdicts allow, behind the token check |
Every command also takes --exclude GLOB, --allow REGEX, --language NAME (each repeatable), and --jobs N. Pass the same ones to every command in a run: --allow changes how comments group, and so their ids.
An inventory record has id, path, line, end_line, column, language, kind (plain, doc, directive, license), placement (full-line, trailing, inline), lines (the lines a delete frees), text, reason (why it is a directive, license, or doc comment), prose, and hints. Consecutive full-line comments at one indentation form one item. The id depends on the path, the text, and the order of identical comments in the file; edit a file and its ids can change, so run inventory again before delete.
The scanner skips binary, minified, and generated files, files over 2 MB, vendored directories (node_modules, vendor, third_party, virtual environments), files with no pygments lexer, and prose or data formats (Markdown, reStructuredText, text, JSON, XML, diffs). estimate reports what it skipped and why.
gh issue create, files the excuse issues.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/delete-comment:delete-commentfrom delete-comment
npx claudepluginhub dashed/claude-marketplace --plugin delete-commentOther plugins' skills for the same job