Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sqz: context compression for AI coding agents

sqz compresses tool output before it enters the model’s context window. It runs as a hook and an MCP server for Claude Code, Cursor, Windsurf, Cline, Gemini CLI, Codex, Kiro, Zed and Copilot CLI, and as a proxy in front of any other MCP server. Deterministic Rust, no LLM calls, offline, and every compressed result can be recovered byte-exact.

cargo install sqz-cli sqz-mcp     # or: brew install ojuschugh1/sqz/sqz · npm i -g sqz-cli · pipx install sqz
sqz init                          # installs hooks, MCP server and agent guidance for every client it finds

Then work as usual. sqz stats --breakdown shows what it saved, per command, from your own sessions. sqz doctor verifies the whole chain: binary, database, shell hook, which clients are actually routed through sqz, and whether anything was compressed recently.

Not installed yet? If you already use Claude Code or Kiro, sqz discover --replay replays your existing transcripts through the engine and reports what it would have saved — a counterfactual estimate on your own sessions, computed locally.

Where the tokens actually go

Across 3,003 real compressions sqz saved 178,442 tokens, a 24.7% average reduction. That number is deliberately not the headline, because most of the tools in this space are graded on ratio alone, and a compressor that hits 90% by dropping the line the agent needed has made the session more expensive.

What the data shows instead:

  • Command output dominates. Build logs, test runs, git status, package installs. A 1,200-token cargo test with one failure becomes the failure, the assertion and the file:line, about 120 tokens. Forty-five commands have purpose-built formatters; unknown output goes through a generic pipeline that folds repeated lines and never touches source code, stack traces or secrets.
  • Identical file re-reads are rare. Measured on 92 Claude Code sessions by a user who counted: 1 in 542 reads. What repeats is unchanged command output (a 13-token §ref§), line ranges of a file already read in full (a §ref:HASH:L40-80§), and files re-read after a small edit (a line-level delta).
  • Over-compression is tracked, not hidden. sqz stats reports how often the agent re-ran a command whose output had not changed, or asked for an original back. Those regret signals sit next to the savings so you can discount the number yourself.

Guides

Measurements

Integrations

Reference