The other half of the context problem.
Context Mode
The other half of the context problem.
Privacy & Architecture
Context Mode is not a CLI output filter or a cloud analytics dashboard. It operates at the MCP protocol layer — raw data stays in a sandboxed subprocess and never enters your context window. Web pages, API responses, file analysis, Playwright snapshots, log files — everything is processed in complete isolation.
Nothing leaves your machine. No telemetry, no cloud sync, no usage tracking, no account required. Your code, your prompts, your session data — all local. The SQLite databases live in your home directory and die when you're done.
This is a deliberate architectural choice, not a missing feature. Context optimization should happen at the source, not in a dashboard behind a per-seat subscription. Privacy-first is our philosophy — and every design decision follows from it. License →
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.
Context Mode is an MCP server that solves both halves of this problem:
- Context Saving — Sandbox tools keep raw data out of the context window. 315 KB becomes 5.4 KB. 98% reduction.
- 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.
https://github.com/user-attachments/assets/07013dbf-07c0-4ef1-974a-33ea1207637b
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:
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode
Restart Claude Code (or run /reload-plugins).
Verify:
/context-mode:ctx-doctor
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, PreCompact, SessionStart) and 6 sandbox tools (ctx_batch_execute, ctx_execute, ctx_execute_file, ctx_index, ctx_search, ctx_fetch_and_index).
| Slash Command | What it does |
|---|---|
/context-mode:ctx-stats |
Context savings — per-tool breakdown, tokens consumed, savings ratio. |
/context-mode:ctx-doctor |
Diagnostics — runtimes, hooks, FTS5, plugin registration, versions. |
/context-mode:ctx-upgrade |
Pull latest, rebuild, migrate cache, fix hooks. |
Note: Slash commands are a Claude Code plugin feature. On other platforms, type
ctx stats,ctx doctor, orctx upgradein the chat — the model calls the MCP tool automatically. See Utility Commands.
Tools (6)
ctx_batch_executeExecutes multiple commands in a sandboxed environment while keeping output out of the context window.ctx_executeExecutes a single command in a sandboxed environment.ctx_execute_fileExecutes a file in a sandboxed environment.ctx_indexIndexes data into the local SQLite database for future retrieval.ctx_searchPerforms a BM25 search against indexed session data.ctx_fetch_and_indexFetches external data and indexes it immediately.Configuration
{"mcpServers": {"context-mode": {"command": "npx", "args": ["-y", "context-mode"]}}}