npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

legacylens-cli

v4.5.0

Published

AI-powered CLI to analyze and cleanup legacy code. Features: .gitignore support, Schema Response, Auto-fix ready.

Downloads

814

Readme

🕵️‍♂️ LegacyLens

The AI-Powered Code Janitor

Stop hoarding dead code. Let AI clean up your technical debt.

npm version License: MIT Powered by Gemini

Quick StartFeaturesConfigurationPrivacy


🧐 What is LegacyLens?

LegacyLens is a CLI tool that helps developers audit, refactor, and clean up legacy codebases.

Unlike traditional linters that check syntax, LegacyLens uses Google Gemini AI with a three-level analysis architecture:

  1. Level 1 (Architectural Skeleton): Extracts signatures, imports/exports locally in seconds
  2. Level 2 (Semantic Compression): Sends compressed Project Map instead of raw code
  3. Level 3 (Targeted Deep Dive): Full content analysis for complex/suspicious files

This makes LegacyLens faster and deeper than traditional AI code analysis - it sees the entire repository structure and connections, not just what you copy-paste.

"It's like having a Senior Architect review your project in 30 seconds."

✨ Features

  • 🧠 Three-Level Analysis Architecture:
    • Level 1: Local extraction of signatures, imports/exports (lightning fast)
    • Level 2: Compressed Project Map sent to AI (sees entire repo structure)
    • Level 3: Targeted Deep Dive for complex/suspicious files (full content analysis)
  • 🗺️ Project Map Integration: Automatically builds a structured map of your codebase (imports/exports, signatures) for better analysis.
  • 🔍 Semantic Indexing: Optional semantic search using Gemini Embedding to find code by meaning.
  • 🧹 Enhanced Dead Code Detection: Uses Project Map to identify unused exports and imports automatically.
  • 🔧 Smart Auto-Fix: Automatically removes dead code with AI confirmation (safe, conservative approach).
  • 🎯 Context-Aware Code Generation: Auto-detects framework (Express, FastAPI, Flask, Django) and generates matching code.
  • 🛡️ Secure & Private: BYOK (Bring Your Own Key). Your code goes directly to Google's API. No intermediate servers.
  • ⚡ Blazing Fast: Optimized Gemini 3 Flash models + intelligent caching + parallel file reading.
  • 🤖 Structured Output: Uses JSON Schema Response mode to guarantee valid data for CI/CD pipelines.
  • 📊 Visual Reports: Includes Mermaid diagrams showing project structure and dependencies.
  • 📦 Zero Config: Respects your .gitignore automatically. No Python required. Pure Node.js.

🚀 Quick Start

1. Get a Free API Key

LegacyLens uses Google Gemini API. The free tier is generous (15 RPM, 1M TPM). 👉 Get your API Key here

2. Run without installing (Recommended)

Just run it in your project folder. It will prompt for the key or read it from env.

# Linux/macOS
export GEMINI_API_KEY="your_key_here"
npx legacylens-cli .

# Windows (PowerShell)
$env:GEMINI_API_KEY="your_key_here"
npx legacylens-cli .

3. Or Install Globally

npm install -g legacylens-cli
legacylens ./my-project --output audit.html

📋 CLI Commands

Analyze (Default)

# Basic analysis
legacylens [project]

# With options
legacylens . --format html --output report.html --verbose

Semantic Indexing

# Build semantic index for code search
legacylens index [project]

# Search code by meaning
legacylens find "authentication logic" [project] --top 10

Code Generation

# Generate API route (auto-detects framework: Express, FastAPI, Flask, etc.)
legacylens create-api --route /users [project] --out routes/users.js

Setup Agent Skills (Cursor, Claude Code, Antigravity)

# One-time: install LegacyLens skills into detected IDEs and check API key
npx legacylens-cli setup-skills
# or, if installed globally:
legacylens setup-skills

Smart Auto-Fix

