Context Mode — Context Optimization for AI Coding Agents
Cut context window bloat, persist session memory, and enforce tool routing across 17 platforms via MCP and hooks.
- Source repo
- mksglu/context-mode
- Stars
- ★ 35k
- Last updated
- 1d ago v2.2.4
- FARS reviewed
- Nov 08, 2026 +9 new
- License
- NOASSERTION
- Primary language
- JavaScript
- FA score
- 73/100 · Some gaps
At a glance
- How it runs
- Works with
- Universal · cross-platformChatGPT · Codex · Claude Code
- Cost
- Free, no paid service needed
- Setup effort
- Medium · a few setup steps
- You'll need
- Typical use
- A Claude Code user installs the plugin and uses
/context-mode:ctx-doctorto verify, with hooks automatically redirecting large tool calls to sandbox execution. - Not a fit if
- Teams without Node.js >= 22.5 installed on every platform
- Teams needing 100% routing enforcement on non-hook platforms like Cursor or Zed
- Users unwilling to add rules files or edit platform config files
- Website
- contextmode.ai ↗ set on GitHub
- Maintenance
- Commits in the last 30 dayslast commit 2026-12-02latest release v2.2.4 (2026-11-25)+31.1 ★/day over 7 days
- Source review
- 73/100 · Some gaps
What does this agent do, and when should you use it?
Context Mode is an MCP server that solves the problem of AI coding agents' context windows being flooded by tool output. It sandboxes tool execution to keep raw data out of context (e.g., 315 KB → 5.4 KB, a 98% reduction) and persists session events (file edits, git operations, tasks, errors, user decisions) into SQLite, using FTS5 and BM25 search to restore key state after conversation compaction. The project promotes a "think in code" paradigm where the model writes scripts that compute results and output only stdout, rather than reading many files into context. Context Mode supports 17+ platforms including Claude Code, Gemini CLI, Copilot, Cursor, OpenCode, and others, with hooks or routing files for enforcement, and it works as an MCP server. It provides 11 MCP tools like ctx_execute and slash commands like ctx-stats and ctx-doctor. The project is licensed under ELv2 and targets developers and teams using LLM-assisted coding.
Context Mode registers itself with supported clients via MCP or plugins. When the model calls tools, hooks or routing rules guide it to prefer sandboxed tools like ctx_execute and ctx_batch_execute, which run code in separate subprocesses and only return stdout to context. ctx_index chunks markdown by headings while preserving code blocks, storing in SQLite FTS5; ctx_search uses BM25 and Reciprocal Rank Fusion to retrieve indexed content. ctx_fetch_and_index fetches URLs, converts to markdown, chunks, and indexes with TTL caching. Session events are captured by hooks like PreToolUse and PostToolUse into SQLite; before compaction, PreCompact hooks save snapshots, and on session resume, SessionStart injects relevant state. ctx_stats reports context savings.
- A Claude Code user installs the plugin and uses
/context-mode:ctx-doctorto verify, with hooks automatically redirecting large tool calls to sandbox execution. - A Gemini CLI developer registers MCP and hooks via one config file, reducing context usage and maintaining session continuity.
- A Cursor user manually configures
.cursor/hooks.jsonand rules file to protect context in the IDE, as the Marketplace plugin is pending review. - A Codex CLI user enables plugin and hooks feature flags to ensure state restoration after conversation compaction.
- A team uses
ctx_indexandctx_searchto build a project knowledge base for on-demand retrieval without loading large documents. - An OpenCode user uses the TypeScript plugin to get native
ctx_*tools and hooks, with session snapshots during compaction.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Install / run
npm install -g context-mode
- Runtime
- Node.js 22.5+
How do you install or deploy this agent?
For Claude Code: run /plugin marketplace add mksglu/context-mode and /plugin install context-mode@context-mode, then restart and verify with /context-mode:ctx-doctor. For other platforms, install Node.js >= 22.5, npm install -g context-mode, then copy the platform-specific MCP config, hooks file, and routing rules. Full steps in README.
How do you use this agent?
After installation, type ctx stats in a supported client to see savings, ctx index to index a file, ctx search to query, and ctx doctor to diagnose. Sandbox tools like ctx_execute are automatically invoked by the model or can be used manually.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
Makes outbound requests; verify telemetry settings and model data routing on private repos.
Inherits capabilities of connected MCP servers; audit third-party servers before enabling.
FARS trust-control audit
- data-flow disclosure
What are this agent's strengths and limitations?
- Sandboxed tools can reduce tool output by up to 98% (e.g., 315 KB → 5.4 KB), drastically preserving context.
- Session continuity is robust, with hooks and SQLite restoring file and task state after compaction.
- Supports 17+ platforms including Claude Code, Gemini CLI, Cursor, Codex, with automatic or manual routing.
- Non-hook platforms like Antigravity IDE and Zed rely on rule files, achieving only ~60% routing compliance, offering weaker protection.
- Requires Node.js >= 22.5 and all platforms need Node installed.
- Some platforms like Cursor lack SessionStart hooks, requiring extra rules file; Cursor plugin is awaiting review.
How does this agent compare with similar options?
Compared to other AI coding assistants without context optimization, Context Mode's unique selling point is its sandboxed execution and SQLite-based session persistence, not just prompt compression.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Context Mode — Context Optimization for AI Coding Agents This agent | 73 · Some gaps | MCP serverFree | ★ 35k | 1d ago | JavaScript | ChatGPT · Codex · Claude Code |
| MCP Task Orchestrator | 70 · Some gaps | MCP serverFree | ★ 215 | 1d ago | Kotlin | Claude Code |
| Mnemosyne | 78 · Good | CLIFree | ★ 162 | 2d ago | TypeScript | Claude Code |
| Okto Nexus Coordination Hub | 77 · Good | — | ★ 107 | 22d ago | Python | — |
How does FollowAgents rate this agent?
Why each dimension lost points
The source shows path containment, per-hop SSRF checks for URL fetching, timeouts, and a local SQLite index. The README identifies data location and network calls, earning full marks for flow transparency. Setup and upgrade describe config backup, plan display, and restoration on early failure, supporting ordinary user control. Sensitive-data rules and dependency auditing are thin in this packet, and the license restricts hosted service use, so those scores are lower. Publisher identity is unverified, with no stronger independent identity evidence in the packet.
The packet includes CI configuration for multiple operating systems, type checking, unit and end-to-end checks, plus README guidance for installation checks and fixes. No checks were executed for this review, and the supplied source excerpts cannot establish all behavior, so consistency, availability, and failure messaging receive moderate scores.
The README covers ten coding agents, varied practical tasks, and agent-specific installation paths. It explains the sandbox, indexing, search, and hooks, but the packet omits full tool descriptions and all agent configuration, limiting capability-boundary and trigger precision scores. Node and Windows Git Bash requirements also constrain environment fit.
The README has a clear contents structure and detailed install, update, check, removal, example, benchmark, and limitation guidance. Manifests consistently show version 2.1.6, and the license text identifies Elastic License 2.0, which has substantial hosted-service restrictions and is not an unrestricted open-source license. No changelog is present in the packet; maintenance responsibility is evidenced mainly by author metadata and repository links.
The tools keep large output in a local index and return concise replies with search access; the skills specify usable report and table formats. Multiple benchmark rows support the stated context-saving value. The cost-benefit case has benchmark methods and runtime requirements, but the figures are project-reported and runtime costs and variation across scenarios receive limited treatment.
The README links savings claims to benchmark rows, input sources, and rerun commands, while source code supports design claims such as path containment and local indexing. Manifests, source, and README provide some corroboration, but several security and performance conclusions rely on project material; statistics and execution records were not independently verified in this review. Cross-source corroboration and separation of fact from inference therefore receive moderate scores.
- Elastic License 2.0 expressly restricts providing the software as a hosted or managed service; review its terms before enterprise use or redistribution.
- The README claims zero telemetry and lists network calls, but this review saw only selected source files and could not independently verify all network behavior or sensitive-data handling.
- Node 24.15.0 or later is required; Windows also requires Git for Windows.
Recent releases
Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.
-
Release notes excerpt
Fixes - fix(ci): OMP release step adds its dir to GITHUB_PATH (D-OMP-CI-6) - fix(ci): OMP native install step stops after 6 min and hands off to the release step (D-OMP-CI-5) - fix(ci): OMP binary from its GitHub release when OMP's install script gets no build (D-OMP-CI-4) - fix: sandbox child env sets PYTHONUTF8=1 so python prints exact UTF-8 on Windows code pages (#1417) Who gets this One version on both channels: the release commit on main (GitHub) and npm. | Agent | Channel | Update with | |---|---|---| | Claude Code | GitHub | claude plugin update context-mode@context-mode | …View on GitHub ↗ -
Release notes excerpt
Fixes - fix: CTX_REPLACE_TRIGGER_BYTES is no longer read; the replace trigger is the constant 4096 and doctor names a leftover value (ADR-0027 D1) - fix: remember a lost replace bet per session, ADR-0027 D3 (ADR-0027 D3) - fix: ctx_search reads a source in order when no query word is in it, so a replaced MCP document comes back in full pages (#1372) - fix: OMP doctor, setup and uninstall read OMP's plugin store and agent dir the way OMP does (#1415) - fix: codex setup list check reads codex mcp get context-mode --json and names a timeout (#1413) …View on GitHub ↗ -
Release notes excerpt
Fixes - fix: a Fake-IP DNS name in 198.18.0.0/15 passes the SSRF guard after a once-per-process .invalid probe; literals and all other ranges stay blocked (#1403) - fix: only an absolute missing cwd walks up to its nearest existing parent; GP3 and Windows cases follow (#1409) - fix: Claude Code PostToolUseFailure takes the narrow matcher, a foreign MCP failure spawns no hook (#1408) - fix: Claude Code registers PostToolUseFailure, so a failed host tool gets its toolerr row (#1408) - fix: ctx_doctor answers when the project does not resolve (#1410) …View on GitHub ↗
FAQ
Is Context Mode free?
Will using sandbox tools limit functionality?
Does Context Mode collect my data?
How do I uninstall?
/plugin to uninstall; for others, remove the MCP config, hooks file, and the global npm package.Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.