Trending
#Developer Tools

mksglu/context-mode

Cuts the token cost of AI coding agents by keeping raw tool output out of the context window and persisting session state.

32,079
2,212
TypeScript
NOASSERTION
8 months old

The problem

AI coding agents burn their context window on raw tool output. A browser snapshot, a batch of GitHub issues, or a log file each land in the prompt at tens of kilobytes, and within half an hour a large share of the window is gone. Compaction then wipes the agent's memory of which files it was editing and what it was asked to do. The project addresses both halves: it moves bulky tool output out of the prompt, and it keeps a durable record of session events so the agent can resume after compaction.

What's different

Most context-saving efforts today are prompt discipline — telling the model in AGENTS.md to be terse, or that's what the README claims the project explicitly avoids. Context Mode instead intervenes at the tool layer: an MCP server exposes sandboxed execution tools (ctx_execute, ctx_batch_execute, ctx_fetch_and_index, and others) so the agent writes a script that inspects the data and prints only the result, rather than reading everything into the conversation. Session events are written to SQLite and indexed into FTS5, so after a compaction the agent retrieves only relevant history via BM25 search instead of replaying everything. Third, it installs routing instructions through platform hooks — the README claims 17 clients — so the agent is nudged toward these tools instead of raw Bash and Read. The trade-off is real: you're asking the model to write code where it could have just read a file, which is not always the right call for small outputs.

Who it's for

Developers running agentic coding sessions on large repositories, who routinely hit context limits mid-task and lose state to compaction — especially those on Claude Code, where the plugin integration and hooks are most complete. Teams that already use hooks can get automatic routing; others get the MCP tools with a manual routing file. People doing short one-off prompts, or working in a client with no MCP or hook support, will see little benefit and added friction. Anyone uncomfortable with the agent executing generated scripts against their working tree should stay away.

Cost of adoption

Requires a Node/TypeScript runtime and a client that supports MCP; Claude Code users need v1.0.33+ per the README. Full enforcement depends on platform hooks — without them you get the tools but no automatic routing. The license is ELv2 (the repo's license field is NOASSERTION), which is source-available rather than OSI open source, so check it against your organization's policy before standardizing. The project is young — created February 2026 — so treat the SQLite/FTS5 index and hook wiring as things that may still change. Install instructions and per-platform steps are in the README.

Verdict

A genuinely useful idea aimed at a real, measurable cost, and the 32k stars in roughly eight months show the pain is widely felt. The momentum signal is strong but shallow: a single monthly board appearance at #8 with +8,135 stars, no daily trending history, and no Hacker News discussion tracked by HotRepo — that pattern fits a launch spike more than a long track record. The architecture is opinionated and the correctness of the "think in code" routing matters more than star count, so try it on a real session and check ctx-stats before rolling it out team-wide. The ELv2 license is the main thing to settle first.

Written by AI from the project's README, updated October 24, 2026. The project's own docs are the source of truth.