|
93%
token reduction
aggressive mode
|
Searchable
indexed data retained
FTS5 + BM25
|
4 modes
incl. LLM-judged
auto • aggressive • balanced • conservative
|
Plugins
Codex + Claude
MCP • hooks • skills
|
Quickstart
# 1. Install
npm install -g context-compress
# 2. One-line setup — registers the MCP server, installs the hook,
# enables transparent Bash compression
context-compress setup --auto
# 3. (optional) Pick a mode for the session
export CONTEXT_COMPRESS_MODE=balanced # or: aggressive, conservative, auto
That's it. Restart Claude Code and shell output is now compressed before it enters context.
Prefer no MCP at all? context-compress wrap "<cmd>" compresses any shell command's output — drop-in for RTK. See CLI.
Quickstart for AI agents — paste this prompt and your agent will install it
Install context-compress — an MCP server that compresses tool output for Claude Code.
Only the printed or filtered response enters your context window.
For searchable retention, use index, fetch_and_index, batch_execute, or intent on a large execute call.
npm install -g context-compress
context-compress setup --auto
context-compress doctor
More info: https://github.com/Open330/context-compress
Why?
Every byte of tool output that enters your Claude Code context window reduces quality and speed.
A single git log or npm test can dump 50KB+ into context — that's ~12,000 tokens gone.
context-compress intercepts these tools, processes output in a sandbox, and returns only what matters:
Before: git log --oneline -100 → 8.2KB into context
After: execute(..., intent: "recent changes") → 0.3KB summary + bounded pre-filter data searchable in FTS5
It works in two modes that compose freely:
- MCP server — registers as a Claude Code MCP server with 8 tools (
execute, search, batch_execute, fetch_and_index, index, execute_file, stats, discover). Agents call them directly when output would be large.
- Standalone CLI —
context-compress wrap "<cmd>" runs any shell command and pipes the output through the same compression pipeline. Drop-in for RTK and friends. The PreToolUse hook can route Bash calls through it transparently when CONTEXT_COMPRESS_FILTER_BASH=1. This is response-only compression: detail omitted by a filter is not indexed or available to search.
Based on context-mode by Mert Koseoğlu — rewritten in TypeScript with security hardening, architectural improvements, and better DX.
Getting Started
Install
npm install -g context-compress
Plugin Support
context-compress now ships plugin metadata for agent hosts: