Developer tools#MCP#Coding agent

context-mode: stop AI coding agents from eating your context window

MCP server that sandboxes tool output into SQLite and returns only relevant snippets — a claimed 98% context saving on 17 platforms. Note: ELv2 license.

Project facts

GitHub Ecosystem
Repositorygithub.com/mksglu/context-mode
Language
TypeScript
Stars
25,035
Data checked
2026-10-03

Snapshot figures reflect the check date and may change over time.

Heavy users of Claude Code and Cursor know the decay pattern: the model is not getting dumber, its context is getting eaten — a Playwright snapshot costs 56 KB, twenty GitHub issues cost 59 KB, and half an hour later the agent has forgotten which files it was editing. context-mode flips the problem: instead of calling fewer tools, change how tool output enters the context. Raw data stays in a sandbox and a SQLite index; only the most relevant snippets come back on demand. The project hit the Hacker News front page in late February (570 points) and now counts 25,035 stars, written in TypeScript, with commits landing this week. The WeChat account AI开源求索 ran a detailed write-up on October 3.

Core features

  • Sandboxed execution: ctx_execute runs scripts in 12 languages (JS/TS/Python/Shell/Ruby/Go/Rust and more) in an isolated subprocess; gh, aws and kubectl credentials pass through environment variables, and only stdout enters the conversation. The README’s own comparison: counting lines across 47 source files costs about 700 KB with plain Read calls, or 3.6 KB with one script.
  • Index and retrieve: files, pages and docs are chunked into SQLite FTS5 with BM25 ranking, RRF fusion, Porter stemming and trigram substring matching — returning matched snippets, not blunt truncation. ctx_fetch_and_index converts a web page to markdown and indexes it, so raw HTML never enters the conversation.
  • Batched calls: ctx_batch_execute merges multiple commands and queries into one call — 986 KB down to 62 KB per the project’s table — aimed at repo research and bulk audits where tool round-trips pile up.
  • Hook-enforced routing: the plugin registers six hooks (PreToolUse, PostToolUse, PreCompact, SessionStart and more), which is the real answer to subagents that read files and fetch pages recklessly — those calls get forced through the sandbox-and-index path. There are 11 MCP tools in total: six sandbox tools plus five meta-tools (stats, doctor, upgrade, purge, insight).
  • Session snapshots: every file edit, git operation, task, error and user decision lands in SQLite; when the conversation compacts, key events are retrieved from the index and the task continues. Note that without --continue, previous session data is deleted immediately.
  • It does not police the model’s voice: the author explicitly rejects aggressive brevity prompts — citing Moonshot AI’s finding that brevity instructions degrade coding benchmarks — the routing layer only decides where data goes, not how the model writes.

Typical use cases

  • Large refactors: dozens of files across many turns, with session snapshots and index retrieval holding the task state instead of whatever fits in the window.
  • Long debugging chains: logs, stack traces and issues tracked over many round-trips, with raw data staying in the sandbox and only conclusions moving forward.
  • Repo research: counting and pattern-finding goes to scripts the agent writes, so the model programs the analysis instead of acting as a data processor.

Quick start

Two commands in Claude Code’s plugin marketplace (v1.0.33 or newer):

/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode

Restart or run /reload-plugins, then /context-mode:ctx-doctor to verify runtimes, hooks and FTS5 all pass; /context-mode:ctx-stats shows the per-tool savings. An npm package context-mode (currently 1.0.169) covers the other platforms — Cursor, Gemini CLI, VS Code Copilot and more, 17 in total, with install paths that differ by platform.

Summary

Worth installing if you run long tasks with heavy log and source reading; short tasks with few tool calls gain little, and workflows that require verbatim full text are the wrong fit — retrieved snippets are not the full document. Three things on the table: first, this is Elastic License 2.0 — source-available, readable and modifiable, but not OSI open source; you may not offer it to others as a managed service, so read the LICENSE before any commercial integration. Second, the “98% savings” figures are the project’s own benchmarks; we found no independent verification, so treat them as orders of magnitude, not promises. Third, enforcement depends on platform hooks: on hook-less platforms like Zed and Antigravity IDE it degrades to a one-time routing-file copy that the README itself rates at roughly 60% compliance. This manages context allocation, not model capability — the judgment stays yours. For another way to fence in a coding agent, see our earlier entry on reverse-skill: it routes tasks to security methodologies by rule — one governs context, the other governs behavior.