|
1 | 1 | # DeadCode |
2 | 2 |
|
3 | | -CLI tool to detect and auto-remove unused exports, dead routes, orphaned CSS, and unreferenced components in TypeScript/React/Next.js projects. |
| 3 | +**Detect and remove unused exports, dead routes, orphaned CSS, and unreferenced components in TypeScript/React/Next.js projects.** |
4 | 4 |
|
5 | | -[](https://github.com/Coding-Dev-Tools/deadcode/actions/workflows/test.yml) |
6 | 5 | [](https://pypi.org/project/deadcode/) |
| 6 | +[](https://pypi.org/project/deadcode/) |
| 7 | +[](https://github.com/Coding-Dev-Tools/deadcode/blob/main/LICENSE) |
| 8 | +[](https://github.com/Coding-Dev-Tools/deadcode/actions/workflows/test.yml) |
7 | 9 |
|
8 | | -## Features |
9 | | - |
10 | | -- **Unused exports** — find functions, classes, constants, types that are exported but never imported |
11 | | -- **Dead routes** — find Next.js pages/api routes with no internal links |
12 | | -- **Orphaned CSS** — find CSS classes defined but never used in JSX |
13 | | -- **Unreferenced components** — find React components defined but never imported |
14 | | -- **Safe auto-removal** — preview with `--dry-run` before making changes |
15 | | -- **Monorepo support** — handles large projects efficiently |
16 | | -- **CI integration** — JSON output for automated pipelines |
| 10 | +**Why DeadCode?** Every TypeScript/React codebase accumulates dead code — exports nobody imports, page components replaced but never deleted, CSS classes refactored out but still sitting in `.module.css` files. ESLint catches unused variables but misses the structural decay: orphaned exports bloat your bundles, stale routes confuse new teammates, and orphaned styles silently accumulate. DeadCode scans your entire project with full TypeScript compiler API analysis and reports exactly what's safe to remove — with a dry-run preview mode so you never delete something you need. |
17 | 11 |
|
18 | | -## Installation |
| 12 | +## Quick Start |
19 | 13 |
|
20 | 14 | ```bash |
21 | 15 | pip install deadcode |
22 | | -``` |
23 | 16 |
|
24 | | -## Usage |
25 | | - |
26 | | -### Scan for dead code |
27 | | - |
28 | | -```bash |
| 17 | +# Scan current project |
29 | 18 | deadcode scan |
| 19 | + |
| 20 | +# Scan a specific project |
30 | 21 | deadcode scan -p /path/to/project |
31 | | -deadcode scan --json-output |
32 | | -deadcode scan -c unused_export # Filter by category |
| 22 | + |
| 23 | +# Preview removable dead code |
| 24 | +deadcode remove --dry-run |
| 25 | + |
| 26 | +# Remove confirmed dead code |
| 27 | +deadcode remove |
33 | 28 | ``` |
34 | 29 |
|
35 | | -### Preview removal (dry run) |
| 30 | +## Commands |
| 31 | + |
| 32 | +### `deadcode scan` |
| 33 | + |
| 34 | +Scan a TypeScript/React/Next.js project for all categories of dead code. |
36 | 35 |
|
37 | 36 | ```bash |
38 | | -deadcode remove --dry-run |
| 37 | +deadcode scan # Scan current directory |
| 38 | +deadcode scan -p /path/to/project # Scan specific project |
| 39 | +deadcode scan --json-output # Machine-readable JSON |
| 40 | +deadcode scan -c unused_export # Filter by category |
| 41 | +deadcode scan -i "generated/" # Ignore paths |
39 | 42 | ``` |
40 | 43 |
|
41 | | -### Remove dead code |
| 44 | +### `deadcode remove` |
| 45 | + |
| 46 | +Remove dead code after previewing. Always preview with `--dry-run` first. |
42 | 47 |
|
43 | 48 | ```bash |
44 | | -deadcode remove |
45 | | -deadcode remove -c orphaned_css |
| 49 | +deadcode remove --dry-run # Preview changes (no writes) |
| 50 | +deadcode remove # Apply removals |
| 51 | +deadcode remove -c orphaned_css # Remove only orphaned CSS |
46 | 52 | ``` |
47 | 53 |
|
48 | | -### View stats |
| 54 | +### `deadcode stats` |
| 55 | + |
| 56 | +Quick overview of dead code in your project. |
49 | 57 |
|
50 | 58 | ```bash |
51 | 59 | deadcode stats |
52 | 60 | ``` |
53 | 61 |
|
54 | 62 | ## Categories |
55 | 63 |
|
56 | | -| Category | Description | |
57 | | -|----------|-------------| |
58 | | -| `unused_export` | Exported names never imported elsewhere | |
59 | | -| `dead_route` | Next.js routes with no internal links | |
60 | | -| `orphaned_css` | CSS classes not referenced in JSX | |
61 | | -| `unreferenced_component` | React components never imported | |
| 64 | +| Category | Description | Example | |
| 65 | +|----------|-------------|---------| |
| 66 | +| `unused_export` | Exported names never imported elsewhere | `export function oldHelper()` with zero consumers | |
| 67 | +| `dead_route` | Next.js routes with no internal links | `app/legacy/page.tsx` no longer linked from navigation | |
| 68 | +| `orphaned_css` | CSS classes not referenced in JSX | `.oldClass` in `styles.module.css` with zero usages | |
| 69 | +| `unreferenced_component` | React components defined but never imported | A `<LegacyWidget>` component with no import sites | |
62 | 70 |
|
63 | | -## Ignore Patterns |
| 71 | +## Features |
64 | 72 |
|
65 | | -Use `--ignore` to exclude paths (gitignore-style): |
| 73 | +- **Unused export detection** — finds functions, types, classes, interfaces, enums, and consts that are exported but never imported within your project |
| 74 | +- **Dead route detection** — detects unreachable page components in Next.js App Router projects |
| 75 | +- **Orphaned CSS detection** — finds CSS module classes that are defined but never referenced in TSX/JSX files |
| 76 | +- **Safe auto-removal** — `--dry-run` preview mode shows exactly what will be deleted before making changes |
| 77 | +- **TypeScript compiler API** — uses the real TS compiler for 100% accurate parsing, not regex heuristics |
| 78 | +- **Monorepo support** — handles large projects efficiently with ignore patterns |
| 79 | +- **CI integration** — JSON output for automated pipelines and gating |
| 80 | + |
| 81 | +## Ignore Patterns |
66 | 82 |
|
67 | 83 | ```bash |
68 | 84 | deadcode scan -i "generated/" -i "**/*.generated.ts" |
69 | 85 | ``` |
70 | 86 |
|
71 | 87 | Default ignores: `node_modules/`, `.git/`, `.next/`, `dist/`, `build/`, `public/`, `static/` |
72 | 88 |
|
73 | | -## CI Integration |
| 89 | +## Pricing |
| 90 | + |
| 91 | +DeadCode is one of eight tools in the Revenue Holdings suite. One license covers all CLI tools. |
| 92 | + |
| 93 | +| Plan | Price | Best For | |
| 94 | +|------|-------|----------| |
| 95 | +| **Free** | $0 | Individual devs, OSS — CLI only, rate-limited | |
| 96 | +| **DeadCode Individual** | **$12/mo** ($10 billed annually) | Professional devs — unlimited scans, auto-removal, CI integration | |
| 97 | +| **Suite (all 8 tools)** | **$49/mo** ($39 billed annually) | Full Revenue Holdings toolkit — 40% savings | |
| 98 | +| **Team** | **$79/mo** ($63 billed annually) | Up to 5 devs — trend analytics, shared baselines, alerts | |
| 99 | +| **Enterprise** | Custom | SSO, RBAC, compliance reports, dedicated support | |
| 100 | + |
| 101 | +🔹 **No lock-in**: CLI works fully offline on the free tier — no telemetry, no phone-home. |
| 102 | +🔹 **Annual billing**: Save 20%. |
| 103 | + |
| 104 | +### Per-Tier Features |
| 105 | + |
| 106 | +| Feature | Free | Individual | Suite | Team | Enterprise | |
| 107 | +|---------|:----:|:----------:|:-----:|:----:|:----------:| |
| 108 | +| CLI: scan, stats | ✓ | ✓ | ✓ | ✓ | ✓ | |
| 109 | +| All 3 scanner categories | — | ✓ | ✓ | ✓ | ✓ | |
| 110 | +| Auto-removal (`deadcode remove`) | — | ✓ | ✓ | ✓ | ✓ | |
| 111 | +| Unlimited file scanning | — | ✓ | ✓ | ✓ | ✓ | |
| 112 | +| CI/CD integration (JSON output) | — | ✓ | ✓ | ✓ | ✓ | |
| 113 | +| Project trend baselines | — | — | — | ✓ | ✓ | |
| 114 | +| Dashboard & analytics | — | — | — | ✓ | ✓ | |
| 115 | +| Compliance reports | — | — | — | — | ✓ | |
| 116 | +| RBAC / SSO / SAML / OIDC | — | — | — | — | ✓ | |
| 117 | +| Priority support | Community | 24h | 24h | 8h | Dedicated | |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +<p align="center"> |
| 122 | + <sub>Part of <a href="https://coding-dev-tools.github.io/revenueholdings.dev/">Revenue Holdings</a> — CLI tools built by autonomous AI.</sub> |
| 123 | +</p> |
| 124 | + |
| 125 | +## CI/CD Integration |
74 | 126 |
|
75 | 127 | ```bash |
| 128 | +# Generate report for CI |
76 | 129 | deadcode scan --json-output > deadcode-report.json |
77 | | -``` |
78 | 130 |
|
79 | | -Exit with findings: |
| 131 | +# Fail CI if any dead routes found |
| 132 | +deadcode scan -c dead_route && exit 1 |
80 | 133 |
|
81 | | -```bash |
82 | | -deadcode scan -j | python3 -c "import sys,json; d=json.load(sys.stdin); sys.exit(1 if d['findings'] else 0)" |
| 134 | +# Track dead code trends over time |
| 135 | +deadcode scan --json-output > baseline-$(date +%Y-%m-%d).json |
83 | 136 | ``` |
84 | 137 |
|
| 138 | +## Storage |
| 139 | + |
| 140 | +- `.deadcode.yml` — project configuration (ignore patterns, categories) |
| 141 | +- `deadcode-baseline.json` — saved scan results for trend tracking |
| 142 | + |
| 143 | +## Roadmap |
| 144 | + |
| 145 | +- [ ] VS Code extension with inline decorations showing dead code |
| 146 | +- [ ] ESLint plugin integration with auto-fix |
| 147 | +- [ ] Webpack/Rollup bundle analysis hooks |
| 148 | +- [ ] MCP server for AI-assisted cleanup |
| 149 | +- [ ] Incremental scanning with cache |
| 150 | +- [ ] GitHub Actions annotator for PR comments |
| 151 | + |
85 | 152 | ## License |
86 | 153 |
|
87 | | -MIT |
| 154 | +MIT — see [LICENSE](LICENSE) |
0 commit comments