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

contextshield

v1.0.0

Published

Before you paste code into an LLM, contextshield finds secrets, huge noise, broken context order, and outputs the optimal prompt pack.

Readme

🛡️ contextshield

Before you paste code into an LLM, contextshield finds secrets, filters noise, orders context, and outputs the optimal prompt pack.

npm version License: MIT

Every time you paste your repository code into Cursor, Copilot, ChatGPT, Gemini, or Claude, you are wasting money, hitting token limits, and risking leaking your API keys.

contextshield makes your repo LLM-ready in one command. It recursively scans your workspace, applies robust .gitignore and default exclusions (lockfiles, node_modules, binaries, build dirs, maps), runs a high-fidelity secret scanner, packs files intelligently by priority, and writes an optimized prompt pack file (with all secrets masked for safety!).


✨ Features

  • 🚀 Zero Setup: Run it instantly using npx or install globally.
  • 🔒 Zero Leak Promise: High-fidelity detection of OpenAI keys, AWS access keys, Stripe keys, GitHub PATs, private keys, and high-entropy database credentials. Any detected secret is automatically masked in the output pack.
  • 🧹 Auto-Junk Exclusion: Filters out lockfiles, node_modules/, binary/image files, build folders (dist/, build/), sourcemaps, IDE configs, and logs.
  • 📊 Token Budgeting & Truncation: Specify your target token budget (e.g. 8k, 32k, 100k). If the repo exceeds it, contextshield prioritizes critical configurations and source code, truncating files at the margin to fit perfectly.
  • 🌲 Dynamic Tree Generator: Includes a clean, folder-first ASCII directory tree of the packed context at the top of your prompt pack.
  • 🎨 Rich CLI Dashboard: Beautiful terminal progress indicators, progress bars, and alerts.

⚡️ Quick Start in 3 Commands

1. Run it instantly (Zero Install)

Scan your current directory with a default 100k token budget:

npx contextshield .

2. Customize the Token Budget

Set a specific budget (e.g., 32k tokens for Claude 3.5 Sonnet context, or 8k for smaller windows):

npx contextshield . -b 32k

3. Specify Custom Output File

Output your prompt pack to a custom path:

npx contextshield . -b 100k -o my-prompt-pack.md

📊 Benchmarks & Token Savings

By filtering junk and lockfiles, contextshield routinely saves 95%+ on token costs, ensuring you stay well within LLM context limits.

| Project Size / Type | Raw Codebase Size | Packed Prompt Size | Token Savings | Secrets Caught | | :--- | :---: | :---: | :---: | :---: | | Vite / React SPA | 342,000 tokens | 12,400 tokens | 96.3% | 1 (mock .env key) | | Express.js API | 185,000 tokens | 8,200 tokens | 95.5% | 2 (leaked API keys) | | Next.js Fullstack app | 2,150,000 tokens | 38,000 tokens | 98.2% | 0 | | Fastify Plugin | 98,000 tokens | 5,100 tokens | 94.8% | 0 |


🎪 Interactive Examples / Playground

contextshield ships with 10 pre-configured playgrounds demonstrating how the CLI solves different repo issues. To set them up, clone the repo and run:

npm run setup-examples

This creates the following playgrounds in the ./examples/ directory:

  1. 01-secrets-leak: Contains a simulated OpenAI Key and AWS credential to demonstrate the scanner and automated masking.
  2. 02-token-bloat-lockfiles: Contains a massive mock lockfile. Watch contextshield reduce token sizes by 99%.
  3. 03-token-bloat-build-folder: Contains huge transpiled javascript bundles and sourcemaps in dist/ showing how they are ignored.
  4. 04-broken-context-order-tests: Demonstrates context priority sorting (configs & source code are prioritized over test files).
  5. 05-binary-bloat: Contains image files to show how they are filtered using MIME types and content inspection.
  6. 06-custom-gitignore: Demonstrates that .gitignore rules (like custom log/temp files) are fully respected.
  7. 07-deep-nesting-tree: Shows how the directory structure tree is generated for deeply nested components.
  8. 08-truncate-critical: Shows how contextshield truncates long files at the margin to fit tiny budgets (e.g. npx contextshield examples/08-truncate-critical -b 200).
  9. 09-clean-prompt-pack: A standard clean playground template.
  10. 10-multi-language: Shows syntax highlighting mapping in Python, Rust, Go, CSS, and HTML file blocks.

🛠 Usage Options

Usage: contextshield [options] [dir]

Before you paste code into an LLM, contextshield finds secrets, huge noise, broken context order, and outputs the optimal prompt pack.

Arguments:
  dir                    directory to scan (default: ".")

Options:
  -b, --budget <tokens>  token budget (e.g. 8k, 32k, 100k) (default: "100k")
  -o, --output <file>    output file name (default: "contextshield-prompt.md")
  --max-size <size>      max individual file size limit (e.g. 500kb, 1mb) (default: "1mb")
  --no-secrets           skip checking for secrets
  --secrets-only         only scan for secrets and print warnings, do not generate prompt pack
  -h, --help             display help for command

📜 License

MIT License. Feel free to use and distribute.