Agents / Skills

Dead Code Sweep

Skill

Finds and removes the code that no longer runs — the unreferenced functions, the unreachable branches, the feature nobody can trigger — with the proof of deadness per item, because deleting the wrong thing is how legends start.

Best for

  • Codebases where half the reading time is spent on code that never runs
  • After a feature removal that left its roots behind
  • Making the next refactor smaller by shrinking the codebase first

What you give it

  • The codebase, and honesty about dynamic entry points (jobs, reflection, external callers)

What you get back

  • The dead list with proof per item: why this is dead, by what evidence, at what confidence
  • The deletions staged by confidence: the certain batch, the probable batch behind a check, the suspicious batch left alone
  • The side-finds: the flag that is always on, the config nobody reads, the dependency only dead code used

How it works

  1. Hunts by multiple evidence types: reference analysis, export/import graphs, runtime usage where instrumentable, and change-history staleness as a hint (never as proof).
  2. Respects the dynamic frontier: reflection, dispatch tables, external callers and scheduled jobs are where static certainty ends — those get instrumentation, not assumption.
  3. Stages deletions by confidence with the suite green after each batch, in reviewable sizes, trivially revertible by design.
  4. Collects the cascade: code dead only because its caller died, dependencies and assets orphaned by the deletions.

Example

You: Sweep the codebase; we think a third of it is dead after two years of pivots.

Result: The sweep: 18% confirmed dead by reference analysis plus runtime evidence (the old export pipeline, two notification channels, 41 orphaned helpers) — deleted in reviewable batches, suite green after each; 6% probable-dead instrumented with usage logging for a month before judgement (two turned out alive via a cron job nobody documented — the honesty that saves weekends); plus the side-finds: four dependencies used only by deleted code (removed) and the feature flag on since 2023 (inlined). The codebase shrank 22%, and the next search results got that much more honest.

Limits — please read

  • Public API surfaces and library exports have invisible callers; they get deprecation paths, not sweeps.
  • The probable batch needs its observation window; impatience is how 'dead' code pages someone at month-end.
  • Deleted is recoverable from history; the sweep records what went where, so resurrection is a revert not a rewrite.