Ask Claude to Find and Remove Dead Code That Nothing Uses Anymore
Every codebase accumulates dead code — functions nobody calls, files nobody imports, config for features that were removed months ago. It's noise that makes the project harder to navigate and understand. Claude finds it and cleans it up.
"Find all dead code in this project — unused functions, orphaned files,
and imports that nothing references. List them first, then remove them."
Claude searches the codebase, traces references, and identifies code that's genuinely unreachable — not just code that looks unused, but code that no execution path can reach.
Different types of dead code Claude finds:
# Unused functions and methods
"Find functions that are defined but never called anywhere in the project"
# Orphaned files
"Find files that aren't imported, included, or referenced by any other file"
# Unused imports
"Remove all unused imports across the project"
# Dead feature code
"Find code behind feature flags that were removed or always evaluate to false"
# Unreachable branches
"Find if/else branches that can never execute based on the surrounding logic"
Be careful with some types of dead code — Claude checks for:
- Dynamic calls — code called via strings, reflection, or config that static analysis would miss
- Event listeners — registered via config or decorators, not direct imports
- CLI commands — called from the terminal, not imported by other files
- API endpoints — hit by external clients, not internal code
- Template references — Blade includes, JSX components, or partials
Ask Claude to be cautious:
"Find potentially dead code, but flag anything that might be called
dynamically or from external systems. Don't delete those — just list them
so I can verify."
After removal, run the tests:
"Now run the full test suite to make sure nothing we removed was actually needed"
Dead code is a lie — it says "this matters" when it doesn't. Let Claude find and remove it so the code that remains is the code that counts.
via Claude Code
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.