Related ToolsClaude CodeClaudeCursorCodyAider

Strata Plugin Compresses Claude Code File Reads to Cut Token Costs

Claude by Anthropic
Image: Anthropic

A new open-source plugin called Strata takes a different approach to reducing Claude Code costs: instead of optimizing prompts or switching models, it compresses the files Claude reads before they hit the context window.

The idea is simple. When Claude Code reads a large file to understand your codebase, it consumes tokens (the units of text that AI models process, and that you pay for). Strata intercepts those file reads and replaces them with compressed structural outlines. A 1,274-line file gets squeezed down to roughly 30 lines. The plugin's author claims this translates to 31-43% cheaper read operations overall.

How the Compression Works

Strata uses what it calls "entropy-guided structural outlines." Rather than relying on a traditional code parser that needs to understand each programming language, it looks for universal structural signals: blank lines at the top level of bracket nesting, points where bracket depth returns to zero, significant changes in indentation, and Shannon entropy gradients (essentially, places where the information density of the text shifts). The result is a language-agnostic summary that preserves the shape of a file without reproducing every line.

For repetitive code, the gains are more dramatic. The README cites an example where 26,000 lines of C++ containing 60 similar class definitions collapse to just 3 representative nodes and 167 characters, a 99.98% compression ratio.

When Claude needs to edit a file, Strata uses a coordinate system called "hashline references" instead of making Claude reproduce code blocks. Each line gets an address like 42#VRK: that the plugin resolves back to actual code. Edits are applied bottom-up so line numbers stay valid throughout the process.

The Practical Tradeoffs

The plugin operates in two modes. Files over 300 lines get the full compression treatment on first read. Files between 100-299 lines read normally the first time but get compressed on repeat reads to prevent the same code from eating context twice.

Strata requires Node.js 22+ and installs as a Claude Code hook via .claude/settings.local.json. It is MIT-licensed, so you can inspect exactly what it does before letting it modify your tool calls.

The 31-43% savings claim is worth scrutinizing. The compression ratios on individual files look impressive in the examples, but real-world savings depend heavily on your codebase structure and how often Claude re-reads files during a session. Codebases with lots of repetitive boilerplate (think generated types, config files, test fixtures) will benefit most. Highly unique, dense code will see smaller gains.

Still, the parser-free approach is clever. Most code compression tools need language-specific parsers, which limits them to supported languages and adds maintenance overhead. Strata's entropy-based method works on any text file, which matters if your project mixes languages or includes non-code files that Claude reads frequently.