Gemini CLI · Updated 2026-11-16
Reduce Gemini CLI Token Usage: Compress Tool Output
Gemini CLI can read a lot at once, which makes it easy to fill a session with whole files and long command output. Here is where Gemini CLI tokens go and how SuperCompress lets the agent keep only the lines that answer your question.
/stats to watch usage, /compress or /clear when a session gets long, and keep GEMINI.md short. Then run npm install -g supercompress-proxy && supercompress setup to add the SuperCompress MCP server to Gemini CLI.
Where Gemini CLI tokens go
- File reads. Reading whole files or folders brings everything in at once.
- Shell output. Full test and build logs.
- MCP servers. Tool definitions plus results.
- Context files.
GEMINI.mdfiles are loaded into the session.
Habits that cut Gemini CLI token usage for free
- Check usage.
/statsshows token use for the session. - Compress or clear long sessions.
/compressreplaces the history with a summary;/clearstarts over. - Read narrowly. Point at the files you mean instead of whole directories.
- Keep
GEMINI.mdshort. It is loaded every session. - Only enable the MCP servers you use.
These habits shrink what goes in. They don't help when the agent genuinely needs to run a test suite or read a large file and only a few lines of the output matter. That is the part SuperCompress handles.
How SuperCompress works
SuperCompress is hosted, extractive and query-aware. Your agent sends a large block of context (a log, a diff, a file read, an MCP result) together with the question it is working on. It keeps the original lines that answer that question and drops the rest. It selects lines from the original rather than writing a summary, so file paths, error messages, IDs and code in the kept lines stay as written; preprocessing may rewrite JSON or collapse repeated stack frames before lines are chosen. See how prompt compression works. The question itself is never compressed.
In Gemini CLI the compress_context MCP tool reports original_tokens and compressed_tokens (the hosted API calls the second one kept_tokens); they are estimates, not provider-billed totals, and when the savings would be too small the tool returns a passthrough notice instead of a digest (no compressed_tokens, and the content is not sent back), so the agent keeps using its original text. The usage_summary MCP tool shows what your account saved this month.
What supercompress setup adds to Gemini CLI
| What | Where | What it does |
|---|---|---|
| MCP server | ~/.gemini/settings.json (mcpServers.supercompress) | Gives the agent the compress_context, connect_account and usage_summary tools. |
Install
npm install -g supercompress-proxy && supercompress setup
Setup links your SuperCompress account in the browser, detects the coding agents on the machine and wires each one. Restart the agent so it loads the new MCP server. Then check what is wired up:
supercompress doctor
doctor prints a per-agent health check. supercompress uninstall removes only the entries SuperCompress added. Setup backs up each config file before it edits it.
Comparing this with other ways to cut tokens? See context compression for coding agents.
How this differs from /compress
Gemini CLI's /compress summarizes the whole history in its own words. SuperCompress works on one bulky result at a time and keeps original lines, so exact errors, paths and code survive. Use both: SuperCompress on large new output, /compress when the session itself gets long.
When to skip it
- Short sessions with small tool results. There is little to drop.
- Files the agent is about to edit line by line. It needs those in full.
- Work where every byte must be passed through unchanged for compliance reasons.
FAQ
Does SuperCompress change how I sign in to Gemini CLI?
No. You keep your normal Gemini CLI login and models. SuperCompress adds an MCP server and instructions to Gemini CLI; your model traffic does not pass through SuperCompress.
Does SuperCompress summarize what Gemini CLI reads?
No. It is extractive. It keeps lines copied from the original output rather than writing a summary, so file paths, error messages and code in the kept lines stay as written. Preprocessing may rewrite JSON or collapse repeated stack frames first.
How do I undo the Gemini CLI setup?
Run supercompress uninstall. It removes only the entries SuperCompress added, so your other MCP servers, hooks and instructions stay as they were.