跳到主要内容
Supermarket
返回能力市场
MCP Server
data
NOASSERTION

context-mode

Free, local plugin that keeps tool output out of your coding agent's context window. Sandbox and SQLite FTS5 search, 99% fewer bytes in context. Works with Claude Code, Codex, Pi, OMP, OpenCode, Gemini CLI, Copilot CLI and 4 more agents. Zero telemetry.

mksglumksglu
89/ 100

公开评测 · 综合采用结论

证据充分,整体质量与安全表现优秀

查看评测依据 查找我项目的报告基于公开项目证据,非安全认证或安装推荐
34.2kstars
2.4kforks
最近更新 6小时前
评测生成时间(北京时间)
本报告引擎
v3.9.1
当前引擎
v3.17.3

本报告与当前引擎使用不同规则;原分数不会自动更新,不同版本的分数不宜直接对比。

重新评测此项目

进入后确认来源与额度,提交才会创建任务。

代码版本未记录或记录无效,无法核对本报告的 commit 与送评文本;不会用当前项目代码回填历史记录。

Evaluation report

综合采用结论

89
A
满分 100 · 静态采用参考
值得推荐低风险
决策摘要

证据充分,整体质量与安全表现优秀

84%
高置信度
100
文档
100
安全
72
质量
100
活跃
70
采用
  • 基础评测完成+25/25确定性评分与静态安全扫描已完成
  • README 有效证据+25/2575,887 个去重后的有效字符
  • 独立证据来源+4/201 类非重复证据,重复文件不叠加
  • 仓库元数据+10/10已取得仓库状态与采用数据
  • 活跃记录+5/5已取得最近提交时间
  • AI 复核+15/15已完成结构化 AI 证据复核

本报告评了什么

综合分用于静态采用筛选,不是任务成功率,也不代表使用 Skill 后的能力提升。

静态检查范围
记录 1 个文件 · 94,435 字符
只检查采集到的受限文本与已知风险模式;未读取的脚本、依赖和运行环境不在结论内。
AI 内容复核
已使用
复核送评文本的说明和设计,不是安装测试或实际任务执行。记录缺失时不推断已使用或未使用。
真实任务效果
本报告未提供实测证据
没有使用/不使用 Skill 的任务对照、重复运行或耗时与 token 成本结果。采用前仍需在隔离环境验证自己的任务。

脚本引用覆盖

脚本引用覆盖记录不可得;不推断没有引用或已经检查。

How it works · 时序图

上下文模式工具调用流程

README描述了工具调用、钩子拦截和路由的交互过程,涉及多个参与方。

AI 提取 · 证据约束

左右滑动查看完整图示

上下文模式工具调用流程README描述了工具调用、钩子拦截和路由的交互过程,涉及多个参与方。AI代理发起工具调用钩子拦截工具调用MCP服务器提供工具持久化存储保存会话和索引调用工具路由到ctx工具读写数据
图示依据
  • • README中'Routing: Automatic. The SessionStart hook injects routing instructions'
  • • README中'11 MCP tools — six sandbox tools...plus five meta-tools'
  • • README中'persists session memory'
五维表现
解决AI编码代理上下文窗口溢出的真实问题,提供多平台安装与路由强制,价值可验证。但README未完整展示,部分平台安装复杂,设计细节如权限边界证据不足。
质量证据
  • README中'Claude Code'章节提供/plugin marketplace add命令
  • Gemini CLI章节提供settings.json配置示例
  • Cursor章节明确'Known limitation: Cursor accepts additional_context...not surfaced'
  • OpenCode章节说明'experimental.chat.system.transform'作为SessionStart替代
  • License: ELv2在README徽章中显示
采用建议
优势
  • 问题与用途描述
  • 有效 README
  • 安装或接入步骤
  • 可执行示例
  • 未发现已知高风险模式
关注点
  • README被截断,部分平台安装不完整
  • 设计细节如权限边界未充分说明
  • 依赖外部服务(Insight dashboard)
  • 部分平台功能依赖实验性钩子
适合

使用Claude Code的团队、需要跨平台上下文优化的开发者、希望自动路由工具调用的用户、对上下文节省有量化需求的场景

不建议直接用于

无Node.js环境的用户、需要完全离线运行的用户、对实验性钩子敏感的生产环境

也有自己的公开项目?先免登录查已有报告;没有报告时,可保留地址继续登录评测。

查找我项目的报告 →
文档证据
100/100
问题与用途描述10 分
有效 README12 分
安装或接入步骤14 分
可执行示例16 分
输入、参数或工具说明11 分
输出或结果说明9 分
限制、权限或边界12 分
错误处理或排障8 分
许可证信息5 分
结构化章节3 分
安全证据
低风险
未发现已知高风险模式

静态扫描不是安全保证,生产接入前仍应人工复核权限和数据边界。

方法、证据与局限展开
数据来源

GitHub Repository API

扫描范围

1 个文件 · 94,435 字符

评测引擎

v3.9.1 · AI 内容复核:已使用(deepseek-chat)

