Context Mode

A shared context-budget layer for developers who run coding agents all day across several editors

Context window optimization for AI coding agents. Sandboxes tool output (98% reduction), persists session memory, and enforces routing across 17 platforms via MCP + hooks.

Category
Developer tools
Audience
Developers
Language
TypeScript

Updated

Context Mode is a context-window optimization layer for AI coding agents, shipped as an MCP server plus a set of agent hooks. It is aimed at developers who keep a coding agent running for hours — driving a browser, reading logs, calling a dozen tools per task — and who watch the agent get slower and vaguer as its window fills with raw tool output. The project is written in TypeScript, reached the top of Hacker News with 570-plus points, and has collected over 21,000 stars since it appeared in February 2026.

What it does

The premise is that most context work focuses on what you put into the window — prompts, files, instructions — and ignores what the agent's own tools push back into it. Every tool call returns a payload, and those payloads are rarely small. The project's own example is a single Playwright snapshot costing 56KB. Stack enough of them and, by the README's account, roughly 40% of the context is gone after thirty minutes of work.

Context Mode attacks that second half of the problem in three ways:

  • Sandboxing tool output. Results are captured before they land in the window, with a claimed 98% reduction. The demo in the video replaces ten separate tool calls with one script and takes 315KB down to 5.4KB.
  • Persisting session memory. What the agent learned in a session survives compaction, so a long task does not restart from a blank slate each time the window is squeezed.
  • Enforcing routing. The same rules about which tool handles which job are applied consistently across 17 platforms, rather than being re-tuned per editor.

How it works

Two mechanisms carry the whole design: an MCP server and hooks into the host agent. The MCP side is what the agent talks to when it wants a tool; the hooks are what let the project sit in the agent's lifecycle and intervene rather than merely offer another tool the model may or may not pick. Tool output is intercepted at that boundary and shrunk before it ever reaches the model, which is why the savings hold regardless of how disciplined the prompt is.

The scripting angle is the part worth understanding. Instead of the agent making ten round trips and absorbing ten raw results, one script does the work and returns a single small result. The reduction is not compression of text the model still has to read — it is work that happens outside the window entirely.

The platform list in the repository's topics gives a sense of the coverage: Claude Code (including its hooks, plugins and skills surfaces), Codex and the Codex CLI, Cursor, Copilot, Zed, Kiro, opencode, Antigravity, pi-agent and OpenClaw. Because the integration is MCP plus hooks rather than a fork of any one client, the same configuration is meant to behave the same way wherever you point it.

Getting started

The project is published to npm as the context-mode package, and the repository also advertises itself through a plugin marketplace listing for agent clients that support one. There is a Discord for users. The license is the Elastic License v2, not a permissive open-source license — worth checking before you build a product on top of it, and largely irrelevant if you are installing it on your own machine. The copy of the README captured for this entry is truncated before the installation steps, so take the exact commands and per-platform configuration from the repository itself rather than from this page.

When to use it / when not

This is for long sessions with heavy tool use. If your agent drives a browser, greps large repositories, reads test output or talks to APIs that return verbose JSON, the tool output is the dominant cost in your window, and that is precisely the cost this addresses. The multi-platform story is a second reason to care: if your team is split between Claude Code, Cursor, Codex and Zed, one routing configuration that behaves identically across all of them is worth more than any single reduction number.

It is less compelling for short, single-shot tasks where the window never gets tight, and it adds a moving part — an MCP server and hooks — between you and your agent, which is a real maintenance cost if you are debugging agent behaviour. Teams with a strict policy about non-OSI licenses in the toolchain will need to clear ELv2 first.

Anyone who has watched a coding agent lose the plot halfway through a long task should take this seriously. The diagnosis is sharp and testable — measure how much of your window your own tool results occupy, and the argument either lands or it does not. The popularity and the active push history suggest a project being maintained, not a demo, though as with any layer that intercepts your agent's plumbing, the honest evaluation is to run it on a real session and compare.

More in Developer tools

All of Developer tools →