Install
openclaw skills install @johnsonbuilds/token-compressionCompress AI Agent tool outputs, logs, and RAG content using Headroom — reduce token usage by 20-95%
openclaw skills install @johnsonbuilds/token-compressionCompress content sent to LLMs (tool outputs, logs, RAG chunks, files) while maintaining answer quality — reduces token consumption by 20-95%.
Headroom caches raw uncompressed content locally (for later retrieval). This means:
Data that should NOT be processed:
If processing sensitive data, ensure: ① device has encrypted storage; ② regularly clean headroom cache directory (~/.headroom/cache).
Only use this skill in the following explicit scenarios:
NOT suitable for:
# Using uv (recommended)
uv tool install --python 3.13 "headroom-ai[all]"
# Or using pip
pip install "headroom-ai[all]"
headroom deploy
Automatically configures local deployment and agent integration.
# Wrap Claude Code
headroom wrap claude
# Wrap Codex
headroom wrap codex
# Wrap OpenCode
headroom wrap opencode
Use headroom unwrap <tool> to remove wrapping.
Note: Wrap operations modify agent startup configuration. Make sure you know what you're doing.
headroom proxy --port 8787
Any OpenAI-compatible client can use this proxy by setting API base URL.
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%})")
headroom mcp install
Provides headroom_compress, headroom_retrieve, headroom_stats tools to any MCP client.
# Health check
headroom doctor
# View savings stats
headroom perf
# Real-time dashboard (requires running proxy)
headroom dashboard
| Scenario | Before | After | Savings |
|---|---|---|---|
| Code search (100 results) | 17,199 tokens | 13,597 tokens | 21% |
| SRE incident debugging | 55,957 tokens | 24,340 tokens | 57% |
| Codebase exploration | 58,801 tokens | 33,895 tokens | 42% |
| GitHub Issue classification | 46,067 tokens | 32,429 tokens | 30% |
JSON duplicate data can save 90%+. Plain text content compresses less.
# Enable output compression
export HEADROOM_OUTPUT_SHAPER=1
headroom proxy --port 8787
# Auto-learn your verbosity preferences
headroom learn --verbosity
headroom learn --verbosity --apply
| Agent | Support |
|---|---|
| Claude Code | ✅ |
| Codex | ✅ |
| OpenCode | ✅ |
| Cursor | Manual config |
| Aider | ✅ |
| Copilot CLI | ✅ |
| Cline | ✅ |
| Continue | ✅ |
| Goose | ✅ |
| OpenHands | ✅ |
headroom_retrieve. To clear cache, delete ~/.headroom/cache directory.http://localhost:8787 as API base.