Skip to content
Skills Library
AI & agents · Automation

headroom

/headroom

Token-reduction skill for coding agents. Compresses JSON tool output, build logs, grep/ripgrep search results, source code, and conversation history the same way the Headroom proxy does — but in-context, with no binary install. Use this skill whenever an agent is about to paste a large tool result (a 1000-row JSON array, a 5000-line pytest log, a 200-result grep, a 1000-line source file) into its next message, or when the agent's conversation is approaching the context limit, or when the user complains about token cost or latency. Also use it to shape the agent's own output: skip ceremony, don

Licence
Apache-2.0
Last repository change
17.06.2026

Assessment and security

95/ 100Class: good
Format20 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
21
Scripts
6
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 17.06.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What to check before installing
  • 6 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/_common.py, scripts/code_compressor.py, scripts/context_manager.py, scripts/log_compressor.py, scripts/search_compressor.py, scripts/smart_crusher.py

What it does and when to use it

Token-reduction skill for coding agents. Compresses JSON tool output, build logs, grep/ripgrep search results, source code, and conversation history the same way the Headroom proxy does — but in-context, with no binary install. Use this skill whenever an agent is about to paste a large tool result (a 1000-row JSON array, a 5000-line pytest log, a 200-result grep, a 1000-line source file) into its next message, or when the agent's conversation is approaching the context limit, or when the user complains about token cost or latency. Also use it to shape the agent's own output: skip ceremony, don

Original author description

Token-reduction skill for coding agents. Compresses JSON tool output, build logs, grep/ripgrep search results, source code, and conversation history the same way the Headroom proxy does — but in-context, with no binary install. Use this skill whenever an agent is about to paste a large tool result (a 1000-row JSON array, a 5000-line pytest log, a 200-result grep, a 1000-line source file) into its next message, or when the agent's conversation is approaching the context limit, or when the user complains about token cost or latency. Also use it to shape the agent's own output: skip ceremony, don

How it works

  1. When to apply which transform
  2. The seven rules
  3. What "compression" means here
  4. Output-token shaping (the "L2 default")
  5. Files in this skill
  6. Important safety rules (do not violate)
  7. Credits
Original SKILL.md headings · 129 lines, 978 words
SKILL.md preview
---
name: headroom
description: >
  Token-reduction skill for coding agents. Compresses JSON tool output, build
  logs, grep/ripgrep search results, source code, and conversation history the
  same way the Headroom proxy does — but in-context, with no binary install.
  Use this skill whenever an agent is about to paste a large tool result (a
  1000-row JSON array, a 5000-line pytest log, a 200-result grep, a 1000-line
  source file) into its next message, or when the agent's conversation is
  approaching the context limit, or when the user complains about token cost or
  latency. Also use it to shape the agent's own output: skip ceremony, don't
  restate code already on screen, drop reasoning on routine turns. Triggers:
  "compress this output", "this is too long", "trim", "summarize the log",
  "reduce tokens", "context is full", "running out of context", "too many
  tokens", "make it shorter", "be terse".
---

# Headroom — portable token-reduction skill

This skill teaches any coding agent to apply the Headroom compression
techniques in-context. It does **not** require the Headroom binary.

## When to apply which transform

Pick the transform by content type. If a tool result is shorter than ~200
tokens, skip compression — the overhead isn't worth it.

| Content the agent is about to use / paste         | Apply                  | Helper script                          |
|---------------------------------------------------|------------------------|----------------------------------------|
| JSON array of dicts / objects (tool results, API responses) | SmartCrusher           | `scripts/smart_crusher.py`             |
| Build / test logs (pytest, npm, cargo, make)      | LogCompressor          | `scripts/log_compressor.py`            |
| grep / ripgrep / ag output (`file:line:content`)  | SearchCompressor       | `scripts/search_compressor.py`         |
| Source code (Python, JS, TS, Go, Rust, Java, C/C++) | CodeCompressor       | `scripts/code_compressor.py`           |
| Conversation history over the context budget      | RollingWindow          | `scripts/context_manager.py`           |
| Anything the model is about to **write back**     | Output Shaper (L2)     | `prompts/verbosity_steering.md`        |

