πŸ“ˆ GH Trending Explorer 🎲 Surprise me

← all repos

mksglu / context-mode

git clone https://github.com/mksglu/context-mode.git v1.0.169 Β· 3mo ago πŸ”₯ on GitHub Trending today

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

β€”
stars, 24h
+4.2k
stars, 7 days Β· #23
+7.5k
stars, 30 days Β· #51
31k
β˜… total Β· +16% this week
2.2k
forks Β· 356 open issues

Star history starts 2026-10-20; the chart appears after the second daily snapshot.

LanguageTypeScript
Licenseβ€”
Created2026-02-23 (7mo ago)
Last pushtoday
Watchers110
OwnerUser

Seen on GitHub Trending

  • 2026-10-20 β€” #3 monthly in typescript Β· +7,498 β˜…
  • 2026-10-20 β€” #7 monthly Β· +7,498 β˜…
  • 2026-10-20 β€” #2 weekly in typescript Β· +4,224 β˜…
  • 2026-10-20 β€” #4 weekly Β· +4,224 β˜…

GitHub topics

Links

README excerpt
# Context Mode
**The other half of the context problem.**
 Used across teams at 
## 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.
 [code] 
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`) β€” the routing block stays focused on *where data goes*, not on *how the model talks*.
## 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:**
 [code] 
Restart Claude Code (or run `/reload-plugins`).
**Verify:**
 [code] 
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 sandb