# Find and remove dead code (with AI confirmation)
legacylens auto-fix [project]

# Dry run (see what would be removed)
legacylens auto-fix [project] --dry-run

📊 Example Output

LegacyLens generates a clean, professional report (HTML or Markdown) highlighting:

  • Complexity Score: 0-100 score of your technical debt.
  • Dead Code Detection: Specific unused functions, variables, and files with confidence levels.
  • Critical Issues: Security vulnerabilities, hardcoded paths, and architectural problems.
  • Actionable Refactoring Plan: Concrete "Before/After" code examples for improvements.
  • Visual Diagrams: Mermaid flowcharts showing project structure and import/export relationships.

🎯 Advanced Features

Three-Level Analysis Architecture

Level 1 - Architectural Skeleton (Local):

  • Extracts signatures, imports/exports from all files in seconds
  • Pure Node.js code - runs at light speed
  • Builds complete dependency graph - sees every connection

Level 2 - Semantic Compression:

  • Sends compressed Project Map instead of raw code
  • AI sees entire repository structure at once (1M context)
  • Finds bugs across frontend/backend/database in different folders

Level 3 - Targeted Deep Dive:

  • Identifies suspicious/complex files (high exports/imports)
  • Adds full content of these files for detailed audit
  • Like medical consultation: X-ray first, then MRI specific area

Project Map (Automatic)

Every analysis automatically builds a Project Map that includes:

  • Project folder structure
  • Function/class signatures
  • Import/export relationships
  • Used to enhance dead code detection and enable three-level analysis

Semantic Indexing (Optional)

Build a semantic index for instant code search. The index is automatically detected and used during analysis if available.

⚙️ Configuration

You can customize the behavior by creating a .legacylens.json file in your project root:

{
  "include": [".js", ".ts", ".jsx", ".py", ".go"],
  "ignore": ["coverage", "dist", "legacy-backup"],
  "engines": {
    "flash": "gemini-3-flash-preview",
    "pro": "gemini-3-pro-preview",
    "embedding": "gemini-embedding-001"
  },
  "maxFileSize": 50000,
  "maxContextSize": 1000000,
  "outputFormat": "html"
}

🤖 CI/CD Integration

LegacyLens is designed for pipelines. It returns a JSON report and proper exit codes.

# GitHub Actions Example
- name: Run LegacyLens Audit
  run: npx legacylens-cli . --format json --output report.json
  env:
    GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}

💸 Cost (It's Free)

LegacyLens is Open Source. The cost depends on the AI model you use.

  • Gemini 3 Flash: Free tier is usually sufficient for most projects (15 RPM, 1M TPM).
  • Gemini 3 Pro: For complex architecture tasks (higher cost, better reasoning).
  • Gemini Embedding: Very affordable for semantic indexing ($0.15 per 1M tokens).
  • You pay $0 to us. You only use your own Google API quota.

🛡️ Privacy & Security

  • No Data Collection: We do not collect your code, keys, or data.
  • Direct Connection: The CLI connects directly from your machine to generativelanguage.googleapis.com.
  • Local Processing: File filtering and .gitignore parsing happen locally before sending context to AI.

🗺️ Roadmap

  • [x] Remove Python dependency (Pure Node.js)
  • [x] Implement JSON Schema Response
  • [x] Add HTML/Markdown reports
  • [x] Project Map integration for better context
  • [x] Semantic indexing with Gemini Embedding
  • [x] Code generation (create-api command)
  • [x] Mermaid diagrams in reports
  • [x] Gemini 3 models integration
  • [x] Auto-Fix Mode: Automatically remove dead code with AI confirmation
  • [x] Context-Aware Code Generation: Framework detection and style matching
  • [x] VS Code Extension: Architecture designed (see vscode-extension/)
  • [ ] Code Execution: Run tests and auto-fix until they pass.
  • [ ] VS Code Extension: Implementation (in progress)

📄 License

MIT © LegacyLens Team