Skip to content
refactoring

Dead Code Finder

Find unused exports, orphan files, and unreferenced types across the codebase — safe-to-delete candidates ranked by confidence.

/dead-code

Install this skill

  1. 1. Copy the SKILL.md content (button above)
  2. 2. Create a folder for the skill:
    # Mac/Linux
    mkdir -p ~/.claude/skills/dead-code
    
    # Windows (PowerShell)
    mkdir $env:USERPROFILE\.claude\skills\dead-code
  3. 3. Save the content as ~/.claude/skills/dead-code/SKILL.md
  4. 4. Restart Claude Code (or open a new session)
  5. 5. Type /dead-code to invoke it
cleanuptree-shakingunused

/dead-code

Identify code that's safe to delete.

Usage

/dead-code # full scan /dead-code src/lib/ # scoped scan /dead-code --include-tests # include test files in usage analysis

What it detects

  • Exported functions / classes / constants with zero imports anywhere
  • Files never imported (orphan modules)
  • Dead branches (if (false), unreachable returns)
  • Unused props on React components
  • Unused dependencies in package.json
  • Unused TypeScript types and interfaces

Strategy

  1. Build an import graph of the project
  2. Mark entry points (build config, page routes, tests if --include-tests)
  3. Anything not reachable from an entry point = candidate

Output

src/lib/legacy/old-utils.ts (entire file unused — 412 lines) src/components/Header.tsx - export function trackHeaderClick (line 42, unused since 2024-08) src/types/api.ts - type LegacyResponse (line 17, unused) 📊 Total: 8 candidates · ~640 lines could be removed

Rules

  • Never auto-delete — present a list, let the user decide
  • Some "dead" code is intentional (re-exports, public API for libs)
  • Watch for dynamic imports — import(\./modules/${name}`)` defeats static analysis
  • Confidence levels: HIGH (purely internal), MEDIUM (could be external API), LOW (dynamic patterns nearby)