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 🙏

© 2025 – Pkg Stats / Ryan Hefner

knip-guard

v1.0.0

Published

Baseline / no-new-issues guard for Knip

Readme

knip-guard

Guard your codebase from new dead code issues detected by Knip.

knip-guard adds a minimal baseline/snapshot mechanism so large or legacy repositories can adopt Knip without blocking progress or hiding existing issues from reports, but rather as a mechanism to accept and progressively improve and accept new issues if needed, promoting ownership and visibility. You keep all existing issues for now — but no new issues can be introduced.


🚀 Why knip-guard?

Knip is excellent at discovering:

  • unused files
  • unused exports
  • unused dependencies
  • unresolved imports
  • dead enum/class members
  • and more…

But if you already have hundreds of issues, enabling Knip in CI immediately will break every PR.

knip-guard solves this by:

  • creating a baseline (snapshot of current issues)
  • allowing those issues to exist temporarily
  • failing CI only when new issues appear
  • letting teams clean old issues gradually and safely

This is the same model used by tools like SonarQube, ESLint’s --init baseline mode, and static analyzers.


❗ How is this different from Knip’s ignore functionality?

Knip provides an ignore config, but it is not the same thing.

ignore is static

You manually list files/paths/symbols to ignore forever.

Problems:

  • It does not distinguish between old accepted issues and new regressions.
  • It grows stale as code changes.
  • It must be manually curated.
  • If you ignore everything, you lose all value from Knip.

knip-guard is dynamic

It maintains a snapshot of all current issues and blocks only newly introduced ones.

Advantages:

  • Zero manual maintenance.
  • Old issues tolerated; new ones blocked.
  • Ideal for large monorepos full of legacy dead code.
  • Baseline updates are intentional and simple (knip-guard accept).

In short: ignore hides issues. knip-guard prevents regressions.


📦 Installation

npm install --save-dev knip-guard

Usage

Install as a dev dependency:

npm install --save-dev knip-guard

Initialize a baseline (run this once in a clean state):

npx knip-guard init --command "npm run knip"

Check in CI (exit code 1 when new issues are introduced):

npx knip-guard check --command "npm run knip"

Accept new issues (after review) and update baseline:

npx knip-guard accept --command "npm run knip"

CLI options:

  • -b, --baseline Path to baseline file (default: .knip-baseline.json)
  • -r, --report Path to existing Knip JSON report (otherwise run knip)
  • -c, --command Command to run knip (default: "npx knip")
  • -h, --help Show help

Build, test & publish

Build (generate JS + types in dist/):

npm run build

Run tests:

npm test

Prepare/publish:

  • The package has a prepare and prepublishOnly script that runs the build.
  • Before publishing, ensure dist/ contains the compiled files and the CLI (dist/cli.js) includes the shebang line.