Key points
- Context Mode is an MCP server that fixes the "amnesia" problem of AI coding agents: raw tool outputs (browser snapshots, logs, git history) exhaust the context window in ~30 minutes, and context compaction deletes progress, constraints, and user decisions.
- Author: mksglu (Mert Köseoğlu, operator of MCP Directory & Hub). Repo: https://github.com/mksglu/context-mode (~13,000 stars). License: Elastic License 2.0 (source-available; forbids closed-source SaaS repackaging).
- Claimed results: 315KB session output compressed to 5.4KB (98%); session time extended from ~30 minutes to ~3 hours (6x). Independently reviewed by pyshine.com, itnotetk.com, easytool.me.
- Three-layer architecture: 1. Sandboxed tool execution:
- Full hook (Claude Code, Qwen Code, Gemini CLI, VS Code Copilot, JetBrains Copilot, OpenCode, KiloCode): ~98% savings expected.
- Partial hook (Cursor, OpenClaw, Codex CLI, Pi): ~98% but SessionStart may be limited.
- MCP-only (Antigravity, Zed, Kiro): ~60%—a single unrouted fetch can wipe out accumulated savings, so hooks should be enabled wherever supported.
- Strongly recommended: daily agent coding >1 hour, frequent tool calls, long multi-turn sessions, large logs/data files.
- Marginal: light usage with few tool calls.
- Not suitable: repackaging as closed-source product (ELv2 forbids); platforms without hook support unless manual routing is configured.
- GitHub: https://github.com/mksglu/context-mode
- Architecture deep-dive: https://pyshine.com/Context-Mode-Context-Window-Optimization-AI-Coding-Agents/
- Hands-on guide (CN): https://www.itnotetk.com/2026/05/05/context-mode-mcp-context-window-saver/
- Usage guide: https://www.easytool.me/blog/context-mode-ai-coding-context-window-guide.html
- MCP Market: https://mcpmarket.com/server/context-mode
- Tool comparison: https://milvus.io/blog/claude-code-context-management-tools.md
ctx_execute, ctx_batch_execute, ctx_execute_file, ctx_index, ctx_search, ctx_fetch_and_index (24h TTL cache). Raw data never enters the context window—only stdout does.
2. Session continuity: Five hooks (PreToolUse, PostToolUse, UserPromptSubmit, PreCompact generating ≤2KB snapshots, SessionStart) write all events to local SQLite with FTS5 full-text indexing. After compaction, BM25 search retrieves only currently relevant context (Porter stemming, trigram matching, 5x weight for headers).
3. "Think in Code" paradigm: The LLM writes code to process data in a sandbox instead of reading raw data—turning it from a "data reader" into a "code generator."Performance data
| Scenario | Raw output | After sandbox | Savings | |---|---|---|---| | Playwright browser snapshot | 56.2 KB | 299 B | 99% | | GitHub Issues (20) | 58.9 KB | 1.1 KB | 98% | | Access logs (500) | 45.1 KB | 155 B | ~100% | | Context7 React docs | 5.9 KB | 261 B | 96% | | CSV analysis (500 rows) | 85.5 KB | 222 B | ~100% | | Git log (153 commits) | 11.6 KB | 107 B | 99% | | Test output (30 suites) | 6.0 KB | 337 B | 95% | | Repo research (subagent) | 986 KB | 62 KB | 94% |
Platform compatibility tiers
Related projects (complementary, not competing)
| | Context Mode | Understand-Anything | codebase-memory-mcp | |---|---|---|---| | Problem | Agent memory/context management | Human codebase comprehension | Efficient structured code queries | | Method | Sandbox + FTS5 + Think in Code | Multi-agent pipeline + visualization | Tree-sitter knowledge graph + query tools | | License | ELv2 | MIT | MIT |
Limitations
1. Effectiveness depends heavily on platform hook completeness.
2. "Think in Code" requires prompt engineering (routing files like CLAUDE.md/AGENTS.md) and model adherence.
3. FTS5/BM25 is weak for structured queries (e.g., "files modified in last 3 days with test coverage") vs. knowledge graphs.
4. SQLite index accumulates over time; ctx_purge cleanup is manual, with no automatic expiry.
Who should use it
Verdict
Context Mode makes a hidden problem explicit: "Claude Code suddenly got dumber" is often context compaction amnesia, not model downgrade. Its deepest contribution is the paradigm: the LLM should be a code generator, not a data reader—a general design principle for future AI coding tools.