Stop Guessing. Start Proving.
The world's first dead-code analyzer powered by SMT Solvers and V8 Isolates.
Getting Started
OptiPrune is a next-generation dead-code analyzer. Unlike traditional scanners, it uses a 7-layer architecture to understand your code's logic and framework context.
Installation
npm install -g optipruneUsage
Run it in your project root:
optiprune --rootDir . --entry src/index.tsWhy OptiPrune?
- Precision: Uses Z3 Solver for formal logic.
- Resilience: Doesn't crash on syntax errors.
- Intelligence: Understands framework decorators (NestJS, TypeORM).
The 7-Layer Core
Precision Engineering Through Every Stage
Entry Point Graph
Static import/export dependency graph & entry point discovery
Monorepo & Workspaces
Cross-package references and boundary resolution
Dynamic Tracing & SMT
Path unreachability via Z3 constraint solving
Isolated V8 Execution
Candidate validation inside sandboxed isolated-vm Isolates
AST Contract & Schema
Preserves Zod/Schema classes, decorators, and API boundaries
Unused Package Sweeper
Flags unused external dependencies in package.json
Non-Standard Entry
Implicit bindings (DI/Events) and Dynamic Specifier resolution
Extreme Minefield Benchmark
Accuracy Under Complexity
Knip (Competitor)
OptiPrune
Accuracy Comparison
Live CLI Demo
See OptiPrune in Action
Plugin Architecture
Framework-Aware Dead Code Detection
OptiPrune uses a Plugin Adapter architecture that allows framework-specific dead code detection. Plugins hook into the analysis lifecycle to recognize framework patterns, decorators, and conventions that would otherwise be marked as unused.
Built-in Plugins
Angular
@Component, @Injectable, @Module, .component.ts, .service.ts
Svelte
.svelte files, lifecycle hooks, stores
Next.js
page.tsx, route.ts, data fetching functions, hooks
NestJS
@Controller, @Injectable, route decorators, DI
Vue.js
.vue files, composition API, lifecycle hooks
Nuxt
pages/, layouts/, composables, definePageMeta
Astro
.astro files, API routes, getStaticPaths
Plugin Lifecycle
Auto-Detection
Plugin checks package.json for framework dependency
onFileStart
Mark framework-specific entry points before analysis
onASTNode
Detect framework patterns in AST traversal (synchronous)
Mark as Used
Framework-specific code marked as reachable
✅ DO
- Use onFileStart for entry points
- Keep onASTNode synchronous
- Check both dependency types
- Provide fallback detection
- Use Babel types for AST checks
❌ DON'T
- Use async in onASTNode
- Mutate AST nodes
- Assume node structure
- Mark everything as used
- Ignore edge cases