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
- Repository
- jeremylongshore/tons-of-skills-marketplace
- 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
- 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.
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.
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
- Detect unused exports — functions, classes, constants, and types exported but never imported elsewhere
- Find unused imports — import statements where the binding is never referenced in the file
- Identify unreachable code — statements after return, throw, break, continue, or inside dead branches
- Spot dead feature flags — conditional branches guarded by flags that are always true or false
- Flag unused variables and parameters — declared but never read
- 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 -100If 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:
- Is the symbol used via dynamic access (Object.keys, require(), reflection)?
- Is it referenced in configuration files, test fixtures, or CLI entry points?
- 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:
- Remove the dead code using Edit tool
- 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- If verification passes → confirmed removal, move to next
- 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
- Fairdb Automation Agent Automate FairDB PostgreSQL-as-a-Service operations — proactive monitoring, incident response, customer onboarding, backup verification, query optimization, and capacity planning with a human-escalation decision framework. Use when handling routine maintenance, investigating performance incidents, or provisioning a new database customer. Trigger with \"fairdb operations\", \"run health check\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Explore Explore blockchain transactions, addresses, and contracts Slash Command · jeremylongshore/tons-of-skills-marketplace
- Excel Analyst Pro Professional financial modeling toolkit for Claude Code with auto-invoked Skills and Excel MCP integration. Build DCF models, LBO analysis, variance reports, and pivot tables using natural language. Plugin · jeremylongshore/tons-of-skills-marketplace
- Fairdb Onboard Customer Complete customer onboarding workflow for FairDB PostgreSQL service Slash Command · jeremylongshore/tons-of-skills-marketplace
- Deal Builds the B2B pipeline, writes the sales playbook, drafts the pricing proposal, and designs the closing motion. Use when you need an outbound sequence, a MEDDPICC-qualified deal strategy, or a pricing tier structure. Trigger with \"build the sales playbook\", \"design pricing for this deal\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Database Designer Database schema design expert for SQL and NoSQL covering normalization, indexing strategies, migration patterns, and query optimization. Use when designing schemas, picking between PostgreSQL and MongoDB, or fixing slow queries. Trigger with \"database schema\", \"data model help\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Defensive Code Cleaner Scans TypeScript/JavaScript for unnecessary null checks, impossible try/catch blocks, redundant validation, and dead catch blocks — tracing data flow to prove each defense is unneeded before flagging. Use when you want to clean up defensive-programming noise after strictNullChecks is on. Trigger with \"find unnecessary null checks\", \"audit defensive code\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Data Generator Generates realistic, locale-aware test data (users, products, orders, custom schemas) using Faker.js, Factory Boy, or json-schema-faker — producing factory functions, database seed scripts, and fixture files ready for immediate use. Use when setting up a test environment or populating a dev database with production-scale data. Trigger with \"generate test data\", \"create seed data factories\". Subagent · jeremylongshore/tons-of-skills-marketplace