mksglu/context-mode
⭐ 14,220 · TypeScript · GitHub Repo
Context window optimization for AI coding agents. Sandboxes tool output, 98% reduction. 15 platforms
antigravity claude claude-code claude-code-hooks claude-code-plugins claude-code-skill codex codex-cli
1-Sentence Summary
Sandboxes tool output for 98% context reduction across 15 AI coding platforms.
🔥 Key Capabilities & USP
Sandboxed Tool Execution (98% Context Reduction) — Replaces raw, verbose tool output (e.g., 315 KB) with structured summaries (e.g., 5.4 KB) via
ctx_executeandctx_batch_execute. Solves the critical pain point of context window overflow during long coding sessions.Session Continuity Across Compaction — Tracks every file edit, git operation, error, and decision in a local SQLite database with FTS5 full-text search and BM25 ranking. Survives conversation compaction without dumping stale data back into context, eliminating the "lost thread" problem.
Think in Code Paradigm — Instead of dumping 50 files into context, the agent writes a script that computes and logs only the result. Replaces ten tool calls with one, achieving ~100x context savings while keeping the agent's reasoning focused on logic, not data.
Output Token Compression (65-75% Reduction) — Enforces terse, technical-exact responses with no filler, pleasantries, or hedging. Preserves full technical accuracy while dramatically reducing LLM output costs and latency.
Multi-Platform with Automatic Routing — Works across 15 platforms (Claude Code, Gemini CLI, Cursor, Copilot, Codex CLI, Zed, etc.) with automatic hook-based routing on capable platforms and seamless MCP-only fallback for others.

Technical Architecture
| Component | Description |
|---|---|
| MCP Server | 11 tools: 6 sandbox tools (ctx_execute, ctx_batch_execute, ctx_execute_file, ctx_index, ctx_search, ctx_fetch_and_index) + 5 meta-tools (ctx_stats, ctx_doctor, ctx_upgrade, ctx_purge, ctx_insight) |
| SQLite + FTS5 | Local knowledge base with full-text indexing and BM25 search for retrieving relevant session context |
| Hook System | PreToolUse, PostToolUse, PreCompact, and SessionStart hooks for automatic routing enforcement on hook-capable platforms |
| Plugin Architecture | Full Claude Code plugin (slash commands, status line) + MCP-only mode for non-hook platforms |
| Runtime | Node.js 18+; distributed via npm with global install and npx execution |
Quick Start Guide
Claude Code Plugin Install (hook-capable):
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-modeMCP-only Install (no hooks):
claude mcp add context-mode -- npx -y context-modeGlobal Install (Gemini CLI, etc.):
npm install -g context-modeVerification:
/context-mode:ctx-doctorOptional Status Line (Claude Code):
{
"statusLine": {
"type": "command",
"command": "context-mode statusline"
}
}Pros, Cons & Use Cases
Pros
- 98% context reduction on tool outputs — transforms 315 KB payloads into 5.4 KB summaries
- 65-75% output token savings — cuts LLM costs and latency without sacrificing accuracy
- Session continuity — survives conversation compaction with full searchable history
- 15+ platform support — single tool works across Claude Code, Cursor, Copilot, Gemini CLI, and more
- Open-source (ELv2 license) with active adoption at major tech companies
Cons
- Requires Node.js 18+ — not available on older or restricted runtimes
- Non-hook platforms need manual routing — extra setup step for MCP-only environments
- Claude Code plugin requires v1.0.33+ — older versions incompatible
- Output compression style — terse "caveman" responses may feel unnatural to some users
- Fresh sessions delete previous data — must use
--continueflag to maintain history across sessions
Who should NOT use this?
- Single-command users — if you rarely run multi-step coding sessions, the setup overhead outweighs the benefits
- Legacy Node.js environments — Node 16 or below is unsupported
- Teams requiring verbose LLM output — if your workflow depends on conversational, explanatory responses, the compression style will feel restrictive
- Non-coding AI agent use cases — this is purpose-built for coding agents; general chat or content generation workflows will not benefit
Ideal Use Cases
- Long coding sessions — refactoring, debugging, or feature development spanning hundreds of tool calls
- Multi-platform agent teams — teams using Claude Code, Cursor, Copilot, and Gemini CLI simultaneously
- Cost-sensitive deployments — reducing LLM token consumption by 65-75% on output and 98% on tool context
- Complex codebase navigation — replacing "read 50 files" patterns with "write a script that computes the answer"
- Automated CI/CD agent pipelines — maintaining session state across compaction during long-running automation tasks
Community & Activity
Context Mode has already garnered 14,220 stars on GitHub, signaling strong community validation and real-world adoption. The project is actively maintained with the latest update on May 10, 2026, indicating ongoing development and responsiveness to user feedback. With support for 15+ platforms and adoption at major tech companies (Microsoft, Google, Meta, Amazon, NVIDIA, Stripe, GitHub), this is rapidly becoming the standard tool for context window optimization in the AI coding agent ecosystem. The combination of a clear, measurable value proposition (98% reduction) and broad platform compatibility makes this a project with serious momentum — and one that every team using AI coding agents should evaluate today.