CLI tool to detect and auto-remove unused exports, dead routes, orphaned CSS, and unreferenced components in TypeScript/React/Next.js projects.
- Unused exports — find functions, classes, constants, types that are exported but never imported
- Dead routes — find Next.js pages/api routes with no internal links
- Orphaned CSS — find CSS classes defined but never used in JSX
- Unreferenced components — find React components defined but never imported
- Safe auto-removal — preview with
--dry-runbefore making changes - Monorepo support — handles large projects efficiently
- CI integration — JSON output for automated pipelines
pip install deadcodedeadcode scan
deadcode scan -p /path/to/project
deadcode scan --json-output
deadcode scan -c unused_export # Filter by categorydeadcode remove --dry-rundeadcode remove
deadcode remove -c orphaned_cssdeadcode stats| Category | Description |
|---|---|
unused_export |
Exported names never imported elsewhere |
dead_route |
Next.js routes with no internal links |
orphaned_css |
CSS classes not referenced in JSX |
unreferenced_component |
React components never imported |
Use --ignore to exclude paths (gitignore-style):
deadcode scan -i "generated/" -i "**/*.generated.ts"Default ignores: node_modules/, .git/, .next/, dist/, build/, public/, static/
deadcode scan --json-output > deadcode-report.jsonExit with findings:
deadcode scan -j | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(1 if d['findings'] else 0)"MIT