JSPM

dead-code-ai

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q59109F
  • License MIT

Static analyzer that finds semantically useless code using LLM reasoning

Package Exports

  • dead-code-ai
  • dead-code-ai/dist/cli.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dead-code-ai) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dead-code-ai

A static analyzer that finds semantically useless code — not just syntactically unused variables (ESLint already does that).

$ npx dead-code-ai src/

dead-code-ai demo npm license


What it finds that ESLint can't

Pattern Example
Result computed, never used const x = heavyFn(); return otherThing;
Condition always true/false if (env === 'prod' && env !== 'prod')
Argument never referenced function add(a, b, c) { return a + b; }
Object built, never read const obj = {a: 1}; doSomethingElse();
Loop result discarded items.forEach(x => total += x); return 0;
Immediate reassign before read let x = compute(); x = 0; use(x);
Redundant double-computation validate(data); validate(data); save(data);

ESLint catches let x = 1; with no usage. dead-code-ai catches semantic waste — code that runs but whose result is meaningless in context.


Install

npm install -g dead-code-ai
# or use directly
npx dead-code-ai

Usage

# Analyze current directory
dead-code-ai

# Analyze specific files or directories
dead-code-ai src/ lib/utils.ts

# Only report high-severity issues
dead-code-ai --min-severity high src/

# Output JSON (for CI integration)
dead-code-ai --json src/ > report.json

# Custom extensions
dead-code-ai --ext .ts,.tsx src/

Setup

Get a free API key at console.groq.com and set it:

export GROQ_API_KEY=gsk_...

Or pass it inline:

dead-code-ai --key gsk_... src/

CI Integration

# .github/workflows/dead-code.yml
- name: Check for semantic dead code
  run: npx dead-code-ai --min-severity high --json src/
  env:
    GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}

How it works

  1. Parse — Babel AST extracts every function/method in your codebase
  2. Batch — Functions are grouped into batches of 6 to minimize API calls
  3. Analyze — Each batch is sent to llama-3.3-70b-versatile via Groq with a strict prompt focused on semantic analysis
  4. Report — Findings are printed with file, line, severity, and the exact problematic snippet

Options

Flag Default Description
--key $GROQ_API_KEY Groq API key
--ext .js,.jsx,.ts,.tsx,.mjs,.cjs File extensions to analyze
--min-severity low Minimum severity: high, medium, low
--json off Output raw JSON instead of formatted output

Severity levels

  • ● high — Code that provably does nothing (always-false branch, result always discarded)
  • ◆ medium — Code that likely does nothing in most contexts
  • ○ low — Code that is suspicious and worth reviewing

Supported languages

  • JavaScript (.js, .mjs, .cjs)
  • TypeScript (.ts)
  • React (.jsx, .tsx)

License

MIT — built by iamadhitya1