A 14-stage pipeline that squeezes LLM tokens without inference costs
Claw Compactor chains fourteen specialized compressors to shrink prompts and context windows before they reach an LLM, preserving structure that perplexity-based drop-in solutions tend to destroy.

What it does
Claw Compactor is a Python engine that runs text through a sequence of fourteen content-specific compressors — AST-aware code shrinking via tree-sitter, JSON statistical sampling, simhash deduplication, log folding, and natural-language abbreviation — to reduce token counts before an LLM ever sees them. It auto-detects content type and language, skips stages that don’t apply, and can store originals in a hash-addressed RewindStore so the LLM can retrieve full text later by marker ID. The README reports 15–82% compression depending on input, with a weighted average around 36% across code, logs, diffs, and search results.
The interesting bit
The architecture treats the pipeline as an immutable data flow: each stage consumes a frozen FusionContext and emits a FusionResult, so nothing is mutated in place. That rigidity, combined with a should_apply() gate on every stage, means the engine pays almost nothing for the dozen compressors that don’t match a given chunk. It is also dependency-free by default — not even PyTorch — which is unusual in a field where most alternatives drag in transformers just to drop a few tokens.
Key highlights
- Claims 15–82% compression with sub-50 ms latency and zero LLM inference cost, benchmarked against SWE-bench instances and LLMLingua-2.
- Content-aware routing detects 16 languages and distinct types (code, JSON, logs, diffs, search results) to pick appropriate stages.
- Reversible compression via
RewindStorelets an LLM retrieve original text by marker ID instead of permanently losing context. - ROUGE-L fidelity scores of 0.653 (aggressive) and 0.723 (balanced), which the project positions as significantly higher than LLMLingua-2.
- Ships with 1,600+ tests, no required heavy dependencies, and an optional
tiktokenextra for exact token counts.
Verdict
Worth evaluating if you are building agentic workflows or IDE features that stuff large codebases, logs, or tool outputs into context windows and want to cut token spend without calling another model. Probably overkill if your prompts are already short and cheap.
Frequently asked
- What is open-compress/claw-compactor?
- Claw Compactor chains fourteen specialized compressors to shrink prompts and context windows before they reach an LLM, preserving structure that perplexity-based drop-in solutions tend to destroy.
- Is claw-compactor open source?
- Yes — open-compress/claw-compactor is open source, released under the MIT license.
- What language is claw-compactor written in?
- open-compress/claw-compactor is primarily written in Python.
- How popular is claw-compactor?
- open-compress/claw-compactor has 2.2k stars on GitHub.
- Where can I find claw-compactor?
- open-compress/claw-compactor is on GitHub at https://github.com/open-compress/claw-compactor.