dead-code-clean

A command that finds and removes unused code, unnecessary imports, duplicate code, and leftover code from a project. It changes files directly and verifies each cleanup phase with a build and tests.

In plain words
What is it for?
Use it to actively clean a codebase after selecting a target and confidence level, with extra care for uncommitted work and uncertain findings.
Why use it?
It removes confirmed clutter while checking that the project still builds and its tests still pass.

Command

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.

agentmods
npx agentmods add commands/mathisk2095/jko-claude-plugins/dead-code-clean
Clone the repo
git clone --depth 1 https://github.com/mathisk2095/jko-claude-plugins
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,447 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00016 $0.01447
Opus 5 $0.00008 $0.00724
Sonnet 5 $0.00003 $0.00289
Haiku 4.5 $0.00002 $0.00145

Measured 2d ago against content hash 526716059a41, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dead-code-clean 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 2d 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.

plugins/dead-code/commands/dead-code-clean.md · 163 lines

How it starts

The opening of the file, as written. The whole thing — 163 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Dead Code Clean

Actively find and remove dead code from the target. Makes changes directly. Defaults to 'high' confidence mode.

CRITICAL: This command modifies files. Ensure the working tree is clean before starting. Each phase is verified with build + tests before proceeding to the next.

First: Use the dead-code-expert skill for the full detection catalog, false-positive awareness, and safe removal strategies.

Preparation

  1. Detect project language from config files.
  2. Determine the target and confidence mode ($2 or default 'high').
  3. Ensure the working tree is clean:
git status --porcelain | head -5

If dirty, warn the user but proceed if they confirm.

Phase 1: Certain Dead Code (always remove)

1a. Unused Imports

Run the language-appropriate tool and fix:

Python:

ruff check --select F401 --fix

JS/TS: Read each file, identify imports not referenced in the file body, remove them with Edit.

Rust: Run cargo clippy and fix unused import warnings.

Go: Already a compile error -- nothing to do.

1b. Unused Local Variables

Python:

ruff check --select F841 --fix

Other languages: Read flagged files from linter output and remove unused variables with Edit.

1c. Debug Artifacts

Find and remove in production code (not tests):

rg -n '(console\.log|print\(|dbg!\(|println!\(|debugger|breakpoint\(\))' . --glob '!*test*' --glob '!*spec*' --glob '!node_modules*' --glob '!target*'

Remove each artifact. Replace println!/print() with structured logging if the project uses a logging framework.

1d. Unreachable Code

Find code after return/break/throw and remove it.

1e. Commented-Out Code

Find blocks of commented-out code:

rg -n '^\s*(//|#)\s*(const|let|var|function|class|import|from|if|for|while|return|def |fn |pub )\b' . --glob '!*test*' --glob '!node_modules*' --glob '!target*'

Read context around each match. If it's genuinely commented-out code (not documentation), delete it. Version control has the history.

Read the full file on GitHub · 163 lines

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. 2d ago First seen · 163 lines · 16 tokens per session scan A 526716059a41

Subscribe to this mod's changes

dead-code-clean is a command published in the GitHub repository mathisk2095/jko-claude-plugins (3 stars, last pushed 4d ago), licensed MIT. It adds 16 tokens to every session and 1,447 once invoked, about $0.0001 per session on Opus 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-08-31.