headroom

Compress large JSON arrays and tool outputs to reduce token usage.

358|20|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/momori777/Artemis --skill headroom-momori777
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: headroom
Source: https://github.com/momori777/Artemis/tree/main/skills/headroom
Command: npx skills add https://github.com/momori777/Artemis --skill headroom-momori777

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Long tool outputs, search results, and JSON arrays can quickly exhaust an LLM's context window, forcing truncation or expensive token usage. This Skill compresses bloated context while preserving the most important items, and caches originals for on-demand retrieval. ## Core Features & Use Cases - SmartCrusher: Compresses JSON arrays using five-dimensional scoring that keeps first/last items, error entries, statistical outliers, query-relevant items via BM25, and change points. - CCR Store: A Compress-Cache-Retrieve LRU cache with TTL that stores original text during compression so the full content can be retrieved later by hash key. - ContentRouter & Token Estimation: Automatically classifies content (JSON, logs, diffs, code) and estimates token counts with CJK-aware counting. - Use Case: A grep returns 200 matching lines as a JSON array. Crush it with a query string to keep only the 15 most relevant items, cutting token usage by 70-90%, and retrieve the original later if the model needs more detail. ## Quick Start Import SmartCrusher from the headroom module and call crush on your large JSON data with a query string to get a compressed version with a retrieval hash.

Frequently Asked Questions about headroom

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compress large JSON arrays before sending them to an LLM?▼

Use SmartCrusher's crush method with your JSON data and an optional query string. It scores items across five dimensions and returns a compressed JSON string plus a hash key for retrieving the original from the CCR cache.

What items does context compression keep when reducing JSON data?▼

SmartCrusher keeps the first 30% and last 15% of items, all error entries, statistical outliers beyond two standard deviations, BM25 query-relevant items, and significant change points, then deduplicates and samples to fill the budget.

Does this compression library require external Python dependencies?▼

No, the module is implemented entirely with the Python standard library. It uses only hashlib, json, math, re, and dataclasses, so it runs in any Python environment without pip installs.

How do I retrieve the original text after compression?▼

Store the original in CCRStore with put using the hash key from CrushResult, then call get with that key when the model needs full detail. Entries expire after a configurable TTL, defaulting to one hour.

When should I not use statistical context compression?▼

Avoid it when every item in the data is equally important, such as financial records or exact configuration lists, since scoring-based retention drops items. It is designed for noisy outputs like logs and search results where most entries are low value.