Memory

Headroom Token Compression

Try it

Compress AI Agent tool outputs, logs, and RAG content using Headroom — reduce token usage by 20-95%

What it does

Compress content sent to LLMs (tool outputs, logs, RAG chunks, files) while maintaining answer quality — reduces token consumption by 20-95%.

The skill document

Headroom Token Compression

Compress content sent to LLMs (tool outputs, logs, RAG chunks, files) while maintaining answer quality — reduces token consumption by 20-95%.

Source

Trigger Conditions

  • Agent processing large tool outputs with high token costs
  • Need to compress logs, code search results, JSON data
  • Using MCP servers that return large amounts of data
  • Want to reduce token consumption in Claude Code, Codex, Cursor, etc.

Installation

# Using uv (recommended)
uv tool install --python 3.13 "headroom-ai[all]"

# Or using pip
pip install "headroom-ai[all]"

Usage

1. One-Click Deploy (Simplest)

headroom deploy

Automatically configures local deployment and agent integration.

2. Wrap Common Agents

# Wrap Claude Code
headroom wrap claude

# Wrap Codex
headroom wrap codex

# Wrap OpenCode
headroom wrap opencode

Use headroom unwrap to remove wrapping.

3. Proxy Mode (Zero Code Changes)

headroom proxy --port 8787

Any OpenAI-compatible client can use this proxy by setting API base URL.

4. Python Library (Inline Use)

from headroom import compress
from openai import OpenAI

messages = [{"role": "user", "content": "Analyze these results"}]
result = compress(messages, model="gpt-4o")

client = OpenAI()
response = client.chat.completions.create(model="gpt-4o", messages=result.messages)
print(f"Saved {result.tokens_saved} tokens ({result.compression_ratio:.0%})")

5. MCP Server Mode

headroom mcp install

Provides headroom_compress, headroom_retrieve, headroom_stats tools to any MCP client.

Verify Installation

# Health check
headroom doctor

# View savings stats
headroom perf

# Real-time dashboard (requires running proxy)
headroom dashboard

Compression Results

ScenarioBeforeAfterSavings
Code search (100 results)17,199 tokens13,597 tokens21%
SRE incident debugging55,957 tokens24,340 tokens57%
Codebase exploration58,801 tokens33,895 tokens42%
GitHub Issue classification46,067 tokens32,429 tokens30%

JSON duplicate data can save 90%+. Plain text content compresses less.

Output Compression (Reduce Model Response Tokens)

# Enable output compression
export HEADROOM_OUTPUT_SHAPER=1
headroom proxy --port 8787

# Auto-learn your verbosity preferences
headroom learn --verbosity
headroom learn --verbosity --apply

Supported Agents

AgentSupport
Claude Code✅
Codex✅
OpenCode✅
CursorManual config
Aider✅
Copilot CLI✅
Cline✅
Continue✅
Goose✅
OpenHands✅

Pitfalls

  • Local processing — compression runs locally, content never sent to external services
  • Original content cached — raw content cached locally, models can retrieve full content via headroom_retrieve
  • Proxy mode — when using proxy mode, configure client to use http://localhost:8787 as API base
  • Output shaping is optional — disabled by default, must be enabled manually

References

Related skills

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

More from johnsonbuilds

Browse all skills

Design and generate international-brand-quality product detail pages for cross-border e-commerce. Generates complete product page content (Hero, Features, Lifestyle, Specs, FAQ) plus AI image prompts and visual assets for any consumer electronics product. Output meets Apple/Nothing brand standards.

by johnsonbuilds2 installs

Generate or edit AI media (image, video, audio, 3D) by calling the wavespeed CLI on the user's machine. Use whenever the user asks to create, edit, animate, upscale, or transform a visual asset, generate audio/TTS/music, or produce marketing creatives. Every model on the WaveSpeed platform is one `wavespeed run <id>` call.

by johnsonbuilds1 installs

Worklittle Jobs MCP — search 4M+ jobs with visa/salary/distance filters, swipe to apply, create resumes & cover letters, and connect your Worklittle account

by johnsonbuilds

Turn any topic into animated explainer videos — Remotion-driven, TTS voiceover, bilingual (Chinese/English)

by johnsonbuilds1 installs

261 hand-drawn style prompt catalog with numbered system — supports GPT Image, Midjourney, and other AI image generators

by johnsonbuilds3 installs

CLI tool to find which LLM models run on your local hardware — checks GPU/CPU/RAM and returns compatible models

by johnsonbuilds1 installs