局限
  • 静态评测不会安装或执行项目代码
  • 安全扫描基于高信号文件与已知模式,不能替代人工审计
  • 流行度只反映采用程度,不代表安全或工程质量

30 天热度趋势

README

Context Mode

A free, local plugin for 10 coding agents. It keeps tool output out of your agent's context window and keeps all usage data on your machine. The plugin is free forever.

npm downloads GitHub stars Discord License: ELv2

33K GitHub stars · 683K npm downloads (read 2026-11-01, stats.json) · on the Hacker News front page and GitHub Trending: charts and sources

The Context Mode plugin is free and local, with its source open on GitHub. Context Mode Gateway is a separate hosted service with its own account and subscription. It takes the same idea from tool output to the whole conversation: Gateway Recall keeps long sessions searchable, and Gateway Memory shares what your agents learn across sessions and tools. See how the Gateway works

Context Mode plugin: free and local, zero telemetry, the plugin keeps your data on your machine. Bench of 2026-11-01: 99.4% of output bytes saved (median of 36 rows with 10 KB or more of raw output). A full debugging session (row g-session-total): 281,261 B raw to 3,266 B in context, about 70K to 817 tokens (an estimate at 4 B per token). Resume after compaction (row e-long-session): a 442,893 B transcript to a 2,019 B block, about 111K to 505 tokens (an estimate). Runs in 10 coding agents with 9 MCP tools.

Contents: Why · Adoption · Install · Try it · Use cases · Benchmarks · How it works · Tools · Security and privacy · Context Mode Gateway · License · Community

Why

A coding agent reads files, runs commands and fetches pages, and every result goes into its context window. The Context Mode plugin runs that work in a local sandbox, keeps the full output in a SQLite index on your machine, and gives the agent the part it asks for.

  • The plugin is free forever. Use it at home and at work, free of charge, under a source-available license.
  • Runs on your machine. The hooks, the sandbox and search run as local processes next to your agent.
  • The plugin keeps your data on your machine. Every index lives in ~/.context-mode: one context.db per project.
  • Zero telemetry. The plugin keeps all usage data on your machine. Security and privacy lists each network call it makes.
  • Works offline after install. Sandbox runs, file indexing and search use local SQLite and your own runtimes.
  • Thinking in Code. The agent writes a short script instead of reading the data, and only what the script prints reaches the context: see How it works, step 5.
  • Small replies. On the 36 bench rows with 10 KB or more of raw output, the plugin's median reply is 99.4% smaller than the raw output.

Adoption: stars and npm downloads

Line chart of cumulative GitHub stars for mksglu/context-mode since 2026-02-23. A daily job redraws it.Area chart of npm downloads per day for context-mode, the last 90 days. A daily job redraws it.

Open the interactive chart and point at a bar to read its value. Tabs there show days, weeks, months and years. Stars come from the GitHub GraphQL API (starredAt); npm downloads come from api.npmjs.org/downloads/range. The total up to 2026-10-29 is 683K npm downloads (stats.json keeps a daily copy). A daily job redraws both charts.

  • Hacker News. "MCP server that reduces Claude Code context consumption by 98%" reached the front page with 570+ points and 107 comments on 2026-02-28 (thread).
  • GitHub Trending. A bot that watches GitHub Trending logged the repo there on 14 days from 2026-04-24 to 2026-10-17 (uibm/trending-watcher).
Companies that stargazers of mksglu/context-mode name in their GitHub profile, Microsoft, Tencent, Alibaba, ByteDance, Google and more.

Starred by engineers at these companies: each name is the company field of 2 or more stargazer profiles, read with the GitHub GraphQL API on 2026-11-01 (data).

Install

Pick your agent: Claude Code · Codex · Gemini CLI · Qwen Code · Pi · OpenCode · Copilot CLI · Kiro · VS Code · ZCode

Open its block and copy its own install command. Each block also holds the update, check and remove steps, and the Install guide walks through them.

The plugin needs Node 24.15.0 or later, from the engines field in package.json. On Windows, add Git for Windows: the shell tools run in Git Bash, and doctor checks for it. contextmode installs as the npm package and command context-mode. Claude Code, Codex, Gemini CLI and Qwen Code install from GitHub, and each of their commands names the release branch.

Claude Code
claude plugin marketplace add mksglu/context-mode
claude plugin install context-mode@context-mode
# update
claude plugin update context-mode@context-mode
# check
claude plugin list
# remove
claude plugin marketplace remove context-mode

Hooks ✓ (package) · MCP ✓ · Skills ✓

Codex
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
# update
codex plugin marketplace upgrade context-mode
# check
codex mcp list
# remove
codex plugin remove context-mode@context-mode

Hooks ✓ (hook file) · MCP ✓ · Skills ✓

Gemini CLI
gemini extensions install https://github.com/mksglu/context-mode
# update
gemini extensions update context-mode
# check
GEMINI_CLI_TRUST_WORKSPACE=true gemini mcp list
# remove
gemini extensions uninstall context-mode

Hooks ✓ (package) · MCP ✓ · Skills ✓

