sqz compresses tool output before it enters an AI coding agent's context window. Agents spend most of their input tokens on build logs, test runs, git status and the same file read again after every edit, and all of it is re-sent on every later turn. sqz installs as a pre-tool hook that intercepts shell commands, runs the output through per-command formatters that keep what the agent acts on (the failing test, the assertion, the file and line) and drop the rest, and returns a short reference in place of anything the model already has in context. Source code, stack traces, error messages and secrets pass through untouched. It is a single Rust binary, deterministic, makes no LLM calls, works offline, and every compressed result can be recovered byte-exact.
The pipeline has six stages. More than 45 per-command formatters across 12 ecosystems cover commands such as git, cargo, npm, pytest, go test, docker, kubectl and terraform, and unknown commands fall through to a generic path. A table compactor collapses padded columns from tools without a formatter. Structural summaries reduce a code file to imports, signatures and call graph. A SHA-256 dedup cache persists across sessions: byte-identical output becomes a 13-token reference, a line range of a file already in context becomes a range reference, and a re-read after a small edit returns only the changed lines, with references served only while the original is still in context. A JSON stage strips nulls, drops debug fields, flattens, collapses arrays and applies TOON encoding. A safe mode detects stack traces, secrets and migrations by entropy analysis and routes them through at 0% compression. A 16-token net-win gate skips compressions that would not pay for their own markers, compression is query-agnostic so provider prompt caches are never invalidated, history is never rewritten, and piped or redirected commands are never intercepted.
Supported clients: Claude Code, Cursor, Windsurf, Cline and Copilot CLI through pre-tool hooks, Gemini CLI through a BeforeTool hook, OpenCode through a TypeScript plugin, Kiro, Codex CLI and Zed through agent guidance plus an MCP server, the Copilot coding agent in CI through a repo-level hook, any CI pipeline through a GitHub Action that compresses logs before an LLM step, VS Code and JetBrains extensions, and Chrome and Firefox extensions for ChatGPT, Claude.ai, Gemini, Grok and Perplexity. An MCP proxy sits between the agent and any stdio MCP server, compresses the tool results that flow back, compacts verbose tool descriptions so the tool list stops consuming context, and injects an expand tool so the agent can recover any original.
Everything that flows through sqz is indexed locally in SQLite full-text search, so a recall command (also an MCP tool) finds an error message from an hour ago after the agent's context has been compacted. A gain report shows daily savings, a stats report estimates dollars saved under a prompt-cached billing model with every assumption printed and overridable, and regret signals (quick byte-identical re-runs and reference expands) point at formatters that dropped something the model needed. There is no telemetry and all processing is local.
| Measurement | Before | After | Saved |
|---|---|---|---|
| Repeated log lines | 148 | 62 | 58% |
| Large JSON array | 259 | 142 | 45% |
| Git diff | 61 | 54 | 12% |
| Stack trace (safe mode) | 82 | 82 | 0% |
| Unchanged git status run again | 155 | 13 | 92% |
| Lines 41-80 of a 200-line file read earlier | 305 | 16 | 95% |
| Same cargo test output, nothing changed | 303 | 13 | 96% |
Features
- Per-command formatters: more than 45 formatters across git, Rust, JavaScript, Python, Go, cloud, containers, JVM, mobile, .NET, system and GitHub tooling, with a generic fallback for unknown commands
- Session dedup: a SHA-256 cache persisted across sessions returns a 13-token reference for output the model already has, a range reference for a partial re-read, and only the changed lines after an edit
- Safe mode: stack traces, error messages, secrets and migrations are detected by entropy analysis and passed through at 0% compression
- Structural summaries: code files reduced to imports, function signatures and call graph
- JSON pipeline: strips nulls, drops debug fields, flattens, collapses arrays and applies lossless TOON encoding
- Byte-exact recovery: every compressed result and every reference can be expanded back to the original
- Client coverage: Claude Code, Cursor, Windsurf, Cline, Copilot CLI, Gemini CLI, OpenCode, Kiro, Codex CLI, Zed, VS Code, JetBrains, Chrome and Firefox
- MCP proxy: wraps any stdio MCP server, compresses its tool results, shortens tool descriptions on demand and injects an expand tool
- CI support: a repo-level hook for the Copilot coding agent and a GitHub Action that compresses logs before an LLM step
- Recall: local SQLite full-text search over everything sqz has seen, as a CLI command and an MCP tool
- Savings accounting: daily gain reports, a prompt-cache-aware cost estimate with overridable assumptions, and regret signals for dropped content
- Prompt-cache safe: deterministic, query-agnostic compression that touches only new tool output and never rewrites history

