headroom
БесплатноБез исполняемых скриптовНе проверенHeadroom is a local compression layer that shrinks tool outputs, logs, JSON, files and RAG chunks before they reach an LLM, so long agent sessions cost fewer…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Headroom — compress what your agent reads before the model sees it
Overview
Headroom sits between an application or coding agent and the LLM provider. It finds large, repetitive payloads (JSON arrays, logs, search results, code) and replaces them with a smaller version. Errors, outliers and first and last items are kept. The originals are cached locally, and the model can fetch them again through a headroom_retrieve tool. Compression runs on your machine.
The package name is headroom-ai on both PyPI and npm. The headroom command ships only in the PyPI package; the npm package is a TypeScript SDK with no CLI.
Savings depend on the payload. Repetitive JSON and logs shrink a lot; short chat turns, prose and already-dense output barely shrink. Headroom does not choose cheaper models or cache answers; for that, use a routing or caching tool.
Instructions
Install
python3 -m venv ~/.venvs/headroom
~/.venvs/headroom/bin/pip install "headroom-ai[proxy]"
The base package gives compress() and the CLI. Add extras as needed: [proxy] for the server, [mcp], [ml] (the Kompress text model), [code], [memory], or [all] for everything except the framework adapters ([langchain], [agno], [strands]). Alternatively uv tool install --python 3.13 "headroom-ai[all]". TypeScript: npm install headroom-ai.
To switch telemetry off, set HEADROOM_TELEMETRY=off (also DO_NOT_TRACK=1 or HEADROOM_OFFLINE=1).
Library: compress a message list
compress(messages, model=...) takes OpenAI-format or Anthropic-format messages and returns a result object with messages, tokens_before, tokens_after, tokens_saved, compression_ratio and transforms_applied.
import json
from headroom import compress
rows = [{"id": i, "host": f"web-{i % 4}", "status": "ok", "latency_ms": 20 + i % 3,
"msg": "request completed"} for i in range(300)]
rows[137] = {"id": 137, "host": "web-1", "status": "FATAL", "latency_ms": 9000,
"msg": "disk full on /var/lib/postgres"}
messages = [
{"role": "user", "content": "Why did the health checks fail?"},
{"role": "assistant", "content": None, "tool_calls": [
{"id": "call_1", "type": "function",
"function": {"name": "list_checks", "arguments": "{}"}}]},
{"role": "tool", "tool_call_id": "call_1", "content": json.dumps(rows)},
]
result = compress(messages, model="gpt-4o")
print(result.tokens_before, result.tokens_after, f"{result.compression_ratio:.0%}")
Send result.messages to the provider instead of the original list. Useful keyword arguments: target_ratio (lower is more aggressive), protect_recent (recent messages left untouched), compress_user_messages=True for long user-supplied documents, optimize=False for an A/B passthrough. Set model to the model you actually call; it drives token counting.
Proxy: no code changes
~/.venvs/headroom/bin/headroom proxy --port 8787
The proxy binds to 127.0.0.1 by default. Point a client at it:
ANTHROPIC_BASE_URL=http://127.0.0.1:8787 claude
OPENAI_BASE_URL=http://127.0.0.1:8787/v1 python app.py
Check it with headroom doctor --port 8787 (exit code 0 healthy, 1 warnings, 2 failure), curl http://127.0.0.1:8787/health, and curl http://127.0.0.1:8787/stats for token counters. headroom dashboard opens the savings view; headroom savings shows the history.
Modes: --mode cache (default) freezes earlier turns so the provider prompt cache keeps hitting; --mode token rewrites earlier turns for maximum savings. --no-optimize makes the proxy a plain passthrough, which is useful for comparing.
For a third-party OpenAI-compatible provider, pass its URL (--openai-api-url https://api.deepseek.com/v1 on wrap, or set OPENAI_TARGET_API_URL), otherwise your key goes to api.openai.com and fails with 401.
Wrap a coding agent
headroom wrap claude # starts the proxy, launches Claude Code through it
headroom wrap codex
headroom wrap claude --code-memory none # skip registering the Serena MCP server
headroom unwrap claude # undo durable changes
wrap also supports aider, copilot, cursor (prints settings to paste), cline, continue, goose, opencode and others; run headroom wrap --help. By default wrap claude registers the Serena code-navigation MCP server for the project in ~/.claude.json and an MCP tool for retrieval; use --no-mcp or --code-memory none to skip them.
MCP server and output reduction
headroom mcp install # registers the MCP server for Claude Code
HEADROOM_OUTPUT_SHAPER=1 headroom proxy --port 8787 # also ask the model to be terse
headroom output-savings # estimated, with a confidence interval
The MCP tools are headroom_compress, headroom_retrieve and headroom_stats.
Learn from failed sessions
headroom learn --verbosity # preview only
headroom learn --verbosity --appl
Установить headroom в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл headroom?
Headroom is a local compression layer that shrinks tool outputs, logs, JSON, files and RAG chunks before they reach an LLM, so long agent sessions cost fewer tokens. It runs as a Python or TypeScript library, an HTTP proxy, a wrapper for coding agents, or an MCP server. Use it when a user asks to "cut token usage", "compress tool output", "reduce my Claude Code bill", "run headroom proxy", "wrap claude with headroom", or "call compress() on messages".
Как установить скилл headroom?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл headroom запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic