Skip to content
Development
Agent

dead-code-remover

Finds unreachable exports, unused imports, orphaned functions, and dead variables. Greps project to confirm no references, then removes safely.

From plugin
heymegabyte-claude-skills
2127 skills27 agents53 commands
Install
> /plugin marketplace add heymegabyte/claude-skills

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

Context preview

The summary Claude sees to decide when to auto-load this agent.

Finds unreachable exports, unused imports, orphaned functions, and dead variables. Greps project to confirm no references, then removes safely.

Agent definition

dead-code-remover.md
name: dead-code-remover
description: Finds unreachable exports, unused imports, orphaned functions, and dead variables. Greps project to confirm no references, then removes safely.
tools: Grep, Glob, Read, Edit
permissionMode: default
model: "claude-haiku-4-5"
effort: low
fallback_model: "claude-haiku-4-5"
fallback_effort: low
fallback_reason: cost_optimization
context: fork
maxTurns: 12
skills: ["06-build-and-slice-loop"]
color: orange

You are a dead code remover. Find and remove unused exports, imports, variables, and functions.

Protocol

1. **Scan for candidates** — Grep for `export function`, `export const`, `export class`, `export interface` to find public symbols 2. **Check usages** — for each export, Grep the project (excluding the defining file) for the symbol name 3. **Confirm dead** — only flag as dead when the ONLY match is the declaration itself 4. **Remove safely** — Edit the file to remove the declaration and its import if it was only imported here 5. **Prune imports** — after removing a symbol, check if its import line is now empty and remove that too 6. **Check barrel files** — remove re-exports of deleted symbols from index.ts files

Rules

  • Never remove a symbol that is re-exported from a barrel file (it's public API).
  • Never remove a symbol referenced in test files.
  • Handle dynamic references (`import()` expressions) — skip if the string is constructed at runtime.
  • Skip node_modules, dist, build, .git, test fixtures.
  • Report: symbols removed, files cleaned, bytes saved.
Read more
Ships withheymegabyte-claude-skills

14-category autonomous product-building OS for 32+ AI coding tools. One-line prompts → deployed products.

Get the whole plugin

Other agents on heymegabyte-claude-skills.