Find dead code, prove it is dead, and see it on a map.
deadcode-map scans a repo and grades every finding SAFE / REVIEW / KEEP, with evidence for each one: importers, callers, string mentions, git age, test coverage. SAFE means nothing in the repo uses it. --fix deletes SAFE findings only. --prove deletes them in a scratch git worktree and runs your tests first. The map is a single self-contained HTML file: a mind map, left to right, root → folders → files. Red nodes hold SAFE dead code, amber hold REVIEW, grey files are clean.
JavaScript / TypeScript, Python, and Java (private-only, opt in with --java-safe). Node.js 18+. Source is parsed with tree-sitter, never executed.
- Terminal: scan, then
--fix, then a clean re-scan (12 s, real run) - Map: expand a folder, open a file, delete from the UI in serve mode (15 s, real run)
npm install -g deadcode-mapGlobal install — the deadcode-map command works anywhere in the terminal. This is the recommended way for a CLI tool.
npm i deadcode-map # local install into the current project, run it with `npx deadcode-map`npm i deadcode-map is what the Install box on npmjs.com shows by default for every package — it is the local form, not a correction to -g.
npx deadcode-map # try it without installingRun it with no path, inside your project. It scans the current directory:
deadcode-map # list findings, graded SAFE / REVIEW / KEEP
deadcode-map --fix # delete SAFE findings only (git-backed, review with git diff; every edit is re-parsed — an edit that would break the file is rolled back, and a file holding live code is never deleted)One file only — the whole project is still scanned (a function can be called from another file), but only that file's findings are reported, fixed, or mapped:
deadcode-map src/utils.js
deadcode-map src/utils.js --fixIf your terminal is already inside the project directory, use the bare commands above — no path needed. A bare deadcode-map always scans the directory your terminal is in right now.
If you are in a different terminal or directory, pass the project path instead, or cd into it first:
deadcode-map ./my-app # ./ means "a folder inside the current directory"
deadcode-map /home/ashu/my-app # an absolute path works too
deadcode-map ./my-app --fix
cd ./my-app && deadcode-map --fix./my-app is just an example path — replace it with your project's folder name.
The map:
deadcode-map --map deadcode-map.html # open it by double-clicking, no server neededClick a file to see everything removable inside it — each SAFE item with its evidence, the exact delete diff, and a copyable fix command. A Files button opens a searchable file list, worst first.
A static HTML file cannot edit files, so the static map offers a copyable fix command instead of a delete button. For real in-UI deletion, run the live map:
deadcode-map serve # http://127.0.0.1:8123/
deadcode-map serve ./my-app --port 8123 # localhost only, never a public addressIt serves the same map and adds a Delete button to every SAFE item and to every file's SAFE findings. The UI asks for confirmation before deleting, then re-scans and shows the file clean. Only SAFE findings are deletable, never REVIEW or KEEP, and only inside the scanned project. Ctrl+C stops the server. (--serve works as a flag too.)
| Command | What it does |
|---|---|
deadcode-map [path] |
Scan a directory (default: current directory) or a single file |
deadcode-map --fix |
Delete SAFE findings only |
deadcode-map --prove |
Prove SAFE deletions: delete in a scratch git worktree, run your tests, report proven / breaks / skipped |
deadcode-map --map <file> |
Write the single-file offline HTML map |
deadcode-map --json <file> |
Write the full JSON report (--json - writes it to stdout) |
deadcode-map serve [path] [--port N] |
Live map with in-UI deletion (localhost only, default port 8123) |
deadcode-map --fail-on safe |
CI: exit 1 when new SAFE dead code exists |
deadcode-map --baseline / --update-baseline |
Hide / record grandfathered findings in .deadcode-map.json |
deadcode-map --diff <baseRef> |
Only findings in files changed vs a git ref (e.g. origin/main) |
deadcode-map --sarif <file> |
SARIF 2.1.0 report for GitHub Code Scanning |
deadcode-map --cache |
Cache per-file parses; repeat scans are several times faster |
deadcode-map --coverage <file> |
Cobertura XML or lcov as a confidence signal (auto-detected when present) |
deadcode-map --java-safe |
Opt in to SAFE grades for Java (private-only) |
deadcode-map mcp |
Start the MCP server on stdio (for AI tools) |
A --json report or --map file written inside the scanned repo is excluded from the scan itself, so repeat runs report identical findings. Exit codes: 0 ok, 1 --fail-on triggered, 2 usage error / no such directory.
| Category | Definition |
|---|---|
| Dead file | No importer, not an entry point, not referenced by name anywhere |
| Dead export / function / class | Defined/exported, 0 importers/callers in the repo |
| Dead import / variable | Imported/declared, never referenced in its scope |
| Unreachable code | Code after return / throw / break / continue, if (false) branches |
| Dead dependency (JS) | In package.json, never imported, required, named in a script, or referenced by a code/config string |
Entry points (package.json main/bin/exports, src/index, __main__ scripts, framework routes, tests, stories, config, migrations); framework-invoked code (route handlers, decorators, dunder/protocol methods, Pydantic/dataclass model fields, @overload groups); re-exports (export { X }, # noqa: F401); public API of a published library (REVIEW at most); methods with 0 in-repo callers (REVIEW at most — they could be called via an object or a framework); anything in a file using dynamic import(), require(variable), importlib, or getattr (REVIEW at most); test code and intentional dead code (# pragma: no cover, /* istanbul ignore next */). A symbol used in its own file is never flagged. Fixture/test-data directories are excluded by default (--include-fixtures to scan them). Framework route directories (app/, pages/) only count as routes when the file's own package shows that framework — a next dependency or a next.config.* file in its nearest package — so a FastAPI app/ package, or a plain package sharing a monorepo with a Next.js app, is scanned as ordinary code. The same gate applies to routes/: it only counts as routes when the file's own package declares @sveltejs/kit, @remix-run/node / @remix-run/react, or ember-source (packs sveltekit.json, remix.json, ember.json keep the route files' symbols too). A Remix app's shell files — app/root.tsx and app/entry.client.tsx / app/entry.server.tsx, loaded by the framework by path — are entries only under the same Remix gate, so the same paths in a plain package are scanned as ordinary code. views/ is not an entry pattern at all — no framework invokes files under a views/ directory by path, so Django, Vue, Flask, NestJS and Express view modules are scanned as ordinary imported code.
False-positive defences, in order: a real import/call graph built from entry points (no flat name-matching) — Python absolute imports resolve from the importing file's own package root (nearest package.json, named pyproject.toml / setup.py / setup.cfg, or Django manage.py), not only from the scan root, so a nested package's modules are not misread as unimported, and each package root is also tried as a src/-layout root (<root>/src/<pkg>, flat layout first), so src/-layout packages like Flask and Click resolve too; a string-reference pass across the repo (only code-like mentions count — README prose and .md files never do); coverage evidence demotes would-be SAFE to REVIEW; dynamic-import and reflection detection downgrade to REVIEW; framework rule packs (frameworks/*.json); confidence grading; baselines; --prove as the final arbiter.
Fixtures in fixtures/ plant dead items next to known live items. Every live symbol is never flagged SAFE, every planted dead item is found at SAFE or REVIEW — 0% SAFE false positives on the fixtures, enforced by npm test (670 tests, 669 pass, 1 skipped).
On real repos the SAFE count fell as the defences landed: umami went from 1,044 SAFE findings to 53, date-fns from 100 to 2, fastapi from 71 to 0. SAFE precision is hand-sampled per repo, not asserted from the count — the 38 umami SAFEs found in batch 3 were all verified true by hand.
An MCP server (stdio) exposes six tools — scan_repo, explain_finding, prove_safe, fix_safe, get_map, status — plus a cleanup-dead-code prompt and a deadcode://map/{path} resource. fix_safe deletes SAFE findings only and refuses unless you pass confirm: true.
/plugin marketplace add ashudhanda/deadcode-map
/plugin install deadcode-map@deadcode-mapOr wire the server by hand in any MCP client config:
{
"mcpServers": {
"deadcode-map": {
"command": "npx",
"args": ["-y", "deadcode-map", "mcp"]
}
}
}Any agent that can run shell commands can also use the CLI directly — no MCP setup needed. A repo guide for agents lives in AGENTS.md.
Paste a public GitHub repo link at https://ashudhanda.github.io/deadcode-map/ and check dead code in the browser: summary counts, per-file findings, and a visual map. Your repo is fetched straight from GitHub in your browser — nothing is uploaded anywhere. An optional GitHub token raises the API rate limit from 60 to 5,000 requests/hour; it is kept only in memory and never stored.
Honest limit: the web checker is a lightweight regex-based analyzer, not the full tree-sitter CLI. It covers JS/TS and Python, caps at 500 files / 5 MB, and handles public repos only. For full accuracy, --prove, and --fix, use the CLI above.
discover → parse (tree-sitter) → import/call graph → confidence + evidence
↑ git age / churn ↑ string-reference pass
↑ coverage.xml (if present) ↑ framework packs
└─→ CLI / JSON / --fail-on / baseline ─→ HTML map ─→ --fix ─→ --prove
MIT. See LICENSE.