Qwen Code
qwen extensions install https://github.com/mksglu/context-mode:context-mode
# update
qwen extensions update context-mode
# check
qwen extensions list
# remove
qwen extensions uninstall context-mode

Hooks ✓ (package) · MCP ✓ · Skills ✓

Pi
pi install npm:context-mode
# update
pi update --extensions
# check
pi list
# remove
pi remove npm:context-mode

Hooks ✓ (the plugin's own event handlers) · MCP ✓ (ctx tools built into the plugin) · Skills ✓

OpenCode
opencode plugin add context-mode
# update
opencode plugin update
# check
opencode mcp list --pure          # OpenCode 1.19
opencode mcp list --standalone    # OpenCode 2
# remove
opencode plugin remove context-mode

Hooks ✓ (the plugin's own event handlers) · MCP ✓ · Skills ✓

Copilot CLI
npm i -g context-mode
context-mode setup --agents copilot-cli
# update
context-mode upgrade
# check
context-mode doctor --agents copilot-cli
copilot mcp list
# remove
context-mode setup --remove --agents copilot-cli

Hooks ✓ (hook file) · MCP ✓ · Skills ✓

Kiro
npm i -g context-mode
context-mode setup --agents kiro
# update
context-mode upgrade
# check
context-mode doctor --agents kiro
# remove
context-mode setup --remove --agents kiro

Hooks ✓ (hook file) · MCP ✓ · Skills ✓

VS Code (Copilot)
npm i -g context-mode
context-mode setup --agents vscode
# update
context-mode upgrade
# check
context-mode doctor --agents vscode
# remove
context-mode setup --remove --agents vscode

Hooks ✓ (hook file) · MCP ✓ · Skills ✓

ZCode
zcode plugins marketplace add mksglu/context-mode
zcode plugins install context-mode@context-mode
# update
zcode plugins update context-mode@context-mode
# check
zcode plugins list
# remove
zcode plugins uninstall context-mode@context-mode

Hooks ✓ (hook file) · MCP ✓ · Skills ✓

The npm route works for every agent:

npm i -g context-mode
context-mode setup

Setup is also the repair. It shows a plan, saves your earlier config, then applies the plan; when a step ends early, it restores the saved config. To uninstall:

context-mode setup --remove
npm rm -g context-mode

Restart the agent, then run /ctx-doctor in it. Each check prints PASS or a fix command, and the Doctor guide explains each check.

How we tested the install

Every agent gets hooks, the MCP server and the plugin skills; the last line of each block above says how. Hooks reach each agent in one of three ways: in the plugin package (Claude Code, Gemini CLI, Qwen Code), in a hook file (Codex, Copilot CLI, Kiro, VS Code, ZCode), or in a plugin inside the agent (OpenCode, Pi). The Agents guide shows what each agent runs. We ran the real binary of each agent with the plugin hook: Claude Code, Codex, Gemini CLI, Qwen Code, Pi, OpenCode, Copilot CLI and ZCode. Each run used a clean temp home and a local test model, on 2.0.0-next.15. For VS Code and Kiro, the check covers the hook setup: VS Code runs the hook command with the documented payload, and kiro-cli 2.35.2 loads all 6 hook entries. CI runs setup, doctor, a hook and an MCP handshake for all 10 agents from the packed package on Linux, macOS and Windows. Record: HOOKS-FIRE.md. Each agent uses its own install command, and ADR-0023 says why.

Your first task with the plugin, step by step: First session. Or paste a prompt from Try it right now.

Try it

Paste one of these prompts into your agent after the install. Each one ran once, live, in Claude Code 2.1.312, and its answer matched the source data (evidence and rerun steps). The headline numbers in Benchmarks use the median of 5 runs. Other agents do the same job with the same tools: ctx_execute, ctx_index and ctx_search. After a prompt, run the stats skill and read the report yourself (See the saving).

On https://react.dev/reference/react/useEffect, show me the example that connects to a chat server and cleans up, and list the rules for the dependency array.

The hook sends WebFetch to the sandbox, and the agent searches the page for the example and the rules. 601,984 B raw, 20,860 B reached the context, 96.5% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5).

Fetch https://jsonplaceholder.typicode.com/photos. Which photo has the longest title (give its id and title), and how many photos have a title that contains the word "est"?

The agent runs code over 5,000 JSON records in the sandbox and gets back two answers. 1,039,898 B raw, 393 B reached the context, 99.96% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5). The answer is two short facts, so this is the best case of the four.

Here is a Linux syslog sample: https://raw.githubusercontent.com/logpai/loghub/master/Linux/Linux_2k.log. How many authentication failures does it contain, and which 3 remote hosts caused the most?

The agent counts failures in a 1,999-line syslog in the sandbox. 216,485 B raw, 566 B reached the context, 99.7% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5).

What are the top 10 stories on the Hacker News front page right now? Give title, points and domain for each.

The hook sends WebFetch to the sandbox, and the agent reads ten stories from the page. 35,087 B raw, 1,501 B reached the context, 95.7% saved (2026-11-02, 2.0.0-next.26, claude-haiku-5-5). The front page changes, so the raw size changes with each run.

See the saving

