If you use Claude Code heavily, you’ve probably hit the same wall: context fills up fast, costs climb, and long sessions degrade. The common fixes — splitting sessions, summarizing manually — treat the symptom, not the cause.

There’s a better approach: attack the problem at three different layers simultaneously.

The three-layer stack

[Bash output] ← RTK filters here

[Context window] ← Headroom compresses here

[LLM API call] ← Graphify prevents reads here

Each tool solves a different piece of the problem.


Layer 1: RTK — filter at the shell

RTK (https://github.com/rtk-ai/rtk) intercepts every Bash command Claude runs and strips the noise before it enters the context. Test failures, git diffs, grep results, ls output — all compressed to what actually matters.

#macOS

brew install rtk

#Linux/macOS (curl)

curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

#Then wire it to Claude Code (one-time setup)

rtk init -g

Restart Claude Code — done

It works via a Claude Code hook, so it’s completely transparent. No changes to your workflow.

Real numbers from my own setup: 73% token reduction across 243 commands — 631K tokens saved. The rtk gain command shows you exactly where the savings come from.

Limitation: only helps with Bash output. Files, conversation history, and API responses are untouched.


Layer 2: Headroom — compress the context

Headroom (https://github.com/headroomlabs-ai/headroom) sits between your session and the API. It compresses accumulated context before each request using content-aware algorithms: SmartCrusher for JSON (the project reports 60–95% reduction), CodeCompressor for source code.

uv tool install --python 3.13 "headroom-ai[all]"
headroom wrap claude # wraps your Claude Code session

Limitation: compression is semantic, not lossless. For data-heavy workflows where exact numbers matter — analytics, financial data, scientific results — verify it doesn’t distort values before relying on it.


Layer 3: Graphify — replace reads with a knowledge graph

Graphify (https://github.com/Graphify-Labs/graphify) pre-processes your codebase into a queryable AST graph. Instead of Claude re-reading dozens of files every session to understand your architecture, it queries a local graph.json.

pip install graphifyy
graphify install --platform claude # creates the /graphify skill

Then inside Claude Code:


/graphify .

The project reports up to 499x fewer tokens for codebase navigation on large TypeScript projects. AST extraction is purely local — zero LLM cost to generate the graph.

Limitation: only valuable on large codebases. Small projects or data-heavy workflows (SQL, APIs) won’t benefit much.


When to use what


The honest caveat

RTK is the one I’ve measured in production — the 73% number is real and verifiable with rtk gain. Headroom and Graphify are tools I’m actively evaluating; the figures above come from their respective projects, not my own benchmarks yet.

That said, the three-layer thesis holds: filtering output, compressing context, and substituting reads with graph queries attack genuinely different parts of the token problem. Used together, they compound.


Have you tried any of these, or found other patterns that work? Curious what combinations people are running.