## The seven rules

These are the core rules the agent should internalise. Full detail in
`AGENTS.md`; this is the short version.

1. **Compress before paste.** Before pasting any tool result over ~200 tokens
   into the next message, run the matching helper script (or apply the matching
   heuristic by hand if no script is available). Cite the script in your
   narration: "Compressed 1,432 → 187 tokens with SmartCrusher (kept first 3,
   last 2, all errors, top 5 by BM25 to query)."
2. **Never drop errors.** Errors, stack traces, `is_error: true` results, and
   `FAILED` lines are sacred. Always preserve them 100%, even when compressing
   hard.
3. **Keep first N and last N.** For arrays, logs, and search results, always
   keep the first 3 and last 2 items. They give pagination context and recency.
4. **Stabilise the prefix.** When building prompts, keep the system prompt and
   the first user turn byte-identical across requests. Move dynamic content
   (timestamps, "today is", session IDs) to the *tail* of the prompt so the
   provider's KV cache stays warm.
5. **Drop oldest tool outputs first.** When the conversation exceeds the token
   budget, drop complete `tool_call` + `tool_result` pairs from the oldest end.
   Never split a pair. Never drop the system prompt. Never drop the last 2
   user turns.
6. **Shape your own output.** Default verbosity is L2: skip preambles, don't
   restate code already on screen, reference by `path:line`. Drop to L3
   (conclusions only) when the user asks for brevity. Never narrate tool
   results the user can already see.
7. **Be reversible.** When you compress a tool result, write the original to
   `.headroom-cache/<sha256>.txt` and include the SHA in your narration: "CCR
   key: `a3f9…`". If a later turn needs the original, retrieve it from there.

## What "compression" means here

Compression is **selection**, not zipping. We don't run gzip. We pick which
items / lines / nodes to keep, and emit a shorter representation that
preserves the information the LLM needs to answer the user's question. The
original is always retrievable from the CCR cache.

The selection heuristics, in priority order:

1. **Errors** — always kept.
2. **First N** — pagination / setup context.
3. **Last N** — recency.
4. **Anomalies** — values >2σ from the mean (for numeric arrays) or items
   whose fields differ sharply from their neighbours.
5. **Relevant** — top-K by BM25 similarity to the user's current question.
6. **Change points** — items where a field value transitions (status flips,
   counters reset).
7. **Sample** — a statistically representative sample of the remainder, so the
   LLM still has a sense of the distribution.

## Output-token shaping (the "L2 default")

When generating your own reply, follow `prompts/verbosity_steering.md` at
level 2 unless the user asks for more or less. The five levels:

- **L0** — off
- **L1** — skip ceremony ("Great, let me…")
- **L2** — L1 + don't restate code/output already on screen; reference by
  `path:line` *(default)*
- **L3** — L2 + conclusions only, skip reasoning unless asked
- **L4** — fragments, minimum tokens

The "effort routing" companion rule: if the previous turn was a tool result
with `is_error: false` and no new user ask, this is a *mechanical
continuation*. Reply at L3 and skip deep reasoning. If the previous turn was
an error, or a new user question, keep full effort. See
`prompts/effort_routing.md`.

## Files in this skill

- `AGENTS.md` — universal agent rules (works with any agent framework). Read
  this first.
- `CLAUDE.md` — Claude Code / Cursor specific copy of the same rules.
- `docs/techniques.md` — deep dive into each transform, with worked examples.
- `docs/integrations.md` — per-agent setup (Hermes, Claw, Codex, Cursor,
  Aider, Goose, Continue, OpenHands, vibe, Copilot CLI).
- `docs/reversible-ccr.md` — the on-disk CCR cache convention.
- `scripts/` — pure-Python stdlib helpers. No `pip install` required.
- `prompts/` — system-prompt fragments for output shaping.
- `examples/` — before/after comparisons for each transform.