Run the stats skill right after a prompt. Each agent uses its own command; the skill calls ctx_stats and shows its report unchanged.

AgentCommand
Claude Code/ctx-stats
Codex$ctx-stats
Copilot CLI/ctx-stats
Gemini CLICall ctx_stats and show me the report.
KiroCall ctx_stats and show me the report.
OpenCodeCall ctx_stats and show me the report.
Pi/skill:ctx-stats
Qwen CodeCall ctx_stats and show me the report.
VS Code (Copilot)/ctx-stats
ZCodeCall ctx_stats and show me the report.

The first lines of a real report, after the JSON prompt above ran as one ctx_execute call:

context-mode stats
────────────────────────────────────────────────────────────────────────────────

This session · 1 call · <1m active
  1015.5 KB became 3.7 KB: 1011.8 KB kept out (99.6%)
  Without context-mode |████████████████████████████████████████|  1015.5 KB
  With context-mode    |█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|     3.7 KB
  about 259K tokens kept out, 1.3 times a 200K window

Captured 2026-11-03 with 2.0.0-next.35: release-out/server.mjs over MCP in a temp HOME.

Next, the same numbers for 20 real tools, in Use cases.

Use cases

Real tool output from public projects, run through Context Mode. Bench of 2026-11-01 on 2.0.0-next.23 (commit 16a4bcc5), median of 5 runs.

What you doToolRawReaches the contextSaved
Read a browser pageChrome DevTools MCP take_snapshot, Thinking in Code136,514 B463 B99.7%
List 40 issuesGitHub CLI gh issue list --json, Thinking in Code182,943 B850 B99.5%
List 25 pull requests with checksGitHub CLI gh pr list --json, Thinking in Code195,471 B776 B99.6%
Look up library docsContext7 query-docs, Thinking in Code6,917 B473 B93.2%
Run 1,106 testsVitest vitest run --reporter=verbose, Thinking in Code62,909 B429 B99.3%
Lint a source folderBiome biome lint --reporter=json, Thinking in Code288,523 B577 B99.8%
Install a workspacepnpm pnpm install --frozen-lockfile, Thinking in Code14,988 B199 B98.7%
Install packagesnpm npm install --loglevel http, Thinking in Code37,761 B435 B98.8%
Read container logsDocker docker logs, Thinking in Code60,374 B587 B99.0%
Plan 72 resourcesTerraform terraform plan, Thinking in Code34,081 B166 B99.5%
Read 300 commits with file statsgit git log --stat, Thinking in Code164,385 B268 B99.8%
Read an 89 KB source fileRead, sent to ctx_execute by the hook91,362 B375 B99.6%
Fetch a 265 KB docs pageWebFetch, sent to ctx_index and ctx_search271,731 B439 B99.8%
Fetch a 214 KB API replycurl in Bash, replaced after it runs219,175 B291 B99.9%
Print a 187 KB git log in BashBash, output replaced after it runs191,120 B204 B99.9%
Print the same git log through a host toolHost tool output over the cap, indexed whole191,120 B2,842 B98.5%
Print a 214 KB GitHub API reply through a host toolHost tool output over the cap, indexed whole219,175 B4,060 B98.1%
Read a 45 KB log fileRead, sent to ctx_execute by the hook46,216 B371 B99.2%
Read a 60 KB source fileRead, sent to ctx_execute by the hook61,576 B374 B99.4%
Debug for a full session: 8 outputs, 3 searchesAll hooks and tools281,261 B3,266 B98.8%

Source: bench/results/2026-11-01-darwin-arm64.json, one row per line; SOURCE.md names where each input comes from. Click a task to open its case: the command, the input file with its sha256, and the run command, so you can run the same row on your machine.

The agent gets the part it asks for. The full output stays in the local index, and ctx_search reads it back. Rows with a command run in the sandbox; the agent then finds the rest with search. The Context7 row has 6,917 B of raw output, under the 10 KB line of the headline rule, so the headline leaves it out.

Next, how the bench counts these bytes, in Benchmarks.

Benchmarks

Bar chart: median output bytes saved per category for rows of 10 KB or more. Sandbox 99.5%, Batch 93.1%, Externalize 98.3%, Hook redirect 99.8%, Session total 98.8%. The table below adds Retrieval, 77.2%.

Rule for every headline number in this README: rows with 10 KB or more of raw output, median of 5 runs per row, measured with ctx_bytes against raw_bytes; a category is the median of its rows; 1 KB = 1,024 B. All 36 such rows, the six categories below: the plugin keeps a median of 99.4% of output bytes out of the context. Bench on 2.0.0-next.23 (commit 16a4bcc5 and the local edits that the file records), macOS arm64, 2026-11-01.

CategoryWhat runsRowsMedian saved
a. Sandboxctx_execute on a file or command1999.5%
b. Retrievalctx_search over the local index377.2%
c. Batchctx_batch: many commands, then search293.1%
d. ExternalizeHost tool output over the cap, indexed whole498.3%
f. Hook redirectA big Read, curl or WebFetch sent to the sandbox799.8%
g. Session totalOne full scripted session198.8%

Search replies (category b) carry the matching text, so they save 77.2%. Category e (long sessions) is in Longer sessions. The full file lists every row, small ones too: 2026-11-01-darwin-arm64.md. Reproduce with cd bench && node run.mjs. It needs plain Node and runs offline; bench/README.md lists each scenario and its options. Method, data files and rerun steps: Benchmarks guide.

Longer sessions

A session grows, the context stays small. The PreToolUse hook sends a tool call to ctx_execute or ctx_index; the full output goes into context.db and a small reply returns. At compaction a snapshot keeps the state, and ctx_resume and ctx_search read it back.

Say you debug a slow test all afternoon. The agent reads files, runs the suite and fetches docs, and each result goes into the context window. When the window is full, the host compacts it, and from then on the agent sees a short summary plus your next message.

Context Mode keeps the full output of each large tool call in context.db on your machine and gives the agent a small reply. At compaction, a snapshot of at most 2,048 B keeps the session state. After the compaction, the agent calls ctx_resume to read that snapshot back and ctx_search to find any earlier output by keyword.

In the bench, a scripted session of 40 tool outputs and one compaction made a 442,893 B transcript, and the ctx_resume block that brought the agent back was 2,019 B (row e-long-session in the bench file; open the case). In the same bench, one large log of 666,796 B put 3,380 B into the context, and the full log stayed in the index for ctx_search (row d-synth-1m; open the case). How the snapshot picks what to keep: the Long sessions guide and ADR-0009.

Speed

Median of 5 runs, bench of 2026-11-01.

MeasureResult
Hook time over a bare node start, per agent7.5 ms to 12.3 ms
ctx_search, 20 queries over 8 indexed files1.62 ms median, 6.70 ms max
ctx_index, 3 real files, 625,649 B150 ms per MB

Source: rows g-hook-kiro to g-hook-claude-code, g-search-latency and g-index-per-mb of the bench file, with every agent and query. The overhead cases show how each one runs.

Next, what happens inside one tool call, in How it works.

How it works

One tool call, step by step: the agent runs a tool, the PreToolUse hook denies a big Read and names the ctx_execute call, the MCP server runs it in the sandbox, SQLite FTS5 keeps the output, and after compaction a state block of at most 2,048 B comes back.

