Get365AI
Sign in
ContextSniper

ContextSniper

Smart task-driven LLM context optimizer

Freemium
Visit github.com
Monthly visits
148.1M
Growth
+1.5%
Rating
5.0 (21)

About ContextSniper

If you've ever pasted your entire src/ folder into Claude or ChatGPT to fix a single bug, you already know the problem: bloated prompts, hallucinated answers, and a $2-per-prompt bill that adds up fast. The root cause is what ContextSniper's README calls the "Lost in the Middle" failure mode — LLMs genuinely struggle to follow instructions buried inside 200,000-token context windows. Most code context tools are dump trucks. They grab everything and hope the model figures it out.

ContextSniper takes the opposite approach. You give it a plain-language task — say, "fix auth middleware" — and it uses a BM25-inspired ranking algorithm combined with AST dependency graph traversal to identify the 5–10 files that actually matter. It doesn't just score files in isolation either: if a file is relevant, its imports and require'd dependencies get a relevance boost too, so you don't miss the utility that your middleware calls three layers deep.

The other detail worth highlighting: it's 100% local. All AST parsing and token scoring runs on your machine. No code leaves your environment, which matters if you're working on a proprietary codebase. It's a CLI tool you can run instantly via npx, it scans hundreds of files in milliseconds, and it includes a watch mode that updates your clipboard automatically as you edit. For developers who prompt LLMs dozens of times a day, that's a meaningful workflow change — not a gimmick.

Key features

BM25-Inspired Task-Aware Ranking

You describe your task in plain text and ContextSniper uses BM25 scoring to find files semantically related to that specific task, rather than blindly including everything in your src/ directory.

AST Dependency Graph Traversal

The tool traces import and require statements across your codebase so that when a file scores as relevant, its direct dependencies automatically receive a relevance boost — catching the files you'd otherwise miss.

Graceful Token-Budget Degradation

When a file is relevant but too large to fit inside your token budget, ContextSniper trims it down to method and class signatures (e.g., export function login(user) { /* ... */ }) rather than dropping it entirely.

100% Local Execution

All parsing, scoring, and context assembly happens on your machine — no API calls, no cloud processing, and no risk of your proprietary code being sent to a third-party server.

Watch Mode with Clipboard Sync

A live watch mode monitors your codebase as you code and automatically updates your clipboard with the latest relevant context, so your next LLM prompt is always current without any manual re-runs.

Instant npx Execution

You can run ContextSniper immediately via npx context-sniper without a global install, which means zero setup friction for trying it on a new project.

Best for

  • solo developers who prompt Claude or ChatGPT multiple times per day
  • engineers working on large codebases where full-context dumps hit token limits
  • teams with proprietary code that can't be sent to external services
  • anyone trying to cut LLM API costs by reducing prompt token counts

Skip if

  • skip this if you need IDE integration — it's a CLI tool only, with no VS Code extension or GUI mentioned
  • skip this if your project uses languages without solid AST support in the current implementation, as language coverage isn't documented
  • skip this if you need team-level sharing or cloud-synced context — everything is local and single-machine

Pros & cons

Pros

  • The BM25 + dependency graph combination is a genuinely smarter selection strategy than simple keyword matching or whole-directory dumps
  • Fully local execution means it's safe for proprietary or client codebases without any policy review
  • Graceful degradation to method signatures preserves structural context even when a file is too large to include in full
  • Watch mode with automatic clipboard sync removes the manual step of re-running the tool every time you edit a file
  • npx execution means you can test it on a project in under a minute with no install required

Cons

  • Only 1 GitHub star and 6 commits at time of writing — this is very early-stage software with minimal community validation
  • npm global install is listed as "coming soon", meaning the distribution story isn't finished yet
  • No documentation beyond the README — supported languages, edge cases, and configuration options are largely undocumented
  • No test suite or CI visible in the repository, which raises questions about reliability on complex dependency graphs

Frequently asked questions

Does ContextSniper send my code to any external server?

No — the README explicitly states it's 100% local. All AST parsing and BM25 token scoring happens on your machine, so nothing is transmitted to OpenAI, Anthropic, or any other service.

How many files does ContextSniper typically select for a given task?

The README targets 5–10 files per task, which is the core premise: replacing a 200,000-token full-codebase dump with a focused, budget-constrained context.

What happens if a relevant file is too large for my token budget?

Instead of dropping the file, ContextSniper trims it to its method and class signatures — for example, export function login(user) { /* ... */ } — so the model still sees the structure without the full implementation.

How does it compare to just using ChatGPT's file upload feature?

ChatGPT's upload drops the full file contents into context with no filtering, which is exactly the "dump truck" approach ContextSniper is designed to replace; ContextSniper's BM25 ranking and dependency traversal mean you're sending the model a fraction of the tokens for the same task.

Do I need to install anything to try it?

You can run it instantly with npx context-sniper — no global install needed, though a global npm install option is listed as coming soon.

How ContextSniper compares

ContextSniper vs ChatGPT file upload

ChatGPT's native file upload dumps full file contents with no relevance filtering, which is the exact pattern ContextSniper exists to fix — you'll burn far more tokens per prompt without the BM25 selection layer.

ContextSniper vs Repomix

Repomix also packages codebases for LLM prompts but focuses on formatting and concatenation rather than task-aware ranking, so it doesn't solve the token-budget or "lost in the middle" problem the way ContextSniper does.

ContextSniper vs GitHub Copilot

Copilot handles context selection automatically inside your IDE, which is more convenient for inline completions, but it's a $10–$19/month subscription and doesn't give you the explicit, inspectable context output that ContextSniper produces for one-shot LLM prompts.

Reviews

Sign in to leave a review.

No reviews yet — be the first.