agentleFS
MediaPluralMediaPlural/agent-proven/skills/dead-code-sweep/SKILL.md

dead-code-sweep

Skill1 starsChanged 12 days agoMITView on GitHub

Prove code unconsumed before deleting — and unnecessary.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Don't use for: features behind flags scheduled for enable, plugin/extension surfaces consumed externally (check the ecosystem, not just the …

    line 36
  2. Distinctive:

    Check the indirect consumption vectors: before trusting zero: string references (dynamic dispatch, DI registration, reflection), …

    line 47
  3. Very specific:

    Delete in one commit per tier-1 batch: Run the full suite before and after (verification-gates Gate 2).

    line 50
  4. Distinctive:

    Completion criterion: every deletion has its consumption proof recorded (zero references, or the necessity analysis).

    line 68

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Dead Code Sweep

Find and remove code nothing needs — in two escalating proofs. Most dead-code checks stop at "has zero references." Real cleanup starts there:

  1. Unconsumed — nothing references it (the easy proof).
  2. Unnecessary — it's referenced but shouldn't be: wrappers that only forward calls, compatibility APIs kept for history, defensive branches hiding impossible states, stale defaults, duplicate state sources, public surfaces nobody should depend on.

Adapts the used-vs-necessary distinction of danhuaxiansheng/claude-code-cleanup-skills (MIT) with this library's baseline gates: every deletion lands with the suite proven green before AND after.

When to Use

  • Post-refactor residue: old paths a migration left behind
  • "Is this module still needed?" — audits before big refactors
  • Wrappers/compat layers that only exist because other wrappers exist
  • Review comments: "nobody calls this anymore" — verify, then delete

Don't use for: features behind flags scheduled for enable, plugin/extension surfaces consumed externally (check the ecosystem, not just the repo), or anything exported by a public API contract (semver constraints).

Procedure

Tier 1 — Unconsumed:

  1. Enumerate candidates — exports, functions, files, components, types: search_files for each identifier; vulture/knip/language-native analyzers for breadth. Record every reference site.
  2. Check the indirect consumption vectors before trusting zero: string references (dynamic dispatch, DI registration, reflection), re-exports, test fixtures, codegen targets, scripts/CI files, documentation examples.
  3. Delete in one commit per tier-1 batch. Run the full suite before and after (verification-gates Gate 2). Lint the touched files.

Tier 2 — Unnecessary (referenced but hollow):

  1. Wrapper audit: a function that only forwards calls with no added value (no validation, no defaults, no logging, no naming) — inline it. One exception: intentional seams for testing or future dispatch.
  2. Compatibility audit: APIs kept "for history" with zero external consumers — delete with the changelog note, or file for a deprecation cycle if the repo is a library.
  3. Defensive-branch audit: branches guarding impossible states (post- validation re-validation, can't-happen type checks). Prove impossibility from the call graph before removing — if the proof needs a comment longer than the branch, keep the branch.
  4. Duplicate state: two sources claiming the same fact — one becomes canonical, the other derived or deleted.

Completion criterion: every deletion has its consumption proof recorded (zero references, or the necessity analysis); suite green before/after; nothing behind a public-API contract was touched without a deprecation note.

Pitfalls

  • Dynamic references are invisible to grep: string-keyed dispatch, reflection, DI containers, __getattr__, codegen. Search strings too.
  • "Referenced" ≠ "needed": tier 2 is where the real debt lives — but it's also where wrong deletions hurt. Prove necessity per finding, never batch-delete tier 2.
  • External consumers: plugins, extensions, downstream forks. A public export's reference count inside the repo proves nothing about the world.
  • Test-only consumers count as dead-adjacent: a function only tests exercise is a candidate for deletion WITH its tests — but only after confirming no production path was about to adopt it.

Verification

Runnable check: full suite before and after each deletion batch, plus a reference re-scan of the deleted identifiers:

search_files --pattern '<deleted-identifier>' . # expect: zero non-history hits

Expected: suite green both sides; re-scan returns zero live references (git history/changelog hits don't count).

Evidence to capture: per-batch before/after suite outputs, the consumption proofs, and the post-delete re-scan.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.