2026-11-27 16:21 UTC

Context Mode routes coding-agent data through local sandboxing and searchable memory

state: expiredheat: lowuncertainty: mediumrelevance: mediumcoding-agents context-managementmksglu

What is this?

Context Mode is a source-available MCP server and set of integrations for coding agents, maintained by GitHub user mksglu. Its repository documents tools that process large tool outputs outside the conversation and return selected results, SQLite/FTS5 indexing and retrieval for session continuity, and hooks that route tool use on supported platforms. It is installable across numerous coding-agent clients, though capabilities differ: some offer MCP tools only, while others support hooks and compaction recovery. The Hacker News item links to the project; the supplied web results also point to the repository and secondary coverage, but do not provide independent testing or adoption evidence. The project claims up to 98% context savings in its own scenarios; those figures are not independently verified. Its README describes the license as Elastic License 2.0, so “open-source” in the case description should be read cautiously as source-available, not necessarily OSI-approved open source.

Why it matters

The practical idea is to change what an agent sends to the model: run analysis on bulky logs, files, or web results locally, then pass back only relevant snippets, while keeping searchable records to recover work after compaction. If it works reliably, this could stretch limited context windows and reduce wasted token use in long coding sessions without requiring a larger model. Its broad client support may make the approach accessible beyond one vendor’s agent. The size of the claimed savings and the quality of continuity remain project-reported, and hooks vary by platform.

Current assessment

Newly surfaced here via a Hacker News post linking to mksglu/context-mode; the supplied repository page documents an installable MCP server and platform-specific plugins/hooks, not a new model or a confirmed enterprise deployment. The described mechanisms are sandboxed execution that returns selected output, local SQLite FTS5 indexing with BM25 retrieval, and hooks that capture events and restore a compact session snapshot where supported. The README gives project-authored examples and claims 315 KB of raw output can become 5.4 KB, with up to 98% savings; treat these as claims from selected scenarios, not independently validated benchmarks or guaranteed end-to-end savings. It also claims local storage and no telemetry, but no independent privacy or security audit is supplied. Compatibility is not uniform: some clients lack hooks or session restoration, and some integrations depend on gated or incomplete upstream features. The project is described as ELv2 source-available, not clearly OSI-approved open source. Secondary search results show coverage in September and October 2026, so the November 1, 2026 post does not establish that the project itself launched then. Useful follow-up: test savings and task quality on representative coding workflows, inspect security boundaries, confirm active maintenance and adoption, and track improvements to client hook support.

Measured heat

no measured readings yet — the hourly heat pass fills this in

How the heat travelled

02-25 13:00⭐ origin echo-reconstructedThe original project announcement is Mert Köseoğlu’s own post, “Stop Burning Your Context Window — We Built Context Mode.” It says Context M
Mert Köseoğlu on blog (echo) · attributed from hn.story.50324789
—
11-01 11:56first on hacker news · published · +5974.9hContext Mode – An Open-Source MCP Server That Reduces AI Coding Context Usage
Moon_Y
—
11-01 11:56amplified on hacker news 👑hn.story.50324789
Moon_Y
peak 1 · 0 comments · 105% of case engagement
11-01 12:29our radar first saw it · +5975.5hdiscovery anchor: hn.story.50324789—

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnContext Mode – An Open-Source MCP Server That Reduces AI Coding Context Usage
Retrieved article excerpt

Open article · Retrieved 2026-11-01T12:30:21.292123+00:00

# Context Mode

**The other half of the context problem.**

