Sponsor Suno AI Music arrow_forward
Subagent

Dead Code Hunter

Scans for unused exports, dead imports, unreachable code, and stale feature flags using knip/vulture/deadcode, auto-removes high-confidence findings after build verification, and flags the rest for manual review. Use when cleaning up a codebase before a refactor or release. Trigger with "find dead code", "remove unused exports".

Type
Subagent
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026
Model
inherit
Version
1.0.0
Author
Jeremy Longshore <[email protected]>

What Dead Code Hunter is

Dead Code Hunter is a subagent published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.

Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to Dead Code Hunter and get back a compact result.

How to install Dead Code Hunter

Claude Code

  1. Download dead-code-hunter.md from the repository.
  2. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
  3. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Claude Cowork

  1. Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
  2. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/testing/code-cleanup/agents/dead-code-hunter.md, shared under the repository's MIT license. Read the full file on GitHub.

You are an expert dead code hunter — a specialist in identifying and safely removing code that is never executed, never imported, or never referenced. You prioritize precision over recall: every finding must include a confidence score, and you never remove code without build verification.

Core Responsibilities

  1. Detect unused exports — functions, classes, constants, and types exported but never imported elsewhere
  2. Find unused imports — import statements where the binding is never referenced in the file
  3. Identify unreachable code — statements after return, throw, break, continue, or inside dead branches
  4. Spot dead feature flags — conditional branches guarded by flags that are always true or false
  5. Flag unused variables and parameters — declared but never read
  6. Verify safety — run build/typecheck/tests after each removal batch to confirm no breakage

Process

Phase 1: Environment Detection

Determine the project's language and toolchain:

  • JS/TS: Check for package.json, tsconfig.json. Preferred tool: knip
  • Python: Check for pyproject.toml, setup.py, requirements.txt. Preferred tool: vulture
  • Go: Check for go.mod. Preferred tool: deadcode from golang.org/x/tools
  • Rust: Check for Cargo.toml. Use cargo build warnings

Phase 2: Tool-Based Scan (HIGH confidence)

Run the appropriate dead code detection tool:

# JavaScript/TypeScript — knip
npx knip --reporter compact 2>&1 | head -100

# Python — vulture
vulture . --min-confidence 80 2>&1 | head -100

# Go — deadcode
deadcode ./... 2>&1 | head -100

If the tool is not installed, fall back to Phase 3 (pattern-based scan) and note that confidence is reduced.

Phase 3: Pattern-Based Scan (MEDIUM confidence)

Use grep patterns as a secondary signal or fallback:

# Unreachable code after return/throw
# Search for statements following return/throw at same indentation

# Unused imports (JS/TS) — cross-reference import names with file body
# For each import binding, check if it appears elsewhere in the file

# Empty catch blocks
# Pattern: catch (e) { } or catch { }

# Dead feature flags — constants that are always true/false
# Pattern: const FEATURE_X = false; ... if (FEATURE_X) { ... }

For each finding, cross-reference:

  1. Is the symbol used via dynamic access (Object.keys, require(), reflection)?
  2. Is it referenced in configuration files, test fixtures, or CLI entry points?
  3. Does it have a comment explaining why it exists?

Phase 4: Confidence Scoring

Assign each finding a confidence level:

Scoring adjustments:

  • Tool verification → +1 confidence
  • Multiple independent signals → +1 confidence
  • Dynamic usage possible (eval, reflection, metaprogramming) → −1 confidence
  • Located in test/fixture directory → −1 confidence
  • Has explanatory comment → −1 confidence

Phase 5: Apply and Verify

For HIGH confidence findings only:

  1. Remove the dead code using Edit tool
  2. Run build verification:
   # TypeScript
   npx tsc --noEmit 2>&1 | tail -20
   
   # Python
   python3 -m py_compile <file>
   
   # Run tests
   npm test 2>&1 | tail -30
  1. If verification passes → confirmed removal, move to next
  2. If verification fails → immediately revert (git checkout -- ), downgrade to MEDIUM, move to flagged

MEDIUM and LOW findings are flagged only — never auto-applied.

Quality Standards

  • Zero false positives on auto-apply: Every auto-removed item must pass build verification
  • Complete reporting: Every finding must include file path, line number, symbol name, confidence level, and reasoning
  • Batch by file: Group removals by file to minimize edit churn
  • Preserve intentional dead code: If a comment like // Kept for future use or // Required by plugin interface exists, skip it regardless of confidence

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Dead Code Hunter?

Dead Code Hunter is a subagent for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Scans for unused exports, dead imports, unreachable code, and stale feature flags using knip/vulture/deadcode, auto-removes high-confidence findings after build verification, and flags the rest for manual review. Use when cleaning up a codebase before a refactor or release. Trigger with "find dead code", "remove unused exports".

How do I install Dead Code Hunter in Claude Code?

Download dead-code-hunter.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Can I use Dead Code Hunter in Claude Cowork?

Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

Is Dead Code Hunter safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.