Ask Claude to Hunt Down Dead Code
Codebases accumulate dead weight silently — functions nobody calls, exports nobody imports, CSS classes that exist in stylesheets but never appear in templates. Claude can track them down before they become a maintenance burden.
@src/ @resources/
Search for functions, classes, and components that are defined but never
imported or referenced anywhere in the codebase. List each one with the
file path and line number, and explain why you think it's unused.
Claude will scan for defined-but-never-called functions, unused exports, and unreferenced route handlers. It's also good at spotting CSS classes that exist in your stylesheet but don't appear in any template.
Dead code found:
- src/utils/formatCurrency.js:12 — formatCurrencyLegacy() defined but never imported
- src/components/OldModal.jsx — entire file never referenced in any route or layout
- resources/css/app.css:204 — .btn-ghost class not found in any Blade/JSX template
For larger codebases, scope it to one module at a time to stay within context limits — or combine it with your IDE's "find usages" output and paste the results to give Claude a head start.
Ask Claude to double-check each finding before deleting anything, since some code may be called dynamically (via call_user_func, require(), or string-based dispatch).
Dead code isn't harmless — it confuses contributors and hides real logic. Let Claude clean house.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.