[users](https://www.npmjs.com/package/context-mode) [npm](https://www.npmjs.com/package/context-mode) [marketplace](https://github.com/mksglu/context-mode) [GitHub stars](https://github.com/mksglu/context-mode/stargazers) [GitHub forks](https://github.com/mksglu/context-mode/network/members) [Last commit](https://github.com/mksglu/context-mode/commits) [License: ELv2](https://github.com/mksglu/context-mode/blob/main/LICENSE)
[Discord](https://discord.gg/DCN9jUgN5v)
[Hacker News #1](https://news.ycombinator.com/item?id=47193064)

Used across teams at
  
  
[Microsoft](https://github.com/mksglu/context-mode)
[Google](https://github.com/mksglu/context-mode)
[Meta](https://github.com/mksglu/context-mode)
[Amazon](https://github.com/mksglu/context-mode)
[IBM](https://github.com/mksglu/context-mode)
[NVIDIA](https://github.com/mksglu/context-mode)
[ByteDance](https://github.com/mksglu/context-mode)
[Stripe](https://github.com/mksglu/context-mode)
[Datadog](https://github.com/mksglu/context-mode)
[Salesforce](https://github.com/mksglu/context-mode)
[GitHub](https://github.com/mksglu/context-mode)
[Red Hat](https://github.com/mksglu/context-mode)
[Supabase](https://github.com/mksglu/context-mode)
[Canva](https://github.com/mksglu/context-mode)
[Notion](https://github.com/mksglu/context-mode)
[Hasura](https://github.com/mksglu/context-mode)
[Framer](https://github.com/mksglu/context-mode)
[Cursor](https://github.com/mksglu/context-mode)

## The Problem

Every MCP tool call dumps raw data into your context window. A Playwright snapshot costs 56 KB. Twenty GitHub issues cost 59 KB. One access log — 45 KB. After 30 minutes, 40% of your context is gone. And when the agent compacts the conversation to free space, it forgets which files it was editing, what tasks are in progress, and what you last asked for. On top of that, the agent wastes output tokens on filler, pleasantries, and verbose explanations — burning context from both sides.

### How Context Mode Solves It

Context Mode is an MCP server that solves all four sides of this problem:

1. **Context Saving** — Sandbox tools keep raw data out of the context window. 315 KB becomes 5.4 KB. 98% reduction.
2. **Session Continuity** — Every file edit, git operation, task, error, and user decision is tracked in SQLite. When the conversation compacts, context-mode doesn't dump this data back into context — it indexes events into FTS5 and retrieves only what's relevant via BM25 search. The model picks up exactly where you left off. If you don't `--continue`, previous session data is deleted immediately — a fresh session means a clean slate.
3. **Think in Code** — The LLM should program the analysis, not compute it. Instead of reading 50 files into context to count functions, the agent writes a script that does the counting and `console.log()`s only the result. One script replaces ten tool calls and saves 100x context. This is a mandatory paradigm across all 17 supported clients, plus the OpenClaw gateway integration: stop treating the LLM as a data processor, treat it as a code generator.

   ```
   // Before: 47 × Read() = 700 KB.  After: 1 × ctx_execute() = 3.6 KB.
   ctx_execute("javascript", `
     const files = fs.readdirSync('src').filter(f => f.endsWith('.ts'));
     files.forEach(f => console.log(f + ': ' + fs.readFileSync('src/'+f,'utf8').split('\\n').length + ' lines'));
   `);
   ```
4. **No prose-style enforcement** — context-mode keeps raw data out of context but never dictates how the model writes its final answer. Brevity, completeness, formatting — your model's call (or yours via your own `CLAUDE.md` / `AGENTS.md`). Aggressive brevity prompts have been shown to degrade coding/reasoning benchmarks ([Moonshot AI on `kimi-k2.5`](https://github.com/anomalyco/opencode/issues/20258)) — the routing block stays focused on *where data goes*, not on *how the model talks*.

[Watch context-mode demo on YouTube](https://www.youtube.com/watch?v=QUHrntlfPo4)

[Watch on YouTube](https://www.youtube.com/watch?v=QUHrntlfPo4)

## Install

Platforms are grouped by install complexity. Hook-capable platforms get automatic routing enforcement. Non-hook platforms need a one-time routing file copy.

**Claude Code** — plugin marketplace, fully automatic

**Prerequisites:** Claude Code v1.0.33+ (`claude --version`). If `/plugin` is not recognized, update first: `brew upgrade claude-code` or `npm update -g @anthropic-ai/claude-code`.

**Install:**

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

Restart Claude Code (or run `/reload-plugins`).

**Verify:**

```
/context-mode:ctx-doctor
```

All checks should show `[x]`. The doctor validates runtimes, hooks, FTS5, and plugin registration.

**Routing:** Automatic. The SessionStart hook injects routing instructions at runtime — no file is written to your project. The plugin registers all hooks (PreToolUse, PostToolUse, UserPromptSubmit, PreCompact, SessionStart, Stop) and 11 MCP tools — six sandbox tools (`ctx_batch_execute`, `ctx_execute`, `ctx_execute_file`, `ctx_index`, `ctx_search`, `ctx_fetch_and_index`) plus five meta-tools (`ctx_stats`, `ctx_doctor`, `ctx_upgrade`, `ctx_purge`, `ctx_insight`).

| Slash Command | What it does |
| --- | --- |
| `/context-mode:ctx-stats` | Context savings — per-tool breakdown, tokens consumed, savings ratio. |
| `/context-mode:ctx-doctor` | Diagnostics — runtimes, hooks, FTS5, plugin registration, versions. |
| `/context-mode:ctx-index` | Index a local file or directory into the persistent FTS5 knowledge base. |
| `/context-mode:ctx-search` | Search previously indexed content. |
| `/context-mode:ctx-upgrade` | Pull latest, rebuild, migrate cache, fix hooks. |
| `/context-mode:ctx-purge` | Permanently delete all indexed content from the knowledge base. |
| `/context-mode:ctx-insight` | Opens the hosted Insight dashboard ([context-mode.com/insight](https://context-mode.com/insight)) in your browser — org analytics for AI-assisted engineering teams. |

> **Note:** Slash commands are a Claude Code plugin feature. On other platforms, type `ctx stats`, `ctx doctor`, `ctx index`, `ctx search`, `ctx upgrade`, or `ctx insight` in the chat — the model calls the MCP tool automatically. See [Utility Commands](https://github.com/mksglu/context-mode#utility-commands).

**Status line (optional):** Claude Code's plugin manifest cannot declare a status line, so this is a one-time manual edit to `~/.claude/settings.json`:

```
{
  "statusLine": {
    "type": "command",
    "command": "context-mode statusline"
  }
}
```

After saving, restart Claude Code. The bar shows `$ saved this session · $ saved across sessions · % efficient` so you can see savings accumulate in real time. The wiring is path-free — `context-mode statusline` resolves through the bundled CLI regardless of where the plugin cache lives.

Alternative — MCP-only install (no hooks or slash commands)

```
claude mcp add context-mode -- npx -y context-mode
```

This gives you all 11 MCP tools without automatic routing. The model can still use them — it just won't be nudged to prefer them over raw Bash/Read/WebFetch. Good for trying it out before committing to the full plugin.


**Gemini CLI** — one config file, hooks included

**Prerequisites:** Node.js >= 22.5 (or Bun), Gemini CLI installed.

**Install:**

1. Install context-mode globally:

   ```
   npm install -g context-mode
   ```
2. Add the following to `~/.gemini/settings.json`. This single file registers the MCP server and all four hooks:

   ```
   {
     "mcpServers": {
       "context-mode": {
         "command": "context-mode"
       }
     },
     "hooks": {
       "BeforeTool": [
         {
           "matcher": "run_shell_command|read_file|read_many_files|grep_search|search_file_content|web_fetch|activate_skill|mcp__plugin_context-mode|mcp__context-mode|mcp__(?!.*context-mode)",
           "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli beforetool" }]
         }
       ],
       "AfterTool": [
         {
           "matcher": "",
           "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli aftertool" }]
         }
       ],
       "PreCompress": [
         {
           "matcher": "",
           "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli precompress" }]
         }
       ],
       "SessionStart": [
         {
           "matcher": "",
           "hooks": [{ "type": "command", "command": "context-mode hook gemini-cli sessionstart" }]
         }
       ]
     }
   }
   ```
3. Restart Gemini CLI.

**Verify:**

```
/mcp list
```

You should see `context-mode: ... - Connected`.

**Routing:** Automatic via SessionStart hook. Optionally copy routing instructions for full model awareness:

```
cp node_modules/context-mode/configs/gemini-cli/GEMINI.md ./GEMINI.md
```

> **Why the BeforeTool matcher?** It targets only tools that produce large output (`run_shell_command`, `read_file`, `read_many_files`, `grep_search`, `search_file_content`, `web_fetch`, `activate_skill`) plus context-mode's own tools (`mcp__plugin_context-mode`). This avoids unnecessary hook overhead on lightweight tools while intercepting every tool that could flood your context window.

Full config reference: [`configs/gemini-cli/settings.json`](https://github.com/mksglu/context-mode/blob/main/configs/gemini-cli/settings.json)


**VS Code Copilot** — hooks with SessionStart

**Prerequisites:** Node.js >= 22.5 (or Bun), VS Code with Copilot Chat v0.32+.

**Install:**

1. Install context-mode globally:

   ```
   npm install -g context-mode
   ```
2. Create `.vscode/mcp.json` in your project root:

   ```
   {
     "servers": {
       "context-mode": {
         "command": "context-mode"
       }
     }
   }
   ```
3. Create `.github/hooks/context-mode.json`:

   ```
   {
     "hooks": {
       "PreToolUse": [
         { "type": "command", "command": "context-mode hook vscode-copilot pretooluse" }
       ],
       "PostToolUse": [
         { "type": "command", "command": "context-mode hook vscode-copilot posttooluse" }
       ],
       "SessionStart": [
         { "type": "command", "command": "context-mode hook vscode-copilot sessionstart" }
       ]
     }
   }
   ```
4. Restart VS Code.

**Verify:** Open Copilot Chat and type `ctx stats`. Context-mode tools should appear and respond.

**Routing:** Automatic via SessionStart hook. Optionally copy routing instructions for full model awareness:

```
cp node_modules/context-mode/configs/vscode-copilot/copilot-instructions.md .github/copilot-instructions.md
```

Full hook config including PreCompact: [`configs/vscode-copilot/hooks.json`](https://github.com/mksglu/context-mode/blob/main/configs/vscode-copilot/hooks.json)


**JetBrains Copilot** — hooks with SessionStart

**Prerequisites:** Node.js >= 22.5 (or Bun), JetBrains IDE with GitHub Copilot plugin v1.5.57+.

**Install:**

1. Install context-mode globally:

   ```
   npm install -g context-mode
   ```
2. Add MCP server via Settings UI: **Settings > Tools > AI Assistant > Model Context Protocol (MCP) > Add Server**:

   - **Name:** `context-mode`
   - **Command:** `context-mode`
3. Create `.github/hooks/context-mode.json`:

   ```
   {
     "hooks": {
       "PreToolUse": [
         { "type": "command", "command": "context-mode hook jetbrains-copilot pretooluse" }
       ],
       "PostToolUse": [
         { "type": "command", "command": "context-mode hook jetbrains-copilot posttooluse" }
       ],
       "SessionStart": [
         { "type": "command", "command": "context-mode hook jetbrains-copilot sessionstart" }
       ]
     }
   }
   ```
4. Restart the JetBrains IDE.

**Verify:** Open Copilot Chat and type `ctx stats`. Context-mode tools should appear and respond.

**Routing:** Automatic via SessionStart hook. Optionally copy routing instructions for full model awareness:

```
cp node_modules/context-mode/configs/je
Moon_Y10
🟧 echo.blog ⭐The original project announcement is Mert Köseoğlu’s own post, “Stop Burning Your Context Window — We Built Context Mode.” It says Context MMert Köseoğlu——

Interpretation history

Decision trace