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

hauntr

v0.2.1

Published

Your AI codebase engineer

Readme

👻 Hauntr

Your AI codebase engineer

npm version npm downloads CI License: MIT Node

Hauntr scans your codebase, finds issues, and uses AI to explain exactly why they're a problem — with a ready-to-paste fix.

Installation · Usage · Auto-fix · AI Mode · Configuration · Rules · Custom Rules


Why Hauntr?

Most linters tell you what is wrong. Hauntr tells you why it matters and shows you the fix — powered by AI.

hauntr scan --ai
  src/components/Dashboard.jsx
  ⚠  "useEffect" is imported but never used   unusedImports

       Why: Unused imports increase bundle size and make it harder for other
       developers to understand what a component actually depends on.

       Fix:
         import { useState } from 'react';

Installation

npm install -g hauntr

Requires Node.js 18+.


Usage

# Scan current directory
hauntr scan

# Scan a specific path
hauntr scan ./src

# AI-powered explanations and fixes
hauntr scan --ai

# Auto-fix fixable issues
hauntr fix

# Save a markdown report
hauntr scan --output markdown

# Output raw JSON
hauntr scan --output json

# Create a config file
hauntr init

Auto-fix

Hauntr can automatically fix certain issues in place — no copy-pasting required.

# Fix all auto-fixable issues in the current directory
hauntr fix

# Fix a specific path
hauntr fix ./src

# Preview what would be fixed without writing any files
hauntr fix --dry-run

# Scan, report, and fix in one shot
hauntr scan --fix

# Scan, report, and preview fixes without writing files
hauntr scan --fix --dry-run

Example output:

✔  Fixed 3 issues across 2 files
   src/components/Dashboard.jsx
   src/utils/helpers.js

⚠  1 issue could not be auto-fixed — run `hauntr scan` to review

Only rules marked as fixable in the Built-in Rules table support auto-fix. Custom rules can opt in by implementing a fix(content, issues) method — see Writing Custom Rules.


AI Mode

Hauntr uses AI to enrich every issue it finds with:

  • Why — a plain-English explanation of the risk
  • Fix — a minimal corrected code snippet, ready to paste

To use AI mode, set your API key and pass the --ai flag:

# Groq (free)
export GROQ_API_KEY="gsk_..."
hauntr scan --ai

# Anthropic
export ANTHROPIC_API_KEY="sk-ant-..."
hauntr scan --ai

Get a free Groq key at console.groq.com.


Configuration

Create a hauntr.config.js in your project root, or run hauntr init to scaffold one:

// hauntr.config.js
export default {
  rules: {
    unusedImports: 'warn',
    largeComponents: { severity: 'warn', maxLines: 300 },
    readmeCheck: 'error',
  },
  ignore: ['dist', 'coverage', '*.test.js'],
};

Severity levels

| Value | Behaviour | |---|---| | 'error' | Exits with code 1, fails CI | | 'warn' | Reported but does not fail CI | | 'off' | Rule disabled |


Built-in Rules

| Rule | What it catches | Auto-fixable | |---|---|---| | unusedImports | Imported bindings never referenced in the file | ✅ | | largeComponents | Component files over a line threshold (default: 300) | ❌ | | readmeCheck | Missing README or missing Installation/Usage sections | ❌ |

Full documentation for each rule: docs/rules.md


Writing Custom Rules

Every rule is a plain JS object with a run method. Register it in your config:

// my-rules/noConsole.js
export const noConsole = {
  meta: {
    name: 'noConsole',
    description: 'Disallows console.log statements in production code.',
    fixable: false,
  },

  run(file, options = {}) {
    const issues = [];
    const lines = file.content.split('\n');

    lines.forEach((line, idx) => {
      if (/console\.(log|warn|error)/.test(line)) {
        issues.push({
          rule: 'noConsole',
          severity: options.severity ?? 'warn',
          message: 'Unexpected console statement',
          file: file.path,
          line: idx + 1,
        });
      }
    });

    return issues;
  },
};
// hauntr.config.js
import { registry } from 'hauntr/rules';
import { noConsole } from './my-rules/noConsole.js';

registry.register('noConsole', noConsole);

export default {
  rules: {
    noConsole: 'error',
  },
};

To make a custom rule auto-fixable, set fixable: true in meta and add a fix(content, issues) method that returns the corrected file content:

export const myRule = {
  meta: {
    name: 'myRule',
    description: '...',
    fixable: true,
  },

  run(file, options = {}) { /* ... */ },

  fix(content, issues) {
    // Apply fixes to content and return the modified string
    return content;
  },
};

See CONTRIBUTING.md for the full rule API reference.


CI Integration

Hauntr exits with code 1 when any error-level issues are found, making it drop-in ready for GitHub Actions:

# .github/workflows/hauntr.yml
name: Hauntr

on: [push, pull_request]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm install -g hauntr
      - run: hauntr scan

Contributing

Contributions are welcome — especially new rules. See CONTRIBUTING.md to get started.

git clone https://github.com/boyzliberty360/hauntr.git
cd hauntr
npm install
npm test

License

MIT © boyzliberty360