ts-prune is a popular open-source CLI tool that finds unused exports in TypeScript projects. CleanAI is a VS Code/Cursor extension that combines ts-prune with other analysis tools for comprehensive dead code detection. This article compares them across the dimensions that matter for day-to-day development.
What ts-prune Does
ts-prune analyzes your TypeScript project's dependency graph and reports exports that are never imported anywhere. You run it from the command line:
npx ts-prune
It outputs a list of unused exports with file paths and line numbers:
src/utils/formatCurrency.ts:3 - formatCurrency
src/helpers/legacy.ts:1 - default
src/components/OldButton.tsx:5 - OldButton
Strengths of ts-prune:
- Fast and focused -- does one thing well
- No configuration required for most projects
- Works with any TypeScript project that has a
tsconfig.json - Free and open source
Limitations of ts-prune:
- Only detects unused exports (not unused imports, variables, or unreachable code)
- TypeScript only (no JavaScript, Swift, or Python)
- CLI-only output -- no visual UI or IDE integration
- No automated removal -- you must delete code manually
- Does not verify that removal is safe (no build verification)
What CleanAI Does
CleanAI is a VS Code and Cursor extension that runs multiple analysis tools and presents unified results in a visual panel. Under the hood, it uses:
- ts-prune for unused TypeScript/JavaScript exports
- ESLint for unused imports and variables
- Periphery for unused Swift declarations
- Vulture for unused Python code
Results are displayed in a webview panel inside your editor, grouped by file, with one-click removal for each finding.
Strengths of CleanAI:
- Multi-language support (TypeScript, JavaScript, Swift, Python)
- Detects unused exports, imports, variables, and orphaned files
- Visual UI integrated into VS Code/Cursor
- One-click removal with undo support
- Auto Clean (Safe) mode: comments out code, runs your build, and only confirms removal if the build passes
- Tracks cleanup progress over time
Limitations of CleanAI:
- Requires VS Code or Cursor (no standalone CLI for full features)
- Free tier has scan limits (paid plans for unlimited)
- Depends on the underlying tools being installed (e.g., Periphery requires Xcode)
Feature Comparison
| Feature | ts-prune | CleanAI | |---------|----------|---------| | Unused exports | Yes | Yes (via ts-prune) | | Unused imports | No | Yes (via ESLint) | | Unused variables | No | Yes (via ESLint) | | Orphaned files | No | Yes | | TypeScript | Yes | Yes | | JavaScript | Partial | Yes | | Swift | No | Yes (via Periphery) | | Python | No | Yes (via Vulture) | | IDE integration | No | VS Code + Cursor | | One-click removal | No | Yes | | Build verification | No | Yes (Auto Clean Safe) | | Price | Free | Free tier + paid plans |
When to Use ts-prune
ts-prune is the right choice when:
- You only work with TypeScript
- You want a quick CLI check for unused exports
- You are comfortable manually deleting code
- You want a free, zero-dependency tool
- You are integrating dead code detection into a CI script
When to Use CleanAI
CleanAI is the right choice when:
- You work with multiple languages (TypeScript + Swift, or TypeScript + Python)
- You want a visual UI that shows findings in context
- You want automated, safe removal with build verification
- You want to detect unused imports and variables, not just exports
- You want to track cleanup progress over time
Using Them Together
Since CleanAI uses ts-prune internally, you get the best of both worlds by using CleanAI in your editor and ts-prune in your CI pipeline:
- In development: Use CleanAI's visual panel to review and remove dead code interactively
- In CI: Run
npx ts-pruneas a check that fails if new unused exports are introduced - Periodically: Run a full CleanAI scan to catch dead code that ts-prune alone misses (unused imports, orphaned files, multi-language issues)
Conclusion
ts-prune is an excellent, focused tool for finding unused TypeScript exports. CleanAI builds on top of it to provide a more complete dead code solution with multi-language support, visual UI, and automated safe removal. For most teams, using CleanAI in the editor and ts-prune in CI gives the best coverage.