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

context-sniper

v0.1.0

Published

AI-powered smart context builder — snipes only the relevant code for your LLM prompt, not the whole repo.

Downloads

166

Readme


🚀 The Problem: "Lost in the Middle"

Standard context tools act like dump trucks: they take your entire src/ folder and throw 200,000 tokens into your LLM. The result? LLMs hallucinate, lose focus on instructions hidden in the middle of long contexts, and cost you $2 per prompt.

ContextSniper acts like a sniper rifle. You give it a target task ("fix auth middleware"), and it selectively extracts only the 5-10 files that matter, keeping your context under a strict token budget.

✨ Features

  • 🎯 Task-Aware Selection: Uses BM25 scoring to find files semantically related to your task.
  • 🕸️ Dependency Graph Boost: Automatically traces import and require statements. If a file is relevant, its dependencies get a relevance boost.
  • 📉 Graceful Degradation: If a file doesn't fit in your token budget, it isn't just dropped. ContextSniper trims it down to its method and class signatures (e.g., export function login(user) { /* ... */ }).
  • 🔒 100% Local & Private: No code ever leaves your machine. All AST parsing and token scoring happens locally.
  • Lightning Fast: Scans and scores hundreds of files in milliseconds.
  • 🔄 Watch Mode: Live context sync that updates your clipboard automatically as you code.

📦 Installation

# Global installation (coming soon to npm)
# npm install -g context-sniper

# Or run instantly via npx
npx context-sniper "your task"

💻 Usage

1. Basic Task Search

Provide a description of what you are working on, and ContextSniper will find the relevant files.

ctx-snipe "add auth via Supabase" --budget 15000

2. Explain Mode (Transparency)

Analyze why certain files were selected without generating the full context payload.

ctx-snipe "fix auth middleware" --explain

Output includes file scores, exact token counts, and matching reasons (e.g., "BM25 match", "Imported by high-score file").

3. Presets for Common Tasks

Use predefined keywords to quickly grab specific domains of your app.

ctx-snipe --preset database --budget 8000 --copy

Available presets: auth, api, database, styling.

4. Diff-Only Mode (PR Reviews)

Packs only the files that have uncommitted changes or are staged in Git. Perfect for asking an LLM to review your current work.

ctx-snipe --diff-only --copy

5. Watch Mode (Live Sync)

Watch for file changes and automatically recalculate and copy context to clipboard as you code.

ctx-snipe "refactor checkout" --watch --copy

🛠️ Configuration & Options

| Option | Description | Default | | :--- | :--- | :--- | | -t, --target <task> | Target task description | Required | | -b, --budget <tokens>| Maximum token limit for the context | 30000 | | --preset <type> | Predefined task preset | undefined | | -o, --output <file> | Custom output file path | AI_CONTEXT.md | | --copy | Automatically copy output to clipboard | false | | --explain | Show scoring breakdown instead of packing | false | | --diff-only | Only include git modified/staged files | false | | --watch | Live reload context on file save | false | | --no-tree | Exclude project tree from context | false | | --no-git-diff | Exclude uncommitted diff from context | false |

📄 License

MIT © EGN Labs