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

@mharoon07/slopguard

v0.1.1

Published

Zero-config CLI defense against AI package hallucination and slopsquatting

Readme

@mharoon07/slopguard

Zero-config CLI defense and programmatic validation against AI package hallucination and slopsquatting.

npm version License: MIT Node.js Dependencies


Overview

AI coding assistants (ChatGPT, GitHub Copilot, Claude, Cursor, and others) regularly hallucinate non-existent package names when generating code. Threat actors actively monitor these common hallucinations, register the fake package names on npm, and backfill them with malicious payloads—an attack vector known as slopsquatting.

slopguard sits between your AI assistant and your terminal. It verifies package existence, release recency, download velocity, and deprecation status in real time before you execute npm install.

Key Capabilities

  • Zero Runtime Dependencies: Built entirely with native Node.js 18+ standard APIs and native fetch.
  • High Concurrency: Parallel asynchronous registry queries with built-in in-memory caching and retries.
  • AST-Free Heuristic Code Extractor: Safely extracts package names from standard input, markdown snippets, CommonJS require, and ESM import declarations.
  • CI/CD Ready: Provides deterministic exit codes and structured --json output for automated pipelines.
  • Dual Interface: Full CLI suite with interactive colored tables and an exportable TypeScript/JavaScript SDK.

Quick Start

Run directly with npx (No installation needed)

# Check one or more package names directly
npx @mharoon07/slopguard check express fake-ai-package-helper

# Scan project dependencies and lockfile
npx @mharoon07/slopguard scan

# Inspect piped AI code or terminal output
cat snippet.ts | npx @mharoon07/slopguard code

Install globally

npm install -g @mharoon07/slopguard

After global installation, the binary is available as slopguard:

slopguard check react @tanstack/react-query

Install locally as a development dependency

npm install --save-dev @mharoon07/slopguard

CLI Reference

1. slopguard check <pkg> [pkg2 ...]

Validates one or more package names directly against the npm registry.

slopguard check express lodash hallucinated-package-xyz

Output:

┌────────────┬────────────────────────────┬──────────┬──────────────┬─────────────────────────────────────────────────────────────┐
│ STATUS     │ PACKAGE                    │ AGE      │ DOWNLOADS    │ DETAILS                                                     │
├────────────┼────────────────────────────┼──────────┼──────────────┼─────────────────────────────────────────────────────────────┤
│ CRITICAL   │ hallucinated-package-xyz   │ n/a      │ n/a          │ Does not exist on npm (hallucination risk). Do NOT install. │
│ LOW        │ express                    │ 15.9y    │ 196.6M/wk    │ Established package (active repository, verified)           │
│ LOW        │ lodash                     │ 14.5y    │ 206.5M/wk    │ Established package (active repository, verified)           │
└────────────┴────────────────────────────┴──────────┴──────────────┴─────────────────────────────────────────────────────────────┘

Summary: Checked 3 packages: 1 critical, 0 high, 0 medium, 2 low.
Status:  FAILED (1 unverified package poses hallucination risk)

2. slopguard scan [path]

Scans package.json in the specified directory (defaults to current working directory) for both dependencies and devDependencies. If package-lock.json exists, it evaluates resolved dependency packages while ignoring workspace and link references.

# Scan current repository
slopguard scan

# Scan subfolder or monorepo workspace package
slopguard scan ./packages/api --fail-on high

3. slopguard code

Reads source code, markdown snippets, or terminal logs from stdin. Automatically extracts package names from:

  • ESM import statements (import x from "pkg", import "pkg", import("pkg"))
  • CommonJS require calls (require("pkg"))
  • Package manager commands (npm i pkg, yarn add pkg, pnpm add pkg, bun add pkg)

Automatically ignores relative paths (./, ../), built-in Node.js modules (fs, node:path, etc.), flags, and subpath imports.

# Pipe from file
cat prompt-output.md | slopguard code

# Pipe from clipboard on Linux
xclip -selection clipboard -o | slopguard code

# Pipe from clipboard on macOS
pbpaste | slopguard code

# Pipe from clipboard on Windows PowerShell
Get-Clipboard | slopguard code

Risk Assessment Matrix

| Risk Level | Heuristic Criteria | Action Required | | :--- | :--- | :--- | | CRITICAL | Package does not exist on npm (HTTP 404). Prime indicator of AI hallucination. | Abort immediately. Do not install. | | HIGH | Created less than 30 days ago AND under 500 weekly downloads. High slopsquatting indicator. | Audit source repository and maintainer identity before proceeding. | | MEDIUM | Created less than 90 days ago, OR under 100 weekly downloads, OR marked deprecated by author. | Proceed with caution; verify package legitimacy. | | LOW | Established package with proven tenure, download volume, and active maintenance. | Safe to install under standard developer hygiene. | | UNKNOWN | Registry network timeout, connection dropped, or HTTP 429 rate limit encountered. | Verification incomplete. Never treated as safe. |


CLI Options

| Flag | Description | Default | | :--- | :--- | :--- | | --fail-on <level> | Exit with status code 1 if any package meets or exceeds the specified level (critical, high, medium, low). | high | | --json | Output findings in machine-readable JSON format. | false | | --no-color | Suppress ANSI terminal formatting. Also respects NO_COLOR=1. | false | | -h, --help | Show usage documentation and options. | - | | -v, --version | Display installed binary version. | - |


Exit Codes

| Code | Status | Meaning | | :--- | :--- | :--- | | 0 | Clean | All packages evaluated below the configured --fail-on threshold. | | 1 | Alert | One or more packages met or exceeded the --fail-on risk threshold. | | 2 | Error | CLI invocation error (missing required arguments, unreadable path, or bad flag). |


CI / GitHub Actions Integration

Prevent untrusted or hallucinated dependencies from entering pull requests by adding a check step to your workflow:

name: Supply Chain Defense

on:
  pull_request:
    branches: [main]

jobs:
  slopguard-audit:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Audit dependencies with slopguard
        run: npx @mharoon07/slopguard scan --fail-on high

Programmatic API

@mharoon07/slopguard can be consumed as an ES module in TypeScript or JavaScript projects:

import {
  checkPackage,
  checkPackages,
  extractPackages,
  assessRisk,
  scanDirectory
} from '@mharoon07/slopguard';

// Verify a single package
const result = await checkPackage('express');
console.log(result.level); // 'LOW'
console.log(result.downloads); // e.g. 196600000

// Extract packages from arbitrary code or text
const extracted = extractPackages(`
  import { test } from "ai-hallucinated-module";
  import react from "react";
`);
console.log(extracted); // ['ai-hallucinated-module', 'react']

// Batch verification with concurrency control
const batchResults = await checkPackages(extracted, { concurrency: 5 });
for (const item of batchResults) {
  if (item.level === 'CRITICAL') {
    throw new Error(`Hallucinated package detected: ${item.name}`);
  }
}

Limitations

  • Registry Verification Only: Checks existence, age, download metrics, and deprecation metadata. It does not perform static analysis of package source code or ASTs.
  • Install Scripts: Does not analyze preinstall or postinstall shell script contents.
  • Complementary Tool: Designed as an initial defense perimeter to block hallucinated packages before package managers download them. It complements, but does not replace, CVE scanners such as npm audit.

License

MIT © Slopguard Contributors