find-dead-code
Skill1 starsChanged 7 months agoMITView on GitHub
Locate unused code with confidence tiers — definitely dead, probably dead, risky to touch. Uses static analysis (knip, ts-prune, ruff, deadcode) plus reflection-aware heuristics for things tools miss (DI, JSON config, dynamic imports). Use during periodic cleanup, before a refactor, or when onboarding to figure out what's still load-bearing.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- AlexisBalayre/claude-code-configtheir own version, first seen Oct 5, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- AlexisBalayre/claude-code-config★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository50 other files it gives its agents.
- algolia-searchSkill
- audit-tautological-testsSkill
- blame-archaeologySkill
- brevo-emailSkill
- bun-runtimeSkill
- clerk-authSkill
- cloudflare-workersSkill
- dbt-data-modelingSkill
- explain-this-diffSkill
- extract-skill-from-sessionSkill
- fastapi-productionSkill
- find-real-bugSkill
- gdpr-dpiaSkill
- github-actions-ciSkill
- graphql-relaySkill
- grpc-servicesSkill
- hipaa-auditSkill
- india-dpdp-actSkill
- java-8-to-21Skill
- jest-to-vitestSkill
- kubernetes-helmSkill
- mongo-to-postgresSkill
- nextjs-pages-to-appSkill
- node-version-upgradeSkill
- opentelemetry-instrumentSkill
- pci-dss-checklistSkill
- plan-the-rollbackSkill
- python-2-to-3Skill
- razorpay-integrationSkill
- react-native-expoSkill
- scaffold-cli-toolSkill
- scaffold-fullstack-appSkill
- scaffold-go-microserviceSkill
- scaffold-new-appSkill
- scaffold-saas-starterSkill
- sentry-monitoringSkill
- shrink-this-prSkill
- soc2-evidenceSkill
- spec-from-conversationSkill
- stripe-integrationSkill
- supabase-backendSkill
- terraform-patternsSkill
- threat-modeling-strideSkill
- triage-stack-traceSkill
- wcag-accessibility-auditSkill
- webpack-to-viteSkill
- write-adrSkill
- write-commit-messageSkill
- write-pr-descriptionSkill
- write-runbookSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Before a major refactor — know what you can safely remove.
- Distinctive: line 70
If grep finds zero references and the file isn't an entry point, it's tier 1.
- Distinctive: line 124
Don't delete 50 things in one PR.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Find Dead Code
Dead code is the silent tax — slow tests, larger bundles, mental load, security surface. But "delete it" is risky: code that looks dead can be reflected, dynamically imported, called via DI, or referenced from JSON config. This skill is the methodology for high-confidence deletion.
When to use
- Periodic cleanup (quarterly).
- Before a major refactor — know what you can safely remove.
- Onboarding a new engineer — show them what's still alive.
- Bundle size investigation — find what's shipping that nobody uses.
- Security audit — fewer code paths is fewer attack surfaces.
When NOT to use
- During active feature development — defer until things stabilize.
- In test code — dead tests are a different audit (see
audit-tautological-tests). - Highly dynamic codebases (heavy plugin systems, Ruby on Rails magic) — false positives dominate; manual review only.
Three confidence tiers
| Tier | Definition | Action |
| Definitely dead | Static analyzer says unused; no string match in repo; not exported from package. | Delete. Open PR. |
| Probably dead | Static analyzer says unused, but might be referenced by reflection, DI, JSON, dynamic imports. | Comment out + smoke test + delete next sprint if no break. |
| Risky | Old code with no recent changes, but maybe still called from a rarely-run path. | Add deprecation log + observe metrics + delete after a release window. |
Tier 1: definitely dead
Static analyzers find these:
| Language | Tool | What it finds |
| JS/TS | knip | unused files, exports, dependencies, devDeps, types |
| TS | ts-prune | unused exports |
| Python | vulture, ruff (F401, F841) | unused imports, unused variables, unused functions |
| Go | staticcheck, unused | unused functions, unused fields, unreachable code |
| Rust | cargo-machete, cargo udeps | unused deps |
| Java | IntelliJ inspections, error-prone | unused methods, unused params |
# JS/TS — the killer
pnpm dlx knipUnused files (3):
src/legacy/old-importer.ts
src/utils/deprecated-formatter.ts
src/components/UnusedModal.tsx
Unused exports (12):
src/api/client.ts: unusedHelper, anotherOne
...
Unused dependencies (2):
lodash (replaced by built-ins)
moment (replaced by date-fns)For each finding, verify with grep:
grep -r "deprecated-formatter" --exclude-dir=node_modules .If grep finds zero references and the file isn't an entry point, it's tier 1. Delete.
Tier 2: probably dead
Things static analyzers miss:
- DI containers —
register('userService', UserService). The string registration looks "unreferenced" to the analyzer but is invoked at runtime. - JSON config refs — webpack/Vite plugin lists,
package.jsonscript targets,tsconfig.jsonpaths. - Dynamic imports —
import(\./plugins/${name}`)`. Static analysis can't follow. - Reflection — Spring
@Component, Angular@Injectable, Pythongetattr, JSobj[methodName](). - Test fixtures referenced by name —
loadFixture("user-with-three-orgs"). - Public API surface — exported from a published package; consumers you don't see.
- CLI commands — registered as a subcommand by string name.
- Event handlers — subscribed via name.
For these, the safe sequence:
- Search broadly — grep for the name across the repo, with case-insensitivity:
grep -ri "deprecatedFormatter" --include="*.ts" --include="*.json" --include="*.yaml" . - Search outside the repo — published package? Check downstream consumers; npm
package-locks; internal monorepos. - Comment-out, don't delete — leave the code in but commented; deploy. Wait a week (or a release cycle).
- Watch logs — if an alert fires, you found a hidden caller. Restore.
- If silent, delete — confidence is now high.
Tier 3: risky
Old code paths that are probably dead but were once live. Examples:
- An admin endpoint used once a quarter for a manual data fix.
- A migration helper for a long-finished migration.
- A fallback for an old client version.
For these, add observability before deletion:
// Tier 3: probably dead but unsure
export function legacyExportV1(req, res) {
log.warn("legacyExportV1 called", {
user: req.user?.id,
userAgent: req.headers["user-agent"],
ip: req.ip,
});
// ... actual code
}Deploy, wait a release window (2–4 weeks), check logs. If zero invocations, delete with confidence.
For old client-version fallbacks: increment metric, alert if non-zero after the deprecation window.
The cleanup PR shape
Don't delete 50 things in one PR. Bundle by concept:
- One PR per dead feature.
- One PR for unused dependencies.
- One PR for dead utility functions in one module.
Each PR is small enough that a reviewer can verify each deletion. Mass deletes hide one accidental load-bearing item.
chore(cleanup): remove legacy v1 invoice exporter
Tier 1: knip flagged. grep confirms no remaining callers in main repo
or downstream packages. Last commit on these files: 2024-08-12 (#1234).
- src/exporters/invoice-v1.ts (deleted)
- src/exporters/invoice-v1.test.ts (deleted)
- Tests passing.What to look for during PR review of a delete
- Was a string match in JSON / YAML / config done?
- Is this code in a published package's public API?
- Is there a test that tests against the deletion target? Delete that test too.
- Is this referenced via DI / reflection / dynamic import?
- Does removing this require any DB cleanup (e.g. cron job rows)?
Tools roundup
| Tool | Language | Notes |
knip | JS/TS | Best-in-class; covers files/exports/deps |
ts-prune | TS | Older, narrower; knip subsumes |
depcheck | JS/TS | Just deps |
madge --circular | JS/TS | Find circular deps; partial cleanup signal |
vulture | Python | Finds unused functions/classes; tune confidence |
ruff | Python | Catches unused imports/vars on every save |
staticcheck | Go | Part of standard tooling |
unused | Go | Standalone unused-detector |
cargo udeps | Rust | Unused crates (requires nightly) |
cargo-machete | Rust | Unused deps; stable Rust |
| IntelliJ inspections | Java | Right-click → Analyze → Unused Declarations |
Anti-patterns
- Deleting based on "I don't recognize this" — gut isn't a static analyzer. Run the tools.
- Deleting before searching outside the file/module — DI, config, plugins reference by name.
- Mass-delete PR with 50 deletions — reviewer can't verify each. Split.
- Deleting test fixtures referenced by name — silent test breakage. Search by string content.
- Deleting code without a deprecation log first for tier 3 — get evidence before removing.
- Deleting in a published package without a major version bump — breaks downstream.
- Believing high coverage means everything is reachable — coverage measures the path tests exercise; rare prod paths aren't tested either.
- Deleting comment-blocks of "old code preserved for reference" without checking git history — history is your reference; delete.
- Keeping
// TODO: remove thisin code — same problem inverted. Either remove now or open an issue with a date.
Verify it worked
- A static analyzer ran and produced findings (knip, vulture, staticcheck, etc).
- Findings sorted into tiers 1/2/3.
- Tier 1 deletions are PRs that reviewers can verify in <10 min each.
- Tier 2 has commented-out code with a date; revisit calendar entry exists.
- Tier 3 has deprecation logging; observability is in place.
- No deletion broke something silently — CI green, smoke tests pass.
- Repo size / bundle size measurable improvement after cleanup.
- PR descriptions document the analyzer's flag and the search done before delete.
- Cleanup is repeatable — a quarterly run produces a clean report (means no new dead code, or you're removing it as you go).
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
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.

