← Resources · One Pager · Tool Breakdown Checked Against The Repo · Oct 12, 2026
Claude Code + Codex + 15 More

Context Mode

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.

How To Use This Page

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.

98%
Less Tool Output In Context
27.2k
GitHub Stars
$0
Free, Runs On Your Machine
What It Is

An MCP Server That Guards Your Context Window

▶ mksglu/context-mode
27.2k
★ 27,213 StarsELv2 · TypeScript
In One Paragraph

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.

Smaller ContextLonger SessionsSurvives Compaction100% Local
The.Problem✣

Every tool call dumps raw data straight into your context window. From the README:

  • One Playwright snapshot: 56 KB.
  • Twenty GitHub issues: 59 KB.
  • One access log: 45 KB.
  • After 30 minutes, about 40% of your context is gone.

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.

How It Works

Three Ideas, One Install

1 · Sandbox.Tools

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.

2 · Session.Memory

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.

3 · Think.In.Code

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 Numbers

What Actually Reaches Your Agent

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.

01Playwright Snapshot56.2 KB raw → 299 B99% Saved
0220 GitHub Issues58.9 KB raw → 1.1 KB98% Saved
03Access Log, 500 Requests45.1 KB raw → 155 B100% Saved
04Analytics CSV, 500 Rows85.5 KB raw → 222 B100% Saved
05Git Log, 153 Commits11.6 KB raw → 107 B99% Saved
06Test Output, 30 Suites6.0 KB raw → 337 B95% Saved
07Repo Research986 KB raw → 62 KB94% Saved
315 KB
Raw Output In A Full Session
5.4 KB
What Reaches Context
~3 hrs
Session Length, Up From ~30 Min
Is It For You

Worth It? Depends How You Work.

The more your agent reads, fetches and runs, the more this saves you.

Install.It.If

Your agent drives a browser or reads logs.

Playwright snapshots, server logs, CSVs, big JSON responses. This is where the 95–100% savings come from.

Install.It.If

You run long sessions and keep hitting compaction.

The session log means you stop re-explaining the task every time the context resets.

Install.It.If

You do research across repos, issues and docs.

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.

Maybe.Skip.It

Your sessions are short and your tasks are small.

If you rarely fill the window, it's one more set of hooks running on every tool call for not much gain.

Where To Get It

Install In Claude Code

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.

1 · Install
Inside Claude Code
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode
2 · Reload
Or just restart Claude Code
/reload-plugins
3 · Verify
Every check should show [x]
/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.

Slash.Commands
/context-mode:ctx-stats
Context saved this session, broken down by tool.
/context-mode:ctx-doctor
Checks runtimes, hooks, search index and plugin setup.
/context-mode:ctx-index
Index a local file or folder so the agent can search it.
/context-mode:ctx-search
Search what you've indexed.
/context-mode:ctx-upgrade
Pull the latest version and fix the hooks.
/context-mode:ctx-purge
Delete everything in the index.
Optional · Status.Line
Add to ~/.claude/settings.json
"statusLine": {
  "type": "command",
  "command": "context-mode statusline"
}

Shows what you've saved, live, at the bottom of Claude Code.

Not On Claude Code?

Codex.CLI
Then install it from the plugin UI
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.

Just.Trying.It
Claude Code, MCP tools only
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.

Everything.Else
Needs Node.js 22.5+ or Bun
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.

Before You Install

Four Things Worth 30 Seconds

Note 01

Use the hooks where you can.

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.

Note 02

Read what the hooks do.

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.

Note 03

Your data stays local.

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.

Note 04

It's source-available, not MIT.

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.