Dead code cleaner
Skill owen-dev-6174/bodhisattva-skills/skills/dead-code-cleaner
Use when finishing a task, after completing edits, or when code feels cluttered with unused imports, unreferenced functions, commented-out blocks, orphaned files, or duplicate utilities. Reduces the 41% code churn rate caused by AI agents leaving obsolete artifacts behind.From its SKILL.md
npx -y skills add owen-dev-6174/bodhisattva-skills --skill dead-code-cleanerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.9 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Dead Code Cleaner: If It Serves No Purpose, It Must Go
AI agents leave debris. Unused imports, orphaned functions, commented-out blocks, duplicate utilities -- dead code that inflates churn to 41%. This skill runs a cleanup pass after every task.
The Iron Law
Code that serves no purpose is not neutral -- it is a lie that the next reader must investigate.
Every dead line forces the next developer to ask: "Is this important? Is it used somewhere I can't see? Was it left here intentionally?" That wasted investigation multiplies across every future reader.
The Process
Step 1 -- Scan for the Five Categories
After completing a task, sweep all modified and newly created files for:
- Unused imports -- Modules imported but never referenced in the file
- Unreferenced functions/variables -- Declared but never called or accessed
- Commented-out code -- Not comments explaining why, but old code preserved "just in case"
- Orphaned files -- Files created during development (scratch files, old versions, temp utilities) that are not imported or referenced anywhere
- Duplicate utilities -- Functions that do the same thing as an existing utility, often created because the agent did not discover the original
Step 2 -- Verify Before Removing
For each candidate, confirm it is truly dead:
- Unused imports: Search the file for any reference to the imported name. Check for side-effect imports (CSS modules, polyfills, init scripts) that are intentionally reference-free.
- Unreferenced functions: Search the entire project, not just the current file. Check for dynamic references (
getattr, bracket notation, reflection). Check for exports consumed elsewhere. - Commented-out code: Distinguish code from documentation.
// Calculate the hash using SHA-256is a comment.// const result = oldApi.fetch(url)is dead code. - Orphaned files: Verify no imports, requires, or references point to the file. Check build configs, test configs, and scripts.
- Duplicates: Confirm identical behavior before removing. Keep the version with better naming, tests, or documentation. Update all callers to use the surviving version.
Step 3 -- Remove With Precision
- Remove one category at a time. Verify the build and tests still pass after each category.
- Do NOT remove code that is outside the scope of your current task unless it was created or modified as part of this task.
- If unsure whether something is dead, leave it and flag it for the user.
Step 4 -- Report What Was Cleaned
After cleanup, summarize:
- What was removed and why
- What was flagged as suspicious but left (with reasoning)
- Any duplicates found that may warrant consolidation in a future task
Red Flags -- Common Dead Code Patterns
| Pattern | Category |
|---|---|
import { helper } from './utils' but helper never appears below | Unused import |
function oldHandler() { ... } with zero call sites | Unreferenced function |
// const config = loadLegacyConfig() | Commented-out code |
temp_solution.ts or utils_backup.js in project | Orphaned file |
formatDate() in helpers.ts AND formatDateString() in utils.ts doing the same thing | Duplicate utility |
TODO: remove after migration still present months later | Stale dead code |
| Variable assigned but never read | Unreferenced variable |
Entire else branch that returns the same value as the if branch | Redundant logic |
Flowchart
digraph dead_code_cleaner {
rankdir=TB
node [shape=box style=rounded]
done [label="Task completed"]
scan [label="Step 1: Scan modified/created files\nfor 5 dead code categories"]
found [label="Dead code\ncandidates found?" shape=diamond]
verify [label="Step 2: Verify each candidate\nis truly dead\n(search project-wide)"]
confirmed [label="Confirmed dead?" shape=diamond]
flag [label="Flag as suspicious\nfor user review"]
remove [label="Step 3: Remove one\ncategory at a time"]
test [label="Build + tests\nstill pass?" shape=diamond]
revert [label="Revert removal.\nFlag for user."]
more [label="More categories\nto clean?" shape=diamond]
report [label="Step 4: Report\nwhat was cleaned\nand what was flagged"]
finish [label="Present clean work"]
done -> scan
scan -> found
found -> finish [label="None"]
found -> verify [label="Yes"]
verify -> confirmed
confirmed -> remove [label="Yes"]
confirmed -> flag [label="Unsure"]
remove -> test
test -> more [label="Yes"]
test -> revert [label="No"]
revert -> more
more -> verify [label="Yes"]
more -> report [label="No"]
flag -> more
report -> finish
}
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.
Gives 0 of the 12 instructions most refactoring skills give in ~1.1k tokens
Counted across 521 of the 525 authors here whose files we hold, read 2026-08-07
- Run tests after each changein 52 of 521
- Run the full test suite after each stepin 32 of 521
- Preserve external behaviorin 27 of 521, across 24 files
- Remove dead codein 26 of 521
- Write tests before refactoringin 26 of 521, across 25 files
- Make small incremental changesin 19 of 521, across 16 files
- Break the implementation into tiny commitsin 18 of 521, across 5 files
- Ask the user about alternative optionsin 17 of 521, across 4 files
- Create a GitHub issue with the planin 17 of 521, across 4 files
- Explore the repository to verify assertionsin 17 of 521, across 4 files
- Interview the user about the refactorin 16 of 521, across 3 files
- Check the codebase for test coveragein 16 of 521, across 3 files
Said here and by no other author read
- Scan modified files for five dead code categories
- Search the entire project to verify unreferenced functions
- Distinguish commented-out code from explanatory comments
- Verify orphaned files have no references
- Remove dead code one category at a time
- Keep the duplicate utility with better tests
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.