dead-code-detector

A code scan that finds parts of a project that are not used, such as imports, functions, variables, styles, and dependencies.

In plain words
What is it for?
Use it to find unreachable code, unused packages, unused exports, circular dependencies, and items that need review before removal.
Why use it?
It helps reduce clutter and avoid removing code that may still be used indirectly, in tests, or by other projects.

Skill for Claude CodeCodex

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 skills/curiouslearner/devkit/dead-code-detector
Any agent
npx skills add CuriousLearner/devkit --skill dead-code-detector
Clone the repo
git clone --depth 1 https://github.com/CuriousLearner/devkit

Made for: Claude Code, Codex.

Per session 19 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,480 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.00019 $0.01480
Opus 5 $0.00010 $0.00740
Sonnet 5 $0.00004 $0.00296
Haiku 4.5 $0.00002 $0.00148

Measured yesterday against content hash 30ee307db490, 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-detector 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 yesterday.

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.

skills/dead-code-detector/SKILL.md · 254 lines

How it starts

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

Dead Code Detector Skill

Identify unused code, imports, variables, and functions for safe removal.

Instructions

You are a dead code detection expert. When invoked:

  1. Scan for Unused Code:

    • Unused imports and dependencies
    • Unreferenced functions and methods
    • Unused variables and parameters
    • Unreachable code paths
    • Commented-out code blocks
    • Deprecated functions still in codebase
    • Unused CSS classes and styles
    • Unused type definitions
  2. Analyze Dependencies:

    • Installed packages not imported anywhere
    • Dev dependencies used in production
    • Production dependencies only used in dev/test
    • Circular dependencies
  3. Check Code Reachability:

    • Functions never called
    • Code after return statements
    • Impossible conditional branches
    • Unused exports in modules
  4. Generate Report: Categorize findings:

    • Safe to Remove: Definitely unused
    • Potentially Unused: Might be used dynamically or in tests
    • Review Required: Exported but not used internally (might be used externally)

Detection Categories

Unused Imports

// Unused
import { foo, bar } from 'module'; // bar is never used

// Recommended
import { foo } from 'module';

Unused Variables

// Unused
const result = calculate();
const unused = 42; // Never referenced

// Dead assignment
let value = 10;
value = 20; // First assignment is dead

Unreachable Code

function example() {
  return true;
  console.log('Never executes'); // Dead code
}

if (false) {
  // Dead code block
}

Unused Functions

// Private function never called
function helperFunction() {
  // ...
}

// Exported but not used anywhere
export function unusedExport() {
  // ...
}

Usage Examples

@dead-code-detector
@dead-code-detector src/
@dead-code-detector --include-tests
@dead-code-detector --aggressive
@dead-code-detector --safe-only

Report Format

# Dead Code Detection Report

## Summary
- Total unused items: 47
- Safe to remove: 32
- Needs review: 15
- Potential savings: ~1,200 lines

## Safe to Remove (32)

### Unused Imports (12)
- src/utils/helpers.js:3
  `import { oldFunction } from './legacy'`

- src/components/Button.jsx:5
  `import { validateProps } from './validation'`

### Unused Variables (8)
- src/services/api.js:23
  `const DEBUG_MODE = false` (never referenced)

### Unreachable Code (5)
- src/handlers/payment.js:67
  Code after return statement (lines 68-72)

### Unused Functions (7)
- src/utils/format.js:45
  `function formatOldDate()` (never called)

## Needs Review (15)

### Exported but Not Used Internally (10)
- src/api/client.js:89
  `export function legacyRequest()`
  ⚠ Public export, might be used by consumers

### Potentially Dynamic Usage (5)
- src/plugins/loader.js:34
  `function loadPlugin()`
  ⚠ Might be called dynamically via string reference

## Dependencies

### Unused npm Packages (5)
- `moment` (use date-fns instead)
- `lodash.debounce` (using native debounce now)
- `axios` (switched to fetch)

### Misclassified Dependencies (2)
- `typescript` in dependencies (should be devDependency)
- `jest` in devDependencies but used in production scripts

## Commented Code (8 blocks)

- src/legacy/auth.js:120-145 (25 lines commented)
- src/components/Modal.jsx:67-82 (15 lines commented)

## Recommendations

1. **Immediate Actions**:
   - Remove 32 safe-to-remove items
   - Delete commented code blocks
   - Uninstall 5 unused packages

2. **Review Required**:
   - Check 10 exported functions with consumers
   - Verify 5 potentially dynamic references

3. **Estimated Impact**:
   - Bundle size reduction: ~45KB
   - Code reduction: ~1,200 lines
   - Dependency reduction: 5 packages

Read the full file on GitHub · 254 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. yesterday First seen · 254 lines · 19 tokens per session scan A 30ee307db490

Subscribe to this mod's changes

dead-code-detector is a skill published in the GitHub repository CuriousLearner/devkit (27 stars, last pushed 10mo ago), licensed MIT. It adds 19 tokens to every session and 1,480 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-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens