# Repository Briefing: mksglu/context-mode
> Source: https://repoforai.com/repo/mksglu/context-mode (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/mksglu/context-mode
- **Official Docs / Website**: https://contextmode.ai
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: JavaScript
- **License**: See repository
- **Engineering Health**: A (81/100 · Maintenance 35/35 · Adoption 20/25 · Releases 20/20 · License 6/20)
- **Latest Release**: v2.2.6 (2026-12-03) — https://github.com/mksglu/context-mode/releases
- **Review Snapshot**: 2026-12-03 (Note: v2.2.6 on 2026-12-03 shipped after this review; verify latest release notes)
- **Deployment / Stack Signals**: MCP, CLI, Local AI
- **Momentum**: 34,726 ★ total (+13 24h / +200 7d) · 2,402 forks
- **Topics**: `antigravity`, `claude`, `claude-code`, `claude-code-hooks`, `claude-code-plugins`, `claude-code-skill`, `codex`, `codex-cli`, `context-mode`, `copilot`, `cursor-plugin`, `kiro`
- **When to Use**: Best for: Coding-agent workflows that generate large build logs, API responses, or documentation dumps and need only a few facts or excerpts at a time. Skip if: Native reads and filters already keep output small, you need full transcripts in model context, or policy prohibits local retention of tool output.

## Overview
```text
### Architecture & Core Mechanics
Context Mode is a local Node.js MCP server and host-plugin layer, not a model runtime. `SessionStart` opens the project's `context.db` under `~/.context-mode` and can prompt the agent to call `ctx_resume`. The `PreToolUse` policy in `src/core/policy/decide.ts` checks the user's deny list first, then evaluates fetches, shell commands, and large whole-file reads for routing. Reads with an explicit line range proceed normally.

In Code Mode, `ctx_execute` writes the agent's script to a temporary directory and launches the chosen runtime with an argument list, using the project directory as the working directory. It strips preload variables such as `NODE_OPTIONS`, caps returned output at 16,384 bytes, and terminates the process tree on timeout. Large results can be retained in SQLite and retrieved selectively through FTS5 rather than inserted wholesale into the model's context.

### Key Capabilities & Differentiators
The integration covers 11 coding agents, including Claude Code, Codex, Gemini CLI, Pi, OpenCode, and VS Code with Copilot. `ctx_execute` reduces data in code before the agent has to read it; `ctx_index` and `ctx_search` support later lookups; `ctx_batch` runs multiple commands before searching their results. Hook-based routing can also externalize supported host-tool output without requiring the agent to request each explicit tool call.

The macOS arm64 benchmark of 2.0.0-next.23 measured `ctx_bytes` against `raw_bytes`, using five runs per row. For the 36 rows with at least 10 KB of raw output, median byte savings were 99.4%; sandbox execution saved 99.5%, while retrieval saved 77.2% because it returns matching text. These figures quantify bytes withheld from context, not equivalent reductions in tokens, latency, or model cost.

### Trade-offs & Limitations
Compared with native line-range reads or shell filters, Context Mode pays off most when a large result will be queried repeatedly or reduced to a few facts. For short outputs or a known line range, native tools are simpler. FTS5 is lexical retrieval, so important evidence can be missed by a poorly phrased query; check excerpts or rerun a targeted read when completeness matters. Local indexes also use disk and can retain sensitive output.

The sandbox is designed to control execution output and time, not to establish a strong trust boundary: child processes run in the project directory and inherit most of the environment. Keep host permissions and secret handling in place. The local plugin is free and source-available, but review LICENSE before redistribution or bundling. The paid Gateway is a separate hosted service for conversation recall and cross-session memory, not a requirement for the local plugin.

### Hardware & Deployment Guide
Run it alongside the coding agent with Node.js 24.15.0 or later. On Windows, shell tools require Git for Windows and run in Git Bash. Use the host's native plugin installer or install with `npm i -g context-mode` and run `context-mode setup`; setup backs up configuration and can repair incomplete installations. The native Codex path also requires a one-time hook setup with `context-mode setup --agents codex`. Restart the host and run `/ctx-doctor` or the host-specific equivalent.

Execution, indexing, and search can run offline after installation; fetching a remote URL still requires network access. No model serving or GPU is required by the plugin. Release v2.2.3 fixed the replacement trigger at 4,096 bytes, distinct from the 16,384-byte output cap. Version 2.2.5 added support for passing Claude Code's session scratchpad to `ctx_index` and `ctx_execute`.
```

## Key Capabilities
```text
- Host integration: 11 coding agents use packaged hooks, configured hooks, or in-process event handlers.
- Execution limits: `ctx_execute` uses an argument-list subprocess, a 16,384-byte output cap, and a 600,000 ms default and maximum timeout.
- Local retrieval: SQLite FTS5 searches tool output kept in a per-project `context.db` under `~/.context-mode`.
- Session continuity: `SessionStart` opens the project database and can prompt the agent to call `ctx_resume`.
- Benchmark scope: On 36 rows with at least 10 KB of raw output, the median share of bytes kept out of context was 99.4%; retrieval alone saved 77.2%.
- Operational checks: `context-mode setup` repairs integration, and packed-package CI checks setup, doctor, a hook, and MCP handshakes across Linux, macOS, and Windows.
```

## Quick Start / Clone
```bash
codex plugin marketplace add mksglu/context-mode
codex plugin add context-mode@context-mode
# one-time step: trust the plugin hooks
npm i -g context-mode
context-mode setup --agents codex
```
