Get365AI
Sign in
ContextSniper

ContextSniper

Smart task-driven LLM context optimizer

Open source
Visit github.com
Monthly visits
148.1M
Growth
+1.5%
Rating
4.2 (73)

About ContextSniper

If you've ever pasted your entire `src/` folder into Claude or ChatGPT and watched it hallucinate half the answer, you already know the problem ContextSniper is solving. Most developers default to a "dump everything" approach when prompting LLMs with code questions — and the result is bloated contexts, confused models, and prompts that can cost $2 a pop when you're hitting GPT-4 or Claude Opus.

ContextSniper is a 100% local CLI tool that takes a different approach. You give it a plain-English task — say, "fix auth middleware" — and it uses a BM25-inspired ranking algorithm combined with AST dependency graph traversal to pull out only the 5–10 files that actually matter. Files that don't fit your token budget aren't silently dropped; they're trimmed down to their method and class signatures (e.g., `export function login(user) { /* ... */ }`), so the LLM still understands the shape of your code without burning tokens on implementation details.

It's an open-source project on GitHub with zero stars at time of writing, which tells you it's early — but the core mechanic is genuinely well-thought-out. All AST parsing and scoring happens locally, nothing leaves your machine, and it runs fast enough to support a Watch Mode that updates your clipboard in real time as you code. If you're spending real money on LLM API calls and tired of context noise degrading your results, this is worth 10 minutes to try.

Key features

BM25-Inspired Task-Aware File Ranking

You provide a task description in plain English, and ContextSniper uses BM25 scoring to identify files semantically related to that specific task — rather than blindly including everything under `src/`.

AST Dependency Graph Traversal

When a file scores as relevant, ContextSniper automatically traces its `import` and `require` statements and applies a relevance boost to its dependencies, so you don't miss the files your target code actually depends on.

Graceful Signature Degradation

If a file is relevant but too large to fit within your token budget, ContextSniper trims it to method and class signatures rather than dropping it entirely, preserving structural context without the token cost.

100% Local Execution

All AST parsing, BM25 scoring, and dependency resolution happen on your machine — no code is sent to any external server, which matters if you're working on proprietary or sensitive codebases.

Watch Mode with Clipboard Sync

ContextSniper's Watch Mode monitors your codebase in real time and automatically updates your clipboard with fresh, re-ranked context as you make changes, so your next LLM prompt is always current.

Fast Scanning Across Large Codebases

According to the project README, ContextSniper scans and scores hundreds of files in milliseconds, making it practical to run before every prompt without adding noticeable friction to your workflow.

Best for

  • developers paying per-token on Claude or GPT-4 API calls who want to cut prompt costs
  • solo engineers working in mid-to-large codebases where "paste everything" stops being viable
  • teams with proprietary code who can't use cloud-based context tools
  • anyone debugging specific modules and tired of LLMs losing focus in 200k-token dumps

Skip if

  • skip this if you need IDE integration — it's a CLI tool only, with no VS Code or JetBrains plugin mentioned
  • skip this if you want a stable, documented tool — it has 1 GitHub star and 6 commits, meaning it's effectively alpha software
  • skip this if you work in languages other than JavaScript/TypeScript — AST parsing is JS/TS-specific based on the repo structure

Pros & cons

Pros

  • The BM25 + dependency graph combination is a smarter approach than simple keyword matching or file-size cutoffs
  • Signature degradation means you never get a silent context gap — you always know what's in scope even if it's trimmed
  • Fully local execution is a genuine differentiator for anyone working on private or regulated codebases
  • Watch Mode + clipboard sync removes manual copy-paste friction from the prompt-iteration loop
  • Available instantly via `npx context-sniper` with no global install required

Cons

  • Only 1 GitHub star and 6 commits — this is pre-community, pre-battle-tested software with no track record
  • No npm package published yet; the README notes global install is "coming soon", so `npx` is the only current path
  • No documentation beyond the README — edge cases, configuration options, and supported file types aren't explained
  • Language support appears limited to JavaScript/TypeScript based on the repo's `tsconfig.json` and package structure — Python, Go, or Ruby codebases aren't mentioned

Frequently asked questions

Does ContextSniper send my code to any external API?

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

How is this different from just using ChatGPT's file upload or Claude's Project feature?

Both ChatGPT and Claude still ingest everything you give them; they don't pre-filter for relevance before billing you tokens. ContextSniper cuts the context down to 5–10 files before it ever reaches the LLM, which can reduce prompt cost from $2 to a fraction of that on GPT-4 or Claude Opus.

What does 'graceful degradation' actually mean in practice?

If a relevant file is too large to fit your token budget, ContextSniper strips it to its exported function and class signatures — something like `export function login(user) { /* ... */ }` — so the LLM still understands the file's interface without consuming tokens on the full implementation.

Does it work with monorepos or just single-project directories?

The README doesn't address monorepos specifically, and with only 6 commits in the repo, this likely hasn't been tested at that scale yet — treat monorepo support as unconfirmed.

What programming languages does ContextSniper support?

Based on the repository contents — `tsconfig.json`, `package.json`, and a TypeScript test file — it's built for JavaScript and TypeScript codebases. Support for Python, Go, or other languages isn't mentioned anywhere in the current README.

How ContextSniper compares

ContextSniper vs ChatGPT file upload

ChatGPT's file upload dumps everything into context without any relevance filtering, meaning you pay for tokens on files that don't matter — exactly the problem ContextSniper is designed to solve.

ContextSniper vs Repomix

Repomix also packages codebases for LLM prompts, but it focuses on formatting and bundling rather than task-aware ranking, so it doesn't reduce token count based on what you're actually trying to do.

ContextSniper vs GitHub Copilot

Copilot handles context selection automatically inside your IDE, which is more convenient, but it's a $10–$19/month subscription and sends your code to GitHub's servers — ContextSniper is free and local.

Reviews

Sign in to leave a review.

No reviews yet — be the first.