Your agent's context window doesn't fill up with your code. It fills up with junk: log files, browser snapshots, API responses, test output. Context Mode keeps that raw data in a sandbox and only lets the answer through. It also remembers what you were doing when the conversation gets compacted.
Want the short version? Read What It Is, then go straight to Install. It's two commands in Claude Code. Not sure it's worth it? Is It For You takes thirty seconds.
Context Mode is an MCP server plus a set of hooks. When your agent wants to read a 45 KB log file or pull a 56 KB Playwright snapshot, the hooks route that work into a sandbox. The sandbox runs it, and only the result comes back: a few hundred bytes instead of the whole dump. Meanwhile it records every file edit, task and decision in a local SQLite database, so the agent picks up where it left off after the conversation compacts.
Every tool call dumps raw data straight into your context window. From the README:
Then the agent compacts the conversation to make room, and forgets which files it was editing, what was in progress, and what you last asked for. You pay for all of it in tokens, and in re-explaining.
Commands, file reads and web fetches run in an isolated subprocess. Only what the script prints enters the conversation. The raw log, page or JSON never does.
It runs 12 languages, and authenticated CLIs like gh, aws and kubectl still work.
Edits, git operations, tasks, errors and your decisions are logged to SQLite as you work.
When the conversation compacts, it searches that log and feeds back only what's relevant. No re-prompting. Start a fresh session without --continue and the old data is deleted.
Instead of reading 47 files to count lines, the agent writes one script that does the counting and prints the answer.
// 47 × Read() = 700 KB // 1 × ctx_execute() = 3.6 KB
The model writes the analysis. It doesn't do it by hand.
It also indexes docs and web pages into a local search engine, so the agent can look up the one paragraph it needs instead of pulling the whole page into context again.
The maintainer's benchmarks. Raw is what a normal tool call would dump into context. The right-hand column is what lands with Context Mode on.
The more your agent reads, fetches and runs, the more this saves you.
Playwright snapshots, server logs, CSVs, big JSON responses. This is where the 95–100% savings come from.
The session log means you stop re-explaining the task every time the context resets.
Fetch and index once, then search. The agent pulls the paragraph it needs, not the whole page, and cached pages aren't fetched again for 24 hours.
If you rarely fill the window, it's one more set of hooks running on every tool call for not much gain.
It's free on GitHub at mksglu/context-mode and on npm as context-mode. In Claude Code you install it as a plugin, and the hooks set themselves up. You need Claude Code v1.0.33 or later.
/plugin marketplace add mksglu/context-mode /plugin install context-mode@context-mode
/reload-plugins
/context-mode:ctx-doctor
Try this first: ask it to "Fetch the Hacker News front page, extract all posts with titles, scores and domains, and group them by domain." Then run /context-mode:ctx-stats and see what you saved.
/context-mode:ctx-stats/context-mode:ctx-doctor/context-mode:ctx-index/context-mode:ctx-search/context-mode:ctx-upgrade/context-mode:ctx-purge"statusLine": {
"type": "command",
"command": "context-mode statusline"
}
Shows what you've saved, live, at the bottom of Claude Code.
codex plugin marketplace add mksglu/context-mode
Turn on plugin_hooks = true and hooks = true under [features] in your Codex config, restart, and type ctx stats.
claude mcp add context-mode -- npx -y context-mode
All the tools, none of the hooks. The agent can use them but won't be pushed to, so you save a lot less.
npm install -g context-mode
Gemini CLI, Cursor, VS Code and JetBrains Copilot, OpenCode, Kiro, Zed and more. Each one has its own config step in the README.
With hooks, the README puts savings around 98%. With only an instruction file, around 60%. One unrouted curl or browser snapshot can undo a whole session's savings.
The plugin hooks into every tool call and runs code in a sandbox with your permissions. It respects your existing deny rules, so if you block sudo, it's blocked in the sandbox too. Still, skim it first.
No telemetry, no account, no cloud sync. Session data lives in SQLite in your home directory. The one hosted piece is the optional Insight dashboard, and only if you open it.
Elastic License 2.0. Use it, fork it, change it, ship it at work. You just can't resell it as a hosted service or strip the license notices.