/code-tidying:audit-dead-code [--max N] [--analyzer knip|vulture|gopls|grep] [target] [--repo <repo> ...]from code-tidying
Hunts dead and unused code across TS/JS, Python, Go, shell, C#, and other languages using Knip, Vulture, gopls, and grep analyzers. Adjudicates candidates as dead, uncertain, or alive for actionable cleanup.
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.
Find code nothing has touched in a long time, which a rotated tidying focus area and a diff-scoped simplification pass cannot see, and answer what here is no longer reachable, and how confident are we? Every candidate is adjudicated against the dynamic-usage patterns static analyzers miss, so the report is a list of decisions a human can act on, not an analyzer dump to re-verify.
Present them as four analyzers of unequal strength, each labeled. A report that treats them as equals is wrong even when every finding in it is right.
| Analyzer | Covers | Measured character | How it fails |
|---|---|---|---|
| knip | TS/JS: unused files, exports, types, enum members. Not class members (Knip 6 rejects --include classMembers) | 60% precision / 100% recall on trap fixtures | Unrestored, it manufactures false positives (a failed config load produced 2 phantom "unused files"); its ERROR: line goes to stderr, which the JSON reporter discards |
| vulture | Python: unused function, class, method, variable, attribute, plus unreachable code | 16.7% precision / 100% recall; all five trap classes false-positived at 100% | Low precision by construction. Its output is a worklist, never a verdict |
| gopls | Go: unexported symbols only (gopls check -severity=hint), the analyzer's declared coverage | Correct on every measured symbol; 2.1s | An unresolved module graph suppresses hints: false negatives, the opposite of knip. Never describe the two degradations with one phrase |
| grep | Shell and PowerShell functions; function/class/const/let/var declarations in JS/TS no package.json root owns (ts-unreferenced-symbol); C# type declarations and members with an access modifier, read as text and never built (cs-unreferenced-private, cs-unreferenced-symbol); unreferenced source files (unreferenced-file) | Shell symbols: 4/4 true positives, 0 false over 546 .sh files (shellcheck found 0 of the 4). JS/TS symbols: 75% precision / 100% recall (derived 2026-11-28 from the candidate set the scan test asserts, not a separate scan). C# private: 66.7% / 66.7%; other C#: 33.3% / 100% (2026-10-29). unreferenced-file precision unmeasured | Low recall: $, -, . are non-word characters, so an adjacent hit reads as a reference and saves a possibly dead symbol. A JS/TS export only an entry point or outside consumer calls is a false candidate; a name in a comment saves a dead one. A C# member reached by a computed reflection name, assembly scanning or a serializer is a false candidate |
Every figure comes from this plugin's trap fixtures under evals/fixtures/, as recorded on
2026-08-23 (JS/TS symbol figures derived 2026-11-28 from scripts/dead-code-scan.test.sh's asserted candidates, C# figures 2026-10-29). Recheck trigger: a major
version bump in any analyzer's detector, or a change to the fixture corpus. Re-measure before quoting
one to a user.
Orphaned files. The grep analyzer emits unreferenced-file (tier 2) for a source file no other
tracked file names, C# and languages with no analyzer (Rust, F# and VB among them) included. A reference in a CI
workflow, settings file, manifest or doc saves the file; a computed path or glob does not, so the
candidate is uncertain, not dead. Its input set, the no-analyzer extension list, per-analyzer
invocation, coverage accounting and degradation detail: context/analyzers.md
"Analyzer reference".
The detector emits candidates, not verdicts. A shape's tier is its prior, taken from the measured precision of the analyzer that produced it.
| Shape | Analyzer | Default tier |
|---|---|---|
ts-unused-file | knip | 2 |
ts-unused-export | knip | 2 |
ts-unused-type | knip | 2 |
ts-unused-enum-member | knip | 2 |
py-unused-symbol | vulture | 2 |
py-unreachable | vulture | 1 |
go-unused-unexported | gopls | 1 |
unreferenced-symbol | grep | 1 |
ts-unreferenced-symbol | grep | 2 |
cs-unreferenced-private | grep | 2 |
cs-unreferenced-symbol | grep | 2 |
unreferenced-file | grep | 2 |
detector-drift | any | 3 |
ts-unreferenced-symbol is tier 2, unlike the shell unreferenced-symbol, because its derived
precision is 3 of 4 and an entry point or public export nothing in the repository calls reads as
unreferenced. Both C# shapes are tier 2 because each yields a false dead on the trap fixtures.
A consumer's own CLAUDE.md or rules may refine these defaults.
${CLAUDE_SKILL_DIR}/scripts/dead-code-scan.sh # whole repo, every analyzer
${CLAUDE_SKILL_DIR}/scripts/dead-code-scan.sh --max 20 # cap the adjudication set
${CLAUDE_SKILL_DIR}/scripts/dead-code-scan.sh --analyzer grep src/ # one analyzer, scoped candidates
${CLAUDE_SKILL_DIR}/scripts/dead-code-scan.sh --root <root> # another repository's root (--repo alias)
${CLAUDE_SKILL_DIR}/scripts/dead-code-scan.sh --json # structured JSON output
${CLAUDE_SKILL_DIR}/scripts/dead-code-scan.sh --unattended --json # read-only unattended run (skips knip so no repo JS/TS config executes)
${CLAUDE_SKILL_DIR}/scripts/dead-code-scan.sh --help # usage and exit codes
Exit is 0 on every scan path and 2 only on a usage error; no detector's exit code is propagated.
Present the Analyzer: lines with the findings: they make a clean report a claim rather than an
absence. A target narrows which files produce candidates; the reference search stays
repository-wide, because a reference from anywhere saves a symbol.
With no target form, the scan 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 before reading --max, --analyzer and target. What differs here:
dead-code-scan.sh --root <root> with the run's --max, --analyzer and target, so the
reference search stays inside that repository: a reference in one repository never saves a
symbol in another. A target resolves under each root; a repository where it does not exist is
reported skipped. --max caps each repository's candidates.origin/HEAD without a worktree, which
would be a write. So 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
scanned as it stands, and the report says so for that repository.Summary candidates: line and the total, and
take one go-ahead before any repository is adjudicated.| State | Meaning |
|---|---|
ran | the analyzer resolved a binary, invoked it, and read trustworthy output |
skipped | no resolvable local binary, or a located binary that failed to invoke. Nothing was fetched; no package runner is ever called |
degraded | the analyzer ran but its output is not trustworthy. It emits no records, its line says why, and its files are uncovered (analyzer degraded) |
scanned-zero-files | the analyzer had zero in-scope input files it owns (a nested project root's files belong to that root). Indistinguishable from clean in the detectors' own output |
no-manifest | the analyzer's language is in scope but no manifest root exists (package.json for knip, go.mod for gopls). Those files are uncovered unless another analyzer took them (grep takes JS/TS no package.json root owns). Not a missing binary |
files= on an Analyzer: line is the number of files that analyzer took as input, including skipped and
no-manifest; it is not the number of findings.
A run where no analyzer reached ran and no source file is uncovered is a scan of nothing, not a
clean bill, and the script says so. A run that leaves any in-scope source file uncovered, even
with some analyzer ran, is not a clean bill either: the clean-result note prints only when
Summary coverage: reports uncovered=0.
Bounded by design. Evidence catalogue: context/adjudication.md "Evidence patterns".
--max cap from Summary candidates: and
get a go-ahead before adjudicating. Never quote a time or token estimate; there is no
measurement behind one. Done when the operator has explicitly approved adjudication or declined it
(report-only).dead, uncertain, or alive against the dynamic-usage
patterns detectors cannot see: string-name dispatch, DI and serialization, reflection, decorator
and route registration, test-only entry points, public API surface, generated code. An
unreferenced-file a computed path or glob could load is uncertain, not dead.alive cites the evidence that saved it. An unevidenced alive is a guess.LSP tool is
available, findReferences on one candidate is one more evidence source. Read what it returns
in LSP tool behavior
before reading a count as dead. Done when every emitted candidate has a dead, uncertain or
alive verdict with evidence, or the cap stopped the batch and the report says so.Edit, no Write, no mutating Bash, and no file written, not
even a findings file; every deletion is the human's. Detectors run only from a resolvable local
binary (PATH, the repo-local node_modules/.bin walk, or .venv/bin) or the analyzer is skipped;
the script invokes no package runner. The one exception is installing or fetching a detector,
only through "When coverage is incomplete" step 3, after an explicit yes.dead → T1 and uncertain →
T2. alive is never emitted as a record: it is a saved candidate, and emitting it would make
Summary total: mean two things.command -v rust-analyzer succeeds while invocation fails).**/fixtures/**, **/__fixtures__/**, and **/testdata/** (including **/evals/fixtures/**) are never scanning input: a test or detector fixture corpus is not the consumer's dead code.A skipped, degraded, no-manifest or scanned-zero-files analyzer, or source files with no analyzer,
are gaps, not a clean bill. After presenting the analyzer roster:
Summary coverage: and each Note: uncovered line: the path and the
reason (no analyzer for the language, no manifest root, tool not installed, analyzer degraded,
tool could not parse it, or analyzer not selected). Rust, F# and VB are a policy exclusion (no analyzer for the language), not a forgotten detector. C# gets the grep analyzer's text-only pass, never
a build./discovery:research (if enabled) to pick a detector for
the language, show the choice and its install command, and install or invoke it only after an
explicit yes. Record its precision as unmeasured until trap fixtures cover it.Consent-gated analyzers that may compile or execute project code remain out of scope.
The script emits flat records; the adjudicated report is what the human reads.
Analyzer: knip | root=. | state=ran | files=19 | detail=19 candidate(s); 269 finding(s) this root does not own dropped ...
Note: knip evaluated knip.config.ts through jiti — a DISCLOSED exception ...
File: src/legacy/format.ts
Finding tier: 2
Finding shape: ts-unused-export
Finding line: 13
Finding excerpt: formatLegacyRow
---
Summary file: src/legacy/format.ts | T1=0 T2=1 T3=0
Summary analyzers: ran=3 skipped=1 degraded=0 scanned-zero-files=2 no-manifest=0
Summary coverage: covered=19 uncovered=2
Summary candidates: total=370 emitted=15 dropped-by-cap=355 cap=15
Summary total: files-with-findings=15 T1=0 T2=15 T3=0
Note: uncovered cmd/tool/main.go — no manifest root
Note: uncovered src/main.rs — no analyzer for the language
files-with-findings= counts files that emitted at least one candidate. Summary coverage:
counts every in-scope source file as covered by an analyzer in ran, or uncovered with one of the
reasons above; markdown, JSON, YAML and other non-source files are not in it. The grep analyzer covers
files with no symbol analyzer, so no analyzer for the language remains only when that analyzer is not
selected.
Present per file: verdict, shape, line, the evidence checked, and for alive what saved it. Close
with the analyzer roster, the candidate count against the cap, and n dropped by cap.
The skill writes nothing, so the memory lives in the repository: adjudicate a bounded batch, hand
the operator suppression entries for each detector's native config (Knip ignore entries, a
vulture whitelist; formats in context/adjudication.md "Suppression
formats"), and the next run reaches new code. Each step is done when the operator has the batch's
verdicts and suppression text, has declined them, or the batch is explicitly deferred; the loop ends when a follow-up scan is
scheduled or the operator stops after one batch.
Only knip and vulture converge. Go and the grep analyzer get no suppression directive: those
verdicts live in the report and in a comment at the declaration, and the same candidates return.
Say so rather than emitting a directive. The probe behind the Go half is in
context/adjudication.md "Suppression formats"; //lint:ignore belongs
to staticcheck, per
Ignoring problems with linter directives.
dead and uncertain verdicts are session-scoped: an un-suppressed uncertain returns next run.
A committed vulture whitelist raises F821 under a consumer's ruff config; say so when you emit
one.
/code-tidying:tidy applies Beck's Dead Code tidying inside one rotated focus area; this hunts the
whole repository and reports./code-tidying:batch-simplify sweeps recently changed files; this targets the long-untouched
ones a recency window excludes./code-tidying:remove-comments audit./code-tidying:tidy
Adjudicated dead verdicts are applied there. This skill only reports.
package.json means knip scans no .js/.mjs/.cjs. Its analyzer is no-manifest with
the real file count, and the grep analyzer takes those files, and any JS/TS outside every
package.json root, for ts-unreferenced-symbol and unreferenced-file. A symbol used only
inside its own file counts as referenced.degraded analyzer is not a quiet analyzer. knip degraded means invented findings were withheld;
gopls degraded means real findings were never produced. Report which. Either way its files are
listed uncovered, so the clean-result note cannot print.$, -, or . needs inspection; it is never an automatic alive.package.json root, and each root reports only the files it owns, so one
degraded workspace neither condemns the others nor has its withheld findings re-manufactured by an
outer root's run.*.py. A parse error on another file is an input note, not a
degraded analyzer.--max counts candidates, not files, so a cap can truncate a file's block: Summary file:
reflects what was emitted, not what exists.context/adjudication.md (opens in a new tab)context/analyzers.md (opens in a new tab)evals/evals.json (opens in a new tab)evals/fixtures/OrderCounter.razor (opens in a new tab)evals/fixtures/OrderCounter.razor.cs (opens in a new tab)evals/fixtures/OrderPage.razor (opens in a new tab)evals/fixtures/cs-orders.cs (opens in a new tab)evals/fixtures/cs-program.cs (opens in a new tab)evals/fixtures/dead-and-dynamic.go (opens in a new tab)evals/fixtures/dead-and-dynamic.py (opens in a new tab)evals/fixtures/dead-and-dynamic.sh (opens in a new tab)evals/fixtures/dead-and-dynamic.ts (opens in a new tab)evals/fixtures/gopls-hints.txt (opens in a new tab)evals/fixtures/knip-degraded.stderr.txt (opens in a new tab)evals/fixtures/knip-report.json (opens in a new tab)evals/fixtures/py-entry.py (opens in a new tab)evals/fixtures/scan-uncovered-java.txt (opens in a new tab)evals/fixtures/standalone.mjs (opens in a new tab)evals/fixtures/ts-entry.ts (opens in a new tab)evals/fixtures/ts-orphan.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub melodic-software/claude-code-plugins --plugin code-tidying7 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./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./remove-commentsRemove commentsEdits code so comments earn their keep (none/strip, necessary/aggressive, explanatory; safe mode, edit-free report): deletes zero-info comments, renames/restructures explanatory ones, keeps load-bearing ones. Use when: 'remove comments', 'dissolve comments', or trim agent comments. Not for read-only flagging: /code-tidying:audit-comment-residue./setupCheck (default, read-only) or apply repo code-tidying config: focus areas, HARD-exclusion overrides, comment-lint git hooks, and CI lint step./tidyWhen bundled simplify resolves in this session, prefer it for the current diff; this skill for proactive focus area hunts. Hunts one rotated focus area for Beck tidyings and ships one structure-only PR. Use when: 'tidy up', 'boy scout', or 'small refactors'. Not for current diff (/simplify) or diff windows (/code-tidying:batch-simplify)./tidy-diffTidy diffTidies a change's file-and-line list before commit: simplify, comment deletions, generated-code residue; docs-hygiene/ai-slop on markdown. Runs on detached HEAD/unattended lanes without base ref. Use when: 'tidy my change before the commit', 'tidy these lines', 'tidy-diff'. Not for /code-tidying:tidy or /code-tidying:batch-simplify.Other plugins' skills for the same job