dead-code-finder
/install dead-code-finder
Dead Code Finder
Detect and report dead code in JavaScript/TypeScript projects.
Quick Start
# Full scan — unused exports, files, and dependencies
python3 scripts/find_dead_code.py /path/to/project
# Exports only
python3 scripts/find_dead_code.py /path/to/project --mode exports
# Unused files only
python3 scripts/find_dead_code.py /path/to/project --mode files
# Unused dependencies only
python3 scripts/find_dead_code.py /path/to/project --mode deps
# JSON output for programmatic use
python3 scripts/find_dead_code.py /path/to/project --json
What It Detects
1. Unused Exports
Exported functions, classes, constants, types, and interfaces never imported anywhere.
- Named exports (
export function foo,export const bar) - Re-exports (
export { x } from './y') - Type exports (
export type,export interface) - Barrel file analysis (index.ts re-exports)
2. Unreferenced Files
Files never imported by any other file in the project.
- Skips entry points (configurable)
- Skips test files, config files, and scripts by default
- Handles path aliases (tsconfig paths)
3. Unused Dependencies
npm packages in package.json never imported in code.
- Checks
dependenciesanddevDependencies - Recognizes CLI tools as potentially used
- Handles scoped packages and subpath imports
Configuration
Default entry points: src/index.{ts,tsx,js,jsx}, src/main.*, src/app.*, pages/**/*, app/**/*.
Default ignores: node_modules, dist, build, .next, coverage, __tests__, *.test.*, *.spec.*, *.config.*, *.d.ts.
Override via flags:
--entry "src/main.ts,src/worker.ts"
--ignore "generated,vendor"
Interpreting Results
=== Dead Code Report ===
UNUSED EXPORTS (12 found):
src/utils/helpers.ts: formatDate, parseQuery, slugify
src/components/Button.tsx: ButtonProps (type)
src/api/client.ts: createClient
UNREFERENCED FILES (3 found):
src/legacy/oldAuth.ts
src/utils/deprecated.ts
src/components/unused/Card.tsx
UNUSED DEPENDENCIES (2 found):
moment
lodash.merge
Workflow
- Run scan on the project
- Review report — some findings may be false positives (dynamic imports, reflection)
- Verify each finding before removing
- Remove confirmed dead code
- Run tests to confirm nothing broke
Limitations
- Dynamic imports with variable paths may cause false positives
- Code consumed by external packages (libraries) shows as unused
- CSS/SCSS imports not tracked
export *partially supported
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install dead-code-finder - 安装完成后,直接呼叫该 Skill 的名称或使用
/dead-code-finder触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
dead-code-finder 是什么?
Find and remove dead code in JavaScript/TypeScript projects. Detects unused exports, unreferenced files, orphaned components, unused dependencies, and dead f... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 105 次。
如何安装 dead-code-finder?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install dead-code-finder」即可一键安装,无需额外配置。
dead-code-finder 是免费的吗?
是的,dead-code-finder 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
dead-code-finder 支持哪些平台?
dead-code-finder 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 dead-code-finder?
由 charlie-morrison(@charlie-morrison)开发并维护,当前版本 v1.0.0。