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

@shivam-sharma/codeguardian

v2.4.2

Published

CLI to scan repos for sensitive secrets before pushing

Readme

Lightweight CLI to scan repositories for accidentally committed secrets (API keys, tokens, private keys). This short guide starts with how to use CodeGuardian in your project, how to integrate it into CI, and then explains the feature and configuration.

How developers use CodeGuardian.


Installation (two quick ways):

  • Run directly with npx (no install required):
npx @shivam-sharma/codeguardian
  • Install as a dev dependency (recommended for team projects):
npm install --save-dev @shivam-sharma/codeguardian

Basic commands:

  • Scan entire repository:
npx codeguardian
  • Scan only staged files (fast; good for pre-commit hooks):
npx codeguardian --staged

Default config:

If no config is provided, CodeGuardian uses built-in rules to scan for common secrets (API keys, tokens, etc.).

Custom config:

You can create a .codeguardianrc.json file to define your own regex rules and files to ignore:

{
  "ignoreFiles": ["package-lock.json", "dist/**"],
  "rules": [
    { "name": "AWS Key", "pattern": "AKIA[0-9A-Z]{16}", "flags": "g" }
  ]
}

Rules are JavaScript regular expressions expressed as strings. flags is optional (for example g). The scanner will try to compile each rule. invalid patterns are skipped.

How to integrate with CI (GitHub Actions).

Use the built-in workflow .github/workflows/codeguardian.yml or add a step to your pipeline to run the scanner in CI mode. Example snippet:

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  scan:
    name: Run CodeGuardian
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - name: Setup Node.js
        uses: actions/setup-node@v5
        with:
          node-version: "22"
          cache: "npm"

      - name: Install dependencies
        run: npm install

      - name: Run CodeGuardian scanner (CI mode)
        run: npx codeguardian --ci

When run with --ci the CLI exits with a non-zero code if any findings are detected — this will fail the job and block merges until issues are resolved.

What CodeGuardian offers


  • Rule-based scanning: configure regex rules (name, pattern, flags) to detect secrets.
  • Built-in detection for AWS, Azure, Google Cloud, Heroku, JWTs, Slack tokens, and more.
  • Scan performance stats: see time taken, memory usage, and file count at the end of each run.
  • ignoreFiles: glob list to skip noisy files (lockfiles, build artifacts).
  • Staged-file scanning: run only what will be committed (fast pre-commit checks).
  • Husky integration: optional pre-commit hooks to block commits locally.
  • CI-ready: --ci mode for failing pipelines on findings.
  • Unused JS/TS module detection: Each scan, CodeGuardian will warn about JavaScript and TypeScript files that are not imported or required by any other file (excluding entry points like index.js, main.ts, etc.). These warnings help you clean up unused code, but do not block CI or fail the scan.

CLI options

  • -c, --config <path> — path to JSON config file (default: .codeguardianrc.json)
  • -s, --staged — only scan staged files
  • --ci — CI mode: exit non-zero when findings exist
  • -v, --verbose — verbose output

Adding scripts to package.json

you can add a script to your package.json to simplify running the scanner:

  "scripts": {
    "scan": "codeguardian"
  }