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 optiprune

Usage

Run it in your project root:

optiprune --rootDir . --entry src/index.ts

Why 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

Layer 1

Entry Point Graph

Static import/export dependency graph & entry point discovery

Layer 2

Monorepo & Workspaces

Cross-package references and boundary resolution

Layer 3

Dynamic Tracing & SMT

Path unreachability via Z3 constraint solving

Layer 4

Isolated V8 Execution

Candidate validation inside sandboxed isolated-vm Isolates

Layer 5

AST Contract & Schema

Preserves Zod/Schema classes, decorators, and API boundaries

Layer 6

Unused Package Sweeper

Flags unused external dependencies in package.json

Layer 7

Non-Standard Entry

Implicit bindings (DI/Events) and Dynamic Specifier resolution

Extreme Minefield Benchmark

Accuracy Under Complexity

Knip (Competitor)

✗ Failed: 8 false positives
✗ Missed: 12 dead exports
⚠ Limited framework awareness
✗ Higher false positive rate
$ knip --strict

OptiPrune

✓ Precision-Engineered Core
✓ Better than heuristic-only tools
✓ Smart Core Analysis
$ npx optiprune --sarif

Accuracy Comparison

Competitors
Baseline
OptiPrune
Better

Live CLI Demo

See OptiPrune in Action

$ npx optiprune
Optiprune Analysis Report v1.8.1
Root: /home/ubuntu/monorepo-battlefield
Summary:
Files: 4 discovered, 4 parsed
Findings: 7 total (0 errors, 5 warnings)

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

1

Auto-Detection

Plugin checks package.json for framework dependency

2

onFileStart

Mark framework-specific entry points before analysis

3

onASTNode

Detect framework patterns in AST traversal (synchronous)

4

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