Case study
SnapContext
AI context management for developers
Relevant project context, prepared automatically.
An open-source AI coding assistant that detects the project, selects the relevant files and prepares the context an AI workflow needs — with cloud providers or fully local models.
The problem
An AI assistant can only work with the context it is given.
When I used AI coding assistants on real projects, the bottleneck was rarely the model. It was the context: which files the assistant could see. Hand the model the whole repository and small local models choke on files that do not fit the window; hand it nothing and it guesses.
Curating that list by hand does not scale. Attaching files manually before every request — the way Aider’s /add works — turns each task into a preparation ritual: remember the files, keep the list current, trim it again when the window overflows.
It gets worse with local models. A model running on your own machine often has a context window of a few thousand tokens, so sending whole files fails constantly — precisely the setup where automatic help is worth the most.
SnapContext was created to remove that preparation work: detect the project, find the relevant files and fit them into the context the model actually receives.
One command from project to prepared context.
SnapContext looks at the project the way a developer would: what stack is this, which files could matter for this request, what should the model actually see. The user starts from a task — describe a bug, request a change — and the context is built around it.
The goal is not to hide the model but to make the hand-off precise: relevant files and blocks instead of an unfiltered dump of the repository.
Project
Stack detection
Candidate scan
AI selection
Prepared context
SnapContext is not a model. It prepares and manages context, then hands the work to a provider the user chooses — a cloud API or a local model through Ollama.
How it works
One request, one pipeline. Each stage exists because the next one needs it.
Developer
Describes a task or asks a question.
Project
The working directory is validated as a project root and the stack is detected from marker files: pubspec.yaml, package.json, pyproject.toml, go.mod, Cargo.toml.
Scan
Candidate files are listed — git ls-files when available, otherwise a directory walk — and ranked locally against the request before any model is involved.
Select
The configured AI provider chooses the most relevant files among the top-ranked candidates. A local heuristic mode covers requests without an API key.
Shape
Tokens are estimated, oversized files are reduced to their relevant blocks, and verbose tool output is pruned so the prompt fits the model’s window.
Execute
The ReAct agent works with that context: answering, planning, editing through the built-in editor or Aider, and running the project’s tests in a loop.
The same pipeline sits behind every interface: the CLI, the IDE extensions, the web UI and the messenger gateways.
Architecture
SnapContext sits between the development environment and the AI providers.
Entry points
- CLI
- IDE extensions
- Web / TUI / API
SnapContext core
- Project detection
- Context pipeline
- ReAct agent + planner
- Memory + history
- Permissions + sandbox
AI providers (external)
- Gemini
- Claude
- Ollama
- DeepSeek
- Groq
Execution
- Built-in editor / Aider
- Test loop
- Git
SnapContext is a layer between the developer’s environment and the AI providers. It understands the project, prepares the context, enforces permissions and memory, and delegates generation and execution to the selected provider and editor.
Technical decisions
Decisions that are visible in the way the project behaves.
Context as an explicit pipeline
Detection, scanning, selection and shaping are separate stages instead of one opaque prompt builder.
- Why
- A single prompt that dumps the repository breaks as soon as one file exceeds the window.
- Consequence
- Each stage can degrade independently: without git it walks directories, without tree-sitter it falls back to regex, without an API key it selects with local heuristics.
Heuristics before the model
Files are ranked locally against the request first; only the best candidates reach the selection prompt.
- Why
- The model’s job is choosing among plausible files, not reading the whole tree.
- Consequence
- Selection stays cheap and deterministic, works with local models and without API keys, and its cost does not grow with the size of the repository.
Token-budget context
Every file is measured before it is sent. Oversized files are reduced to their relevant blocks — extracted with tree-sitter when the language is supported — and verbose tool output is pruned to summaries.
- Why
- Local models often have windows of a few thousand tokens; whole files simply do not fit.
- Consequence
- Large codebases remain usable on small local models, and context-overflow errors from providers are detected and handled instead of crashing the run.
An editor of its own, with backups
SnapContext ships a built-in editor — validated writes inside the project, automatic backups — and keeps Aider as an optional alternative.
- Why
- Depending on an external tool for every edit made the base workflow fragile.
- Consequence
- Plans can commit step by step and changes can be undone per step with snapcontext revert.
Autonomy behind permissions
Approved actions persist in a permissions file, risky commands run in a Docker sandbox by default, and background processes without it are rejected.
- Why
- An agent that edits and executes code needs boundaries the user controls.
- Consequence
- Autonomous mode reuses the decisions the user already approved instead of asking again for each step.
What “context” means here
Four different things are called context in an AI workflow. SnapContext treats them as distinct stages.
Source code
Everything in the repository.
Candidate files
The subset the scanner considers relevant to the request.
Selected files
The files the provider chooses for this task.
Relevant blocks
Inside oversized files, the functions and classes that matter.
Model input
The shaped prompt that actually reaches the model.
Only the last stage is visible to the provider.
What SnapContext is
A context layer and an orchestrator: it prepares what the model sees, calls the provider, applies edits through its editor and keeps the memory of the project.
What it is not
It is not a model. Code is generated by the connected provider — Gemini, Claude, a local model through Ollama, or another OpenAI-compatible API.
Provider profiles adapt the prompt per model: cloud models receive fuller instructions, while local models get reduced context to stay inside smaller windows.
Where it runs
One core, several surfaces. All of them drive the same pipeline.
The CLI is the primary surface: snapcontext, snapcontext --chat, --plan, --tui. The installation is pipx or pip, the --init wizard configures the provider, and --demo runs without an API key.
The VS Code extension embeds the web chat in a webview, streams the orchestrator logs to an output channel, and adds an “Add to context” action in the explorer — the visual equivalent of /add.
The JetBrains plugin brings the same actions into IntelliJ IDEA and PyCharm: a Tools menu, a bottom tool window with live output, a settings page, and files added to the context from the project view. It expects the snapcontext CLI to be installed.
- CLI
- VS Code
- JetBrains IDEs
- Web UI
- TUI
- REST API
- Discord
- Telegram
- GitHub
- PyPI
- VS Code Marketplace — link not available yet
- JetBrains Marketplace — link not available yet
The VS Code and JetBrains marketplace listings are not public yet.
Windows, Linux and macOS are supported. Installers exist for all three, including a Windows executable without Python.
Where the project stands
SnapContext is published on PyPI and under active development. The labels below describe today, not the roadmap.
Automatic project detection
Marker files and typical folders identify the stack before anything runs.
In placeRepository scan and candidate ranking
git-aware listing plus local scoring of files against the request, before any model is called.
In placeAI file selection
Provider-backed selection among ranked candidates, with a heuristic local mode.
In placeToken-aware shaping and pruning
Relevant-block extraction for oversized files and proactive pruning of tool output.
In placeReAct agent and planner
Tool-driven reasoning loop, multi-step plans and an autonomous mode with retries.
In placeBuilt-in editor and Aider support
Validated writes with automatic backups, step commits and per-step revert.
In placePermissions and Docker sandbox
Persistent approvals, default-deny sandboxing of risky commands, safe file writes.
In placePersistent memory
Project memory (CLAUDE.md), SQLite history and a proactive curation daemon.
In placeMCP client and plugin marketplace
Built-in database, API and browser tools, plus third-party MCP servers.
In placeGraph RAG and LSP analysis
A code dependency graph and LSP-backed symbols, degrading to regex search when unavailable.
In placeInterfaces and integrations
CLI, TUI, web UI, REST API, VS Code and JetBrains extensions, Discord and Telegram.
In placeTesting and benchmark
A pytest suite with coverage gates, ruff and mypy, and a 50-task editing benchmark verified by AST.
In placeMulti-repository Graph RAG
Cross-repository indexing is a stated direction, not a shipped capability.
In developmentIntel XPU acceleration
Local inference on Intel Arc GPUs exists behind an extra; broader hardware support is experimental.
In developmentMonolith decomposition
The orchestrator and the messenger gateways are still being extracted into modules.
In developmentEditing benchmark, deep mode
The full-agent benchmark with a local model is planned; the light engine benchmark is the one measured.
In development
The benchmark measures the editing engine on synthetic tasks with AST verification, not general coding quality, and says so in the repository.
What building it taught me
Building SnapContext taught me that context is an engineering problem before it is an AI problem.
The original friction — attaching files to an assistant by hand — turned into work on project detection, repository scanning, token budgets, parser integration, safe file writes, sandboxing and permission systems. An assistant that edits code on its own is only trustworthy when everything around the model is explicit: what it may read, what it may run, and what happens when a component is missing.
- developer tooling
- IDE extension development
- repository analysis
- token budgets
- parser integration
- safe file writes
- sandboxing
- permission systems
- graceful degradation
- open-source maintenance
The hard part of an AI coding assistant is not the model — it is deciding what the model sees.
Built to remove friction from AI-assisted development.
SnapContext started as a simple annoyance: preparing context by hand, file by file, before every request. The answer was a tool that reads the project the way a developer does — and hands the model only what matters.
Back to selected work