## Important safety rules (do not violate)

These mirror the safety rules in upstream Headroom. Each prevents a concrete
failure mode.

1. **Never drop user or assistant text.** Tool results can be compressed;
   human-authored messages cannot.
2. **Never split a tool_call / tool_result pair.** Dropping one half orphans
   the other and the model will hallucinate a result.
3. **Parse failures are no-ops.** If the input doesn't parse as the expected
   type, pass it through unchanged. A bad compression is worse than no
   compression.
4. **Always preserve recency.** The last N turns (default 2 user turns) are
   never dropped, even if they have low importance scores.
5. **Always preserve the system prompt.** Never.
6. **100% error preservation.** No exceptions.
7. **Idempotent.** Running the compressor on already-compressed output should
   be a no-op (or close to it).

## Credits

This skill is a portable re-implementation of the techniques in
[chopratejas/headroom](https://github.com/chopratejas/headroom) by Tejas Chopra
and contributors, licensed Apache 2.0. See `NOTICE` and the "Credits" section
of `README.md` for full attribution. The upstream project is faster, more
accurate, and ML-backed; install it if you can.
Files in this package (21)
  • .gitignore 1 KB
  • AGENTS.md 13 KB
  • CLAUDE.md 13 KB
  • CONTRIBUTING.md 3 KB
  • LICENSE 11 KB
  • NOTICE 1 KB
  • README.md 12 KB
  • SKILL.md 7 KB
  • docs/integrations.md 7 KB
  • docs/reversible-ccr.md 4 KB
  • docs/techniques.md 16 KB
  • examples/before_after.md 10 KB
  • prompts/cache_alignment.md 5 KB
  • prompts/effort_routing.md 6 KB
  • prompts/verbosity_steering.md 5 KB
  • scripts/_common.py 8 KB
  • scripts/code_compressor.py 12 KB
  • scripts/context_manager.py 12 KB
  • scripts/log_compressor.py 6 KB
  • scripts/search_compressor.py 7 KB
  • scripts/smart_crusher.py 10 KB

Versions

RepositoryScoreLicence
This page · roman-ryzenadvanced/headroom-skill95Apache-2.0
TerminalSkills/skills100Apache-2.0
tuan2304/my-company100MIT
momori777/artemis100Apache-2.0
udaysharmadev/Skills100MIT
akillness/jeo-skills95MIT

Database snapshot: 13.11.2026 · package version 5afcd3ab8d45 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100token-warden
    Token budget guardian for agent sessions. Models token consumption in four independent layers (context reading, tool/command output, conversation output, code generation), routes each layer to its most efficient tool or behavior, and enforces anti-pattern rules. Use in long…
  • 100transcript-grep
    Search a Claude Code session transcript for a string or regex pattern and show every matching message with surrounding context. Reads /api/sessions/:id/transcript and resolves sessions via /api/sessions?limit= from the Agent Monitor dashboard. Use when hunting for a specific…
  • 95session-investigator
    Investigate fast-agent session and history files to diagnose issues. Use when a session ended unexpectedly, when debugging tool loops, when correlating sub-agent traces with main sessions, or when analyzing conversation flow and timing. Covers session.json metadata, history JSON…
  • 90context-budget
    Reduce repeated reading and implementation work while preserving the requested result. Use for incremental research or RedBot saved-library updates, large tool output, repeated source/history reads, token costs, 省 token / 上下文消耗, and Ponytail reuse checks before implementation.
  • 100prefixer
    Give agents a namespace map of a codebase so searches start scoped instead of broad. Use to improve a codebase's token efficiency; save tokens and cut context cost when agents search code: at the start of work in an unfamiliar or large repo, when a task needs repeated codebase…
  • 100file-search
    This skill should be used when agents need to search codebases for text patterns or structural code patterns. Provides fast search using ripgrep for text and ast-grep for syntax-aware code search.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.