Remove dead code, unused imports and debug statements with Claude Code
dead-code-cleaner deletes commented-out code, leftover console.log, var_dump, print and debugger calls, unused imports and unused functions in 40+ languages. Comments that explain your code stay.
What it removes
Commented-out code
Old implementations and disabled calls are deleted. Docblocks, license headers, TODOs and linter directives are kept.
Debug statements
console.log, debugger, var_dump/dd/print_r, breakpoint(), binding.pry, dbg!, System.out.println and more.
Unused imports
Python, JavaScript/TypeScript, Vue/Svelte, PHP use, Java, Kotlin and Groovy. Side-effect imports are left alone.
Unused functions
Optional. Reported, checked against framework entry points, then removed, using native analyzers where available.
Fast, token-cheap scanner
The bundled deadcode.py (Python 3.8+, no dependencies) lexes every file once and prints one line per finding, so Claude can review a whole repository without opening each file. A full scan of a real 3,700-file PHP/JS project takes about 2 seconds.
$ deadcode.py scan app/ app/models/User.php 42-47 H 6L // $this->db->where('id', $id); 88 M^ 1L // return $cache; # 312 files, 57 findings (41 H, 16 M), 230 lines
Install
In Claude Code, add the marketplace and install the plugin:
/plugin marketplace add mushonnif/dead-code-cleaner /plugin install dead-code-cleaner@dead-code-cleaner
Then ask in plain language ("remove console.log and debug prints") or run the command:
/remove-dead-code # commented-out + debug + imports, whole repo /remove-dead-code comments src/ # commented-out code only /remove-dead-code debug app/ # debug statements only /remove-dead-code imports src/ # unused imports only
What Claude does
- Checks there are no uncommitted changes, so the cleanup is its own diff.
- Scans and triages findings by confidence.
- Removes approved ranges. The script refuses any range that contains live code.
- Optionally finds unused symbols with vulture, knip, phpstan, staticcheck and similar tools.
- Runs your lint and tests, then reports what was removed and what was kept.
Supported languages
C/C++/Obj-C, C#, Java, Kotlin, Scala, Groovy, Go, Rust, Swift, Dart, Zig, JavaScript/TypeScript, Vue/Svelte/Astro, PHP (incl. Laravel Blade), Python, Ruby, Perl, Shell, PowerShell, Lua, SQL, Haskell/Elm, Elixir, Erlang, Julia, Lisp/Clojure, R, VB, Ada/VHDL, assembly, HTML/XML, CSS/SCSS/Less, Twig/Jinja, Handlebars, ERB, YAML/TOML/HCL/Terraform, Dockerfile, Makefile.
FAQ
How do I remove all console.log statements from a project?
Run /remove-dead-code debug src/. Standalone console.log, console.debug and debugger lines are removed. console.error and real loggers are kept. A call whose removal would break code is flagged for a hand fix.
How do I find unused imports in Python, JavaScript, TypeScript, PHP or Java?
Run /remove-dead-code imports src/, or use the scanner on its own: deadcode.py scan src/ --kind imports. Statements with only some unused names are flagged as partial.
How do I delete commented-out code but keep real comments?
Run /remove-dead-code comments. Code-shaped comments are told apart from prose, so docblocks, license headers, TODO notes and linter directives stay.
How do I remove var_dump, dd() and print_r from a PHP or Laravel project?
Run /remove-dead-code debug app/. Blade templates are supported.
Does it work without Claude?
Yes. deadcode.py is a standalone Python 3.8+ script with no dependencies.