/code-tidying:remove-comments [audit|report|safe] [none|necessary|explanatory] [override] [target] [--repo <repo> ...]from code-tidying
Edits code to strip zero-information comments, rename/restructure explanatory ones, and keep load-bearing ones. Supports safe mode and edit-free audit reports.
Ships in code-tidying. 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.
Run each command below as its own Bash call, all sent together in one message (worktree isolation).
Keep any bound in the command's own pipe (output limits).
Unless this section says otherwise, treat a failure (not a repository, git unavailable) as an unknown value and carry on. Keep these as body calls, never ## Pre-computed context lines (gather-block convention).
git branch --show-currentScope (rung, base, count, then a 10-path preview; re-run the script without --max for the full set): !${CLAUDE_SKILL_DIR}/scripts/scope-code-files.sh --max 10 2>/dev/null || echo "(not a git repository)"
Tooling layer (present/absent per analysis layer; an absent row names the capability lost): !${CLAUDE_SKILL_DIR}/scripts/comment-tooling-probe.sh 2>/dev/null || echo "(probe unavailable)"
Repository settings (team then personal layer, one line per key): !${CLAUDE_SKILL_DIR}/scripts/settings.sh 2>&1 || echo "(settings unavailable)"
All three run before the argument is read, so each is a preview: the scope line is void whenever the argument names an explicit target, and the tooling line is re-derived in the workflow.
Arguments: $ARGUMENTS
Each key resolves through four layers, lowest first, a later one winning: the default below,
userConfig, the team layer, and the personal override; a policy key also reads the org baseline
below the team layer. For the comment policy keys
(comment_posture, comment_keep_list, class_c_max_lines) the team layer is
<home>/comment-policy.yaml over the org baseline <home>/comment-policy.org.yaml (the team file
may tighten the org posture, never loosen it), and the personal override is
<home>/comment-policy.local.yaml; for the others it is <home>/code-tidying.yaml and <home>/code-tidying.local.yaml. <home> is the
repository's bound convention home, else docs/conventions (the settings line above, from
${CLAUDE_SKILL_DIR}/scripts/settings.sh). A policy key a comment-policy file does not set is read
from the same layer's code-tidying file, and a comment-settings: line in the settings output names
each code-tidying file still holding one: repeat it in the report's first lines, with
/code-tidying:setup apply as the move. A per-run token beats every layer. A layer holding a
value outside a key's set is named (file or userConfig, key, value) and dropped; a valid higher
layer still wins, else the default. Report each key's value and the layer it came from once, in
the report's first lines.
| Key | userConfig | Values | Default |
|---|---|---|---|
comment_posture | ${user_config.comment_posture} | auto, none, necessary, explanatory | auto: necessary |
comment_keep_list | ${user_config.comment_keep_list} | default, or a repository-relative path to a file | default: reference/keep-list.md |
comment_edit_scope | ${user_config.comment_edit_scope} | diff, files | diff |
encode_constraints_unattended | ${user_config.encode_constraints_unattended} | true, false | false |
class_c_max_lines | ${user_config.class_c_max_lines} | 1 to 40 | 2 |
apply_local_renames | ${user_config.apply_local_renames} | true, false | true |
hard_exclusions is ${user_config.hard_exclusions} (enforce, the default, or advisory) from
userConfig alone: tidy's exclusions reference owns its channels, and a repository lifts paths through
its overrides file. An unexpanded or empty userConfig value is unset. Old posture values still resolve: strict and
balanced read as explanatory, conservative as explanatory plus safe, aggressive as
necessary. Old per-run tokens too: aggressive means necessary and strip means none.
comment_keep_list replaces what necessary keeps above the floor; it never changes the floor.
A path holds the repository's own criteria in the shape of the shipped file; an absolute path, a
.. segment, a symlink anywhere on the path or a path naming no regular file is invalid. The
settings line checks the file layers; check a userConfig path with
${CLAUDE_SKILL_DIR}/scripts/settings.sh --keep-list <value> and drop it when the line says
invalid. The resolved list's path is absolute: ${CLAUDE_SKILL_DIR}/reference/keep-list.md for
default, else the repository root joined with the value. Under necessary, read it before
triage, and when it is not the shipped one, name its path in the report's first lines.
--pipeline marks a run the pull-request pipeline starts. It changes no setting, and
whether a run may ask is still decided by the AskUserQuestion tool, in the workflow's step 1.
Make the code in scope self-describing and remove every comment that does not earn its keep. The floor the canonical sources jointly sign: implementation code only needs comments when the code is nonobvious. The prime target is agent-written code, which over-narrates by default; this is a tidy-after-generation pass, not a generation-time ban. The target is over-narration, not density: a hand-written contract-heavy file is legitimately comment-dense, and a full pass over one can end at zero edits.
| Argument | Action |
|---|---|
| (empty) | Remove under the resolved posture, over the narrowest scope rung that resolves: uncommitted diff → branch diff → whole repository (reference/scope.md). The repository rung is taken without asking and, outside report, runs in safe mode whatever the posture or token (actions/remove.md step 1). Read actions/remove.md, run its steps 1 and 2, then dispatch per The comment-reviewer agent. |
<path> | The same, over one file or directory; the pre-computed scope line is void: ignore it and do not run scope-code-files.sh. |
audit [target] | Read-only residue audit: history narration, plan and session references, conversational asides, ticket back-references, origin notes, unjustified workarounds. Read actions/audit.md. Its residue shapes: reference/shapes.md. Edits nothing and never asks. |
report [target] | Remove's triage with nothing applied: every treatment is a proposal. Combines with a posture token, override and --added-since; beats safe. Rules in actions/remove.md. |
safe [target] | Only class-A deletions apply; every class-B move, class-C deletion and rewrite is a proposal. Beats any posture token. |
none, necessary, explanatory | This run's posture, over every layer. |
override [target] | Lift the GLOBAL HARD path list for this run's target, so /code-tidying:remove-comments override ruff.toml triages a file the list would drop. Path entries only; every lifted path is named in the report with its channel. |
--added-since <base> | Only comments on lines the branch adds against the merge base of <base> and HEAD, from ${CLAUDE_SKILL_DIR}/scripts/added-lines.sh <base> (<start><TAB><count><TAB><path> per hunk). With no target its files are the scope and scope-code-files.sh is not run. Exit 2 is reported and the run stops. |
--base <ref> | With no target, the scope is the branch's changed code files against the merge base of <ref>, uncommitted and untracked ones included, from ${CLAUDE_SKILL_DIR}/scripts/scope-code-files.sh --branch-only --base <ref>, and comment_edit_scope sets the granularity. It never widens: nothing changed is files=0. Exit 2 is reported and the run stops. --added-since beats it. |
--notes <path> | Append the staged narrative block to <path> too. Refuse a symlink, then check git ls-files --error-unmatch <path>: a tracked or symlinked path is refused, the run continues, and the block is reported only. |
--pipeline | The run is the pull-request pipeline's comment pass; it changes no setting. |
--repo <repo> (and the other target forms) | Any action above, once per repository, per Over several repositories. |
The argument hint leaves out --added-since, --base, --notes and --pipeline to stay within
its length budget; this table lists every token. Match tokens whole and strip them before reading the target. ./safe, ./none, ./report and
the like are paths, not tokens. Precedence: report decides that nothing applies; then safe;
then a posture token; then the resolved setting.
With no target form, the run covers this checkout. A target form (--repo,
--repos-from, --owner, --fleet, --skip, or the same request in words) selects several
repositories, which resolve, count, fan out and merge as
${CLAUDE_PLUGIN_ROOT}/reference/target-scope.md "Target
forms", "Resolving repositories", "Fan-out" and "Merging findings" say. Strip the target-form
tokens first; every other token applies in each repository, except as below. What differs here:
<path> target, each repository takes the rung
scope-code-files.sh resolves in that checkout, reported with its findings, and the safe-mode
rule that rung carries; a clean clone on its base branch resolves to the repository rung.
--added-since and --base read one checkout's branch diff, so with a target
form they stop the run and name the repository rung or a <path> instead. A <path> target
resolves under each root, and a repository where it does not exist is reported skipped. The
pre-computed lines describe this checkout only: the per-repository subagent runs
scope-code-files.sh, comment-tooling-probe.sh and settings.sh with that repository's root
as its working directory, under its own permissions, and reads the settings and the keep list
from that repository.audit and report read the clone on disk, since a worktree would be a write.
After the fetch, a repository other than the session's own whose checked-out HEAD is not
origin/HEAD, or whose working tree has uncommitted changes, is read as it stands, and the
report says so for that repository.audit and report write to no repository other than the session's
own. A run that edits works in one repository at a time, as target-scope.md "Writes stay per
repository" says: for a repository other than the session's own, in a worktree that
repository's convention creates, never its main checkout, and the scope above is read in that
worktree. The diff is left for review there, as in a single run, and ships as that repository's
own pull request.report
run writes one only for the session's own repository; for every other, the rows go in the
merged report.A run that may apply edits (not audit, not report) hands the triage and the comment-only edits
to code-tidying:comment-reviewer, a fresh agent that did not write the code, whenever a subagent
tool (Agent, listed as Task on some surfaces) is available, however small the scope: the point is a
reader other than the author, and a small diff gets that reader too. This skill stays the
orchestrator: it runs workflow steps 1 and 2, dispatches, checks what comes back, applies the
class-B moves, and reports.
diff), posture, settings, under
necessary the resolved keep list's path, the discovered markers and the tooling layer. Model and effort: the
agent's own definition, unless
/multi-agent:route worker code (if enabled) reports a config layer (basis config) that
sets the worker role, in which case pass that role's single variant model and effort.change-shape.sh on every file it touched, before
against after: anything but COMMENT-ONLY, or DOCSTRING-ONLY on a Python file whose only
difference is docstring deletions, is reverted. Check each deletion against the floor and
the posture's keeps (Postures), the resolved keep list under necessary only, and
each keep against the rule it names. Reject a report that edits code,
reaches outside the scope, deletes a kept comment or misstates a reason./architecture:adr (if enabled) per ADR candidates, write
the findings file (actions/remove.md) from the rows it
listed, less the reshape flags whose move you applied and plus one for each move whose gate
failed, then report.With no subagent tool, or when this skill is itself running inside comment-reviewer, run the
workflow in actions/remove.md inline.
The posture decides which comments stay. Class tests are in reference/triage.md; the gates in reference/safety.md.
explanatory | necessary | none | |
|---|---|---|---|
| Default for | opt-in only | every run (auto) | opt-in only |
| Class A | deleted | deleted | deleted |
| Class B | dissolved by its move when the gate passes, else kept with a proposal | dissolved when the gate passes, else deleted with a reshape flag | deleted with a reshape flag; no move is attempted |
| Class C | kept when it passes the earn-its-keep test, rewritten terser over the line budget; a criterion-2 failure is deleted | only the resolved keep list stays; every other comment is deleted with a reshape flag or an open-constraint line, never rewritten | only the floor stays |
| A tie (doubt about a class or a keep) | keeps the comment or proposes | deletes, except doubt about the floor, which keeps | deletes, except doubt about the floor |
The floor, kept in every posture: machine-read directives (shebangs, lint pragmas, encoding
cookies, region markers, repo-local markers the workflow discovers, remove-comments-ignore and
dissolve-comments-ignore lines, the comment trailing a uses: line pinned to a full commit id,
whatever its wording), suppression justifications paired with their waiver, legal and
license headers, TODO(#issue) markers, and a comment that is one half of a comment-plus-regression-test
pair, because deleting half of a paired record is a correctness bug. A pragma that waives a
correctness or safety rule stays (deleting it changes lint output, so it is not a comment edit), and
under none and necessary its symbol is listed as open root-cause work.
What necessary keeps above the floor is the resolved keep list: the shipped
reference/keep-list.md, or the file comment_keep_list names. A keep
other than a public-API doc comment or a script's exit-code list is held to class_c_max_lines.
Unless the list keeps it, a warning of consequence, a unit or sentinel annotation, a section divider and rationale about this
repository's own code are our-code surprises: deleted, narrative staged, and
each one a reshape flag naming the symbol and the move that would make the comment unnecessary
(rename, extract, a type, an assertion, a redesign). A constraint the code could enforce gets the
encode step in actions/remove.md.
What none keeps above the floor: public-API doc comments, except that one which only restates
the signature is proposed for deletion, never deleted.
ADR candidates (necessary and none): a deleted comment that records one of this
repository's own deliberate decisions and names the alternative it was chosen over is an ADR
candidate as well as a reshape flag; one that names no alternative is a reshape flag only. The
run that triages it lists it in the report. In an interactive run with the architecture plugin
enabled, the orchestrator, never comment-reviewer, then invokes /architecture:adr (if enabled)
via the Skill tool for each listed candidate, with the decision, the alternative and the comment's
text; that skill owns and applies the admission test. Otherwise
(unattended, report mode, or no architecture plugin) the candidate stays listed. For each ADR
candidate, the orchestrator also passes the domain terms the comment uses to
/domain-driven-design:ubiquitous-language lookup (if enabled); each term the glossary lacks is a
glossary-candidate row in the findings file. With no domain-driven-design plugin, or no glossary,
no row is written.
What explanatory keeps is the full earn-its-keep contract: the floor, the public-API doc
comments, unit and sentinel annotations on the adjacent declaration, and every class-C comment that
is inexpressible, load-bearing where it is read, and within the line budget.
No posture loosens a gate. Every applied deletion carries COMMENT-ONLY (DOCSTRING-ONLY for a Python docstring), every applied function-local rename carries RENAME-ONLY, tier-2 and tier-3 moves need a discovered test net, and an UNPROVABLE file yields proposals only.
/source-control:commit (if enabled) (and appended to --notes when
given). Under explanatory a class-B comment's information moves into code before the comment
goes; under necessary and none a class-B comment the run cannot dissolve goes to the staged
block and a reshape flag. The block carries an Intentional-removal: line only when the target
repository's own scripts or CI read that trailer. On an explicit target over committed code, the
landing place is the next commit touching that code, named in the report. When the target
repository squash-merges with the pull request's body as the commit message
(merge message for a squash merge),
the branch commit's message never reaches the default branch: the landing place is the body of
the pull request that ships the change, which takes the whole block, trailer included. Decide it
from the repository's squash-merge commit-message setting, read through the forge's repository
API; when that cannot be read, name both the pending commit and the shipping pull request's body,
so the block survives either merge style.${CLAUDE_SKILL_DIR}/scripts/change-shape.sh (COMMENT-ONLY,
RENAME-ONLY); additive and interface-creating moves need a discovered test net. Any other verdict
reverts the edit and demotes it to a proposal, and so does UNAVAILABLE or no verdict. This holds
however the file is written: a shell edit needs the same verdict as an Edit call.change-shape.sh gives when such removed
docstrings are the edit's only difference and none of the file checks in
reference/safety.md (tier 0) refuses it. A class or method docstring
deletion always reads CODE-CHANGED and is a proposal. It gates
docstring deletions the way COMMENT-ONLY gates comment deletions, under necessary and none;
under explanatory, or with any other verdict, a docstring deletion is a proposal. The proof
reads one file, so a repository search for the owner's name in every other file comes first:
any hit other than a direct call (the name immediately followed by (), or any __doc__,
__dict__, vars, help, getdoc or getmembers beside it, makes the deletion a proposal.override argument, a glob in
.claude/code-tidying/exclusion-overrides.md, or hard_exclusions: advisory. Precedence per path
is argument, then repository file, then setting, then enforced. The behavioral guards, the
work-tracking entries and SELF-UPDATE EXTRA HARD hold at every setting./docs-hygiene:audit-noise (if enabled) territory./code-tidying:tidy's Explaining
Comments tidying./code-tidying:audit-dead-code, the rest to open work./code-tidying:tidy or /code-tidying:batch-simplify: no focus-area rotation, no scope budget, no
wave machinery, one pass over one resolved scope./code-review and /simplify own those, and
/ai-slop:audit (if enabled) owns prose./code-metrics:audit-suppressions (if enabled), which marks
the correctness rules; point to it over the same scope rather than rebuilding it./source-control:commit./review:fanout fix./implementation:implement./debugging:debug./architecture:improve./architecture:adr./domain-driven-design:ubiquitous-language curate.explanatory doubt keeps or proposes, and under necessary
and none the narrative is staged before anything is deleted.explanatory
it is staged and deleted, since rejected alternatives belong in the commit or PR that removed them,
or in an ADR when the decision is an ADR candidate.necessary stays open work until its cause is fixed.Doctrine, with what each source contributes and two misreadings corrected: reference/sources.md. Tooling, measurements and install commands: reference/tooling.md.
| Old | Now |
|---|---|
/code-tidying:dissolve-comments | /code-tidying:remove-comments |
strip | none |
aggressive | necessary |
posture strict, balanced | explanatory |
posture conservative | explanatory with safe |
actions/audit.md (opens in a new tab)actions/remove.md (opens in a new tab)evals/evals.json (opens in a new tab)evals/fixtures/origin-notes.sh (opens in a new tab)evals/fixtures/residue-snippet.py (opens in a new tab)reference/dissolving-moves.md (opens in a new tab)reference/keep-list.md (opens in a new tab)reference/safety.md (opens in a new tab)reference/scope.md (opens in a new tab)reference/shapes.md (opens in a new tab)reference/sources.md (opens in a new tab)reference/tooling.md (opens in a new tab)reference/triage.md (opens in a new tab)scripts/added-lines.sh (opens in a new tab)scripts/change-shape.sh (opens in a new tab)scripts/changed-code-files.sh (opens in a new tab)scripts/comment-census.sh (opens in a new tab)scripts/comment-tooling-probe.sh (opens in a new tab)scripts/commented-out-code.sh (opens in a new tab)scripts/detect-comments.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
bashThree short reads, in order
7 skills in this plugin
/audit-comment-residueAudit comment residueRead-only classifier: flags residue in code comments (history narration, plan or session references, conversational asides, ticket/PR back-references, origin notes, workarounds with no link or removal condition). No edits. Use when: 'audit code comments' or report chat/ticket comments on commit/review. Not for edits: /code-tidying:remove-comments./audit-dead-codeportability-ok: R6 kept-adapter operation - dead-code-scan.sh grep analyzerRead-only hunt for dead and unused code via 4 analyzers (Knip TS/JS, vulture Python, gopls Go, grep shell/C#/other), adjudicated dead, uncertain, or alive. Use when: 'find dead code', 'remove unused code', unused exports, functions, orphaned files, or if anything calls a symbol. Find-and-delete starts here; deleting is /code-tidying:tidy./batch-simplifyBatch simplifyWhen bundled simplify resolves in this session, prefer it when asked to clean up one file or path; this skill for batch sweeps. Runs simplification over a time window, branch, directory, or repository, grouped by ecosystem in dependency order. Use when: 'batch simplify', 'simplify recent changes', or catch up after a multi-session sprint.npx claudepluginhub melodic-software/claude-code-plugins --plugin code-tidyingOther plugins' skills for the same job