One tool call, in time order, from the install to a hook error.

  1. Install. Each agent's own install command adds the MCP server, the hooks and the skills ctx-doctor, ctx-stats and ctx-upgrade to that agent's config folder, for example ~/.codex/skills/<name>/SKILL.md. context-mode setup writes or repairs any part the native command leaves out (ADR-0023).

  2. Session start. The SessionStart hook opens the project database. When the session ran before, the agent gets one line that tells it to call ctx_resume (dispatch.ts).

  3. PreToolUse checks. Before a tool runs, the PreToolUse hook checks the call in a fixed order: the user's deny list, WebFetch, curl and wget, inline HTTP and build commands, then a full-file Read over OUTPUT_CAP (16,384 B) and one-file shell dumps such as cat or tail. A Read with a line range runs as usual (decide.ts).

  4. The exact call. When a check matches, the hook stops the call and its reply names the exact ctx_* call to use, for example ctx_execute with {"language":"shell","code":"<the command>","intent":"<what you need>"}. For WebFetch the reply names ctx_index, then ctx_search (read-deny.ts).

  5. The sandbox. This is the Thinking in Code step: the agent's script runs here, and only what it prints comes back. ctx_execute writes the script to a temp folder and spawns the runtime from an argument list in the project folder. The timeout is EXEC_TIMEOUT_MS (600,000 ms, default and maximum); on timeout it stops the whole process group (taskkill /F /T on Windows). The child gets your environment minus preload variables such as NODE_OPTIONS, and the agent gets what the script prints, at most OUTPUT_CAP (execute.ts). Thinking in Code. The agent sends a short script as a tool parameter, the script reads the data in the sandbox, and only what it prints goes into the context. Two real calls, in the form the Claude Code terminal shows them:

    ctx_execute on 5,000 JSON records, from the Claude Code 2.1.312 stream of the Try-it run with Context Mode 2.0.0-next.26 (04-api-json.json). The data is 1,039,898 B; the agent gets 254 B.

    ⏺ context-mode - ctx_execute (MCP)(language: "javascript", c…jsonplaceholder.typicode.com/photos\");
      if (!res.ok) throw new Error(\"HTTP \" + res.status);
      const photos = await res.json();
      let longest = null;
      for (const p of photos) {
        if (!longest || p.title.length > longest.title.length) longest = p;
      }
      const withEst = photos.filter(p => p.title.includes(\"est\")).length;
      const ties = photos.filter(p => p.title.length === longest.title.length).map(p => p.id);
      console.log(JSON.stringify({ total: photos.length, longest…nd count of titles containing \"est\"")
      ⎿  exit 0 · 239 B
         {
           "total": 5000,
           "longest": {
             "id": 653,
             "title": "temporibus commodi et fugit doloremque re…rit exercitationem necessitatibus aut",
             "length": 86
           },
           "longestTieIds": [
             653
           ],
           "titlesContainingEst": 892
         }
    

    ctx_batch on an install log and a long git log, one live MCP call to release-out/server.mjs of Context Mode 2.0.0-next.36 on 2026-11-03 (2026-11-03-ctx-batch.json). The commands print 228,881 B; the agent gets 8,667 B, the parts that match its two queries, and the full output stays in the index.

    ⏺ context-mode - ctx_batch (MCP)(commands: ["cat npm-install… queries: ["cache miss","feat commit"])
      ⎿  ## cache miss
         js.org/@esbuild%2fwin32-x64 282ms (cache miss)
         npm http fetch GET 200 https://registry.npmjs.org/@esbuild%2flinux-s390x 79ms (cache miss)
         npm http fetch GET 200 https://registry.npmjs.org/@esbuild%2fopenbsd-x64 101ms (cache miss)
         npm http fetch GET 200 https://registry.npmjs.org/@esbuild%2fwin32-arm64 99ms (cache miss)
         npm http fetch GET 200 https://registry.npmjs.org/@esbuild%2fdarwin-arm64 99ms (cache miss)
         … +95 lines (ctrl+o to expand)
    
  6. Indexing. The full output goes into the index in chunks of at most MAX_CHUNK_BYTES (4,096 B). A Markdown chunk stays inside one heading section, and a code block that fits stays whole. Each chunk goes into two SQLite FTS5 tables: a Porter-stemmed table for words and a trigram table for paths, names and parts of words (fts.ts).

    ctx_index on a copy of this repo's docs/how-it-works.md, one live MCP call to release-out/server.mjs of Context Mode 2.0.0-next.36 on 2026-11-03 (calls.json). The file is 11,577 B; the agent gets 64 B.

    ⏺ context-mode - ctx_index (MCP)(path: "how-it-works.md")
      ⎿  Indexed 1 source(s), 17 chunk(s) from s1. Label: how-it-works.md
    
  7. Search. ctx_search ranks each table with BM25 and joins the two lists with Reciprocal Rank Fusion: a hit scores 1/(RRF_K + rank), with RRF_K = 60. Before it returns an empty list, it tries a spelling fix from the indexed words. Search covers this session, this worktree (the default) or the whole project, and each snippet is at most SNIPPET_MAX_BYTES (800 B) (search.ts).

    ctx_search on that index, in the same run, in a project that also holds an AGENTS.md. One search reads the index and every agent's memory files. The agent gets 1,268 B: one content hit and one memory hit, each with its source and heading. For memory shared across machines, agents and sessions, see Context Mode Gateway Memory.

    ⏺ context-mode - ctx_search (MCP)(queries: ["compaction state block"])
      ⎿  Query "compaction state block":
         how-it-works.md #14: ### Session continuity
         
         The hooks log each prompt, edit, command, tool error, i…e same rows always give the same bytes.
         memory AGENTS.md #0: # Agent rules
         … +10 lines (ctrl+o to expand)
    
  8. Run, then replace. On hosts that run the tool first, the PostToolUse hook checks the result. Output over REPLACE_TRIGGER_BYTES (4,096 B) goes into the index whole, and the agent gets the best-matching chunks and one ctx_search line for the rest (dispatch.ts).

  9. Journal and compaction. The hooks log each prompt, edit, command, tool error and decision in a journal. After a compaction the agent gets a state block of at most STATE_BUDGET (2,048 B), and each long line becomes a ctx_resume(seq) pointer to the full row; one ctx_resume reply is at most RESUME_CAP (2,048 B). On the next prompt, a prompt-match block brings back the journal rows that match it by BM25 (ADR-0009).

    ctx_resume with empty parameters returns the state block, in the same run: 209 B.

    ⏺ context-mode - ctx_resume (MCP)()
      ⎿  <context_mode_state session="mcp:85e67fa2-28ef-45eb-9d5b-a967129b74c0" upto="2">
         indexed how-it-works.md
         source s1: how-it-works.md (11536 B)
         more: ctx_search(queries:[], scope:"session")
         </context_mode_state>
    
  10. The database. Each project has one context.db under ~/.context-mode, in Node's built-in node:sqlite. The database runs in WAL mode and runs a PASSIVE checkpoint on close. A new database gets built under a temp name and moves into place in one atomic step, and the busy timeout is DB_TIMEOUT_MS (5,000 ms) (db.ts).

  11. A hook error. A hook always ends with exit 0. On any error it gives the host's allow reply and writes one log line to ~/.context-mode/hook-errors.log, so your agent keeps working. A spawned hook has HOOK_TIMEOUT_MS (5,000 ms) (fallback.ts).

Every number with its reason: How it works. The rules the hook follows: ADR-0008. Next, the Tools the agent calls.

Tools

ToolWhat it does
ctx_executeRuns code or a shell command in a sandbox; returns what it prints
ctx_batchRuns many commands, indexes the output, and searches it in one call
ctx_indexIndexes a file, a text or a URL into the project database
ctx_searchSearches the local index; returns the matching parts
ctx_resumeReturns the plugin's local state block (at most 2,048 B), or one full row by seq
ctx_statsShows how much output stayed out of context
ctx_doctorChecks the install; each check prints PASS or a fix command
ctx_upgradeInstalls, upgrades or uninstalls; replaces old contextmode entries
ctx_purgeDeletes indexed data by session, source or project

Three more real calls, from the same live run of Context Mode 2.0.0-next.36 on 2026-11-03 (calls.json).

ctx_stats: the agent gets 3,097 B, the first line is the summary.

⏺ context-mode - ctx_stats (MCP)()
  ⎿  ctx_stats: 82.5% kept out all-time, 82.5% this session.
     … +59 lines (ctrl+o to expand)

ctx_doctor after context-mode setup --agents claude-code: 862 B, one row per check.

⏺ context-mode - ctx_doctor (MCP)()
  ⎿  Environment: context-mode 2.0.0-next.36 (8facf27), agent claude-code 0 (client r20-live)
     Environment: darwin-arm64, Node v26.8.1, shell /bin/zsh
     | Check | Status | Detail | Fix |
     |---|---|---|---|
     | D1 version | PASS | 2.0.0-next.36 (8facf27): ahead of next on npm (2.0.0-next.34) |  |
     | D2 node | PASS | ok |  |
     … +11 lines (ctrl+o to expand)

ctx_purge deletes one source: 66 B.

⏺ context-mode - ctx_purge (MCP)(source: "how-it-works.md")
  ⎿  ctx_purge: deleted 18 rows (scope: source). This cannot be undone.

Full reference: Tools.

Commands in the agent: /ctx-stats shows the ctx_stats result, /ctx-doctor runs ctx_doctor (send its report with a defect report), and /ctx-upgrade runs ctx_upgrade, then ctx_doctor.

Security and privacy

  • The plugin keeps all its data on your machine, one database per project in ~/.context-mode, and ctx_purge deletes it by session, source or project. Read the Security guide.
  • The plugin has zero telemetry: usage data, events and crash reports stay on your machine. It uses the network for four calls, each one started by you or your agent:
CallWhenFile
Fetch of a URL, for ctx_indexYour agent asks for a page. The fetch blocks private and link-local addresses, checks each address the host name points to, connects to the address it checked, and checks again at each redirect.fetch.ts
One read of the npm dist-tags, with git ls-remote of the release tags as the fallbackYou run context-mode doctor, to check for a new versiondoctor-env.ts
npm i -g context-mode, or gh issue createYou run context-mode upgrade, or you press a key to send the debug reportcommands.ts
Your agent's own install command, npm or gitYou install or updateYour agent
  • The guard test D-PRIVACY-NET-1 in tests/0008-enforcement.test.mjs scans the source for HTTP clients, sockets, DNS lookups, git network calls and gh or npm spawns. It flags each new call site, so this table stays true.
  • Doctor and the debug report remove secrets by their structure before they print.

Code from ctx_execute runs on your host as your user, with your files, your network and your environment except the preload variables, so keep your agent's own permission prompts on. Here "sandbox" means the output stays in the sandbox and out of the context. What the plugin stores, where, and how to delete it: Privacy.

Context Mode Gateway

The plugin works on tool output, on your machine, and it is complete on its own. Context Mode Gateway is a separate hosted service with its own account and subscription. It works on every request, across all your agents. Its 11 features, the full list: Context Saving, Recall, Memory, Skills, Search, Session resume, Active Context, Instructions, Protect, Prompt caching, Live and Analytics. Add the Gateway when you want savings on every request, memory across sessions and agents, or cost reports for a team. For one project on one machine, the plugin covers the job. The two work together: Gateway guide. Gateway Recall, Search and Session resume run on the Gateway server, across sessions and agents. The plugin's ctx_search and ctx_resume read the local context.db of one project. With the Gateway on, your requests pass through its server; the plugin keeps its own data on your machine.

ProductRunsScopeBilling
Context Mode pluginOn your machineOne project, local context.dbFree
Context Mode GatewayHosted serviceAll sessions and agentsSubscription, separate from the plugin

Set up the Gateway with one command:

npx @context-mode/cli

npx @context-mode/cli signs you in to your Gateway account, which has its own subscription, and writes one config change per agent. Apps: Claude Code, Claude Desktop, Codex, Codex Desktop, T3 Code, OpenCode and Pi. The Gateway CLI needs Node 20.12 or later, from its npm engines field.

Gateway Live screen during a session: money saved, bytes kept out per request, history kept and sent, and a feed of each request with its cost and saving

Live. One session as it runs: money saved this session, bytes kept out per request, history kept and sent, and a feed of each request with its cost and saving. Click the image for the full video.

Docs: How saving works

Gateway Overview: money saved, AI spend, prompt-cache discount and cost per request over 30 days
Overview. Your spend and what the Gateway saved, per day, in one view.
Docs: How saving works
Gateway Analytics: saved money over time, split by source
Analytics. Where each saving comes from: hidden tools, archived old results, large outputs kept in the archive and trimmed context.
Docs: How saving works
Gateway Spend: spend per day by model, cost per request and cache hit rate
Spend. Spend per day and per model, cost per request and the cache hit rate, to help you plan a budget.
Docs: Prompt caching
Gateway Memory: money saved by Recall and searches per day
Memory. Facts and decisions carry across sessions and agents. The screen shows what Recall saved and how many searches found an answer.
Docs: Memory
Gateway Skills: import from GitHub and the list of installed skills
Skills. Add a skill once and all your clients use it when it helps. Import skills from GitHub and see the installed ones.
Docs: Skills
Gateway Protect: a new command rule that blocks terraform destroy
Protect. Rules that check each shell command before it runs. Here, a rule that stops terraform destroy.
Docs: Protect

Numbers in these screens come from the author's own account over 30 days (Oct 3 - Nov 1, 2026), so read them as one account's usage. Click an image for the full size.

Three prompts to try with the Gateway on. The line under each one names the feature it shows.

Move this project from Jest to Vitest. Convert every test file, fix the config, run the suite after each batch, and tell me what is left.

Memory keeps the plan and the file list across a long job.

Pick up where we stopped yesterday on the Jest to Vitest move. What is done, what is left, and which test was failing?

Recall brings back yesterday's work in a fresh session.

Which date library did we choose on Tuesday, and why did we reject the other two?

Search finds the answer in past sessions.

Gateway features, from contextmode.ai/docs

Source: contextmode.ai/docs:

FeatureWhat it doesWhat you getDetails
Context SavingFolds old tool output, runs data work as code (Thinking in Code), trims tool schemas, places cache marksA tool output over 2,048 B becomes a short pointer, with the full copy archivedSaves the most on sessions with many tool calls
RecallThe model sees recent work and an index of older work; the agent searches the archive for the restGateway, Claude Code, Opus 5.5, 200K window, 2026-10-04: mean cost per session $4.8627 to $3.0353 (-37.6% in dollars, ab.json below)Cost measured in Claude Code on Claude Opus 5.5
MemoryEach fact keeps two times: when it was true and when the Gateway learned itClaude Code and Codex on one account share one store, tested end to endThe memory block goes into the first request of a new session
SkillsA skill catalog on the Gateway for your account; it loads the skill that matches your messageThe matching skill loads on the message that needs itImport skills from GitHub; a loaded skill joins the prompt in full
SearchSearches the prompts, commands and tool output that passed through, in the console and as an agent toolFind any past prompt, command or tool output, from the console or your agentThe console searches the first 4,000 characters of each tool result
Session resumeOne command rebuilds a conversation as a native Claude Code or Codex sessionContinue a conversation in Claude Code or CodexRestores the text, tool names and a summary; the command is valid for 15 minutes
Active ContextSets how much a thread carries before its oldest parts move to the archive: 200K, 500K or 1M tokensPick the window size per threadAn image older than the kept part becomes a short text note
InstructionsOne text of at most 4,096 characters that tells every agent how to answer youRead from the provider cache after the first requestSets how the agent writes to you
ProtectA tool-call firewall: checks shell commands, file reads and writes, web fetches and tool-server calls by what they doEach call checked before it runsReads the call itself, so keep your agent's sandbox on for script files and paths built at run time; opt-in
Prompt cachingKeeps requests cache-friendly: cache marks on the fixed part of the prompt and a cache for fetched pagesInside the measured costs aboveUses up to 4 cache marks, the provider's maximum
Live and AnalyticsShows each request and what the Gateway saved, as it happens and over timeSee each request and its saving, live and over timeCovers every request that passes through the Gateway

Gateway only: its cost against Claude Code alone, Claude Opus 5.5, mean dollars per session at list price. The plugin numbers are in Benchmarks.

  • Six short tasks (2026-09-29): 24.5% fewer dollars pooled over 176 sessions (21% to 29% per task). v3-opus55-short.json
  • Long Claude Code session, 200K window (2026-10-03/04): mean cost per session $4.8627 to $3.0353 (-37.6% in dollars, mean of 3 pairs). ab.json
  • We fixed the rules before each run: contextmode.ai/docs/benchmarks.

The Gateway routes to Anthropic and OpenAI. The Gateway sends your requests to its server on the way to the model. It keeps a searchable record of your sessions for Recall and Search, and masks secrets and e-mail addresses when it reads archived output back. Its privacy page is at contextmode.ai/privacy. Keep your agent's own sandbox on next to Protect.

License

Elastic License 2.0 (ELv2, the LICENSE file), a source-available license. You may use, copy, change and share the code, and use it at work, free of charge. The license keeps three uses for the licensor:

  1. Offering the software to others as a hosted or managed service that gives them a large part of its features.
  2. Moving, changing, turning off or getting around the license key functions, or removing or hiding what the license key protects.
  3. Changing, removing or hiding the licensor's license, copyright or other notices.

We chose ELv2 so the source stays open to all and the hosted service stays with the project.

Community

Report a defect on Discord with the full /ctx-doctor report, and send ideas there too. The maintainer writes every change; CONTRIBUTING.md shows how an agent files an issue.

Videos. Better Stack on Context Mode. Make your own video and share it on Discord; we add videos over 10K views here.