
Agentic coding sessions spend most of their token budget on context the model reads rather than the answers it writes, and three open-source tools now attack that spend from fundamentally different positions in the request lifecycle. Headroom is an out-of-band compression layer that rewrites inbound payloads before they reach the provider, Caveman pairs an in-band prompt-design skill with an optional local proxy, and Graphify replaces runtime file exploration with a pre-built codebase knowledge graph served through MCP tools. Confusing the three is common because they are often named in the same breath, yet they touch different token sinks, run at different times, and report savings on different denominators. This article breaks down each tool's documented architecture — Headroom's CacheAligner-to-CCR pipeline and content-typed engines, Caveman's SKILL.md hooks and contextwindow.Pack() selection function, and Graphify's tree-sitter-to-Leiden build feeding MCP endpoints — and audits what each vendor's numbers actually measure. The intended audience is developers deciding which tool, if any, to adopt for Claude Code or Cursor sessions.

| Phase | Headroom | Caveman (skill‑only) | Caveman (skill + proxy) | Graphify |
|---|---|---|---|---|
| Pre‑session build | — | — | — | A build step runs tree‑sitter over the repository, merges the ASTs and community clusters, and writes a graph.json that encodes the whole codebase (the “Leiden” graph) 【3†L1-L8】 |
| Session start | The local proxy or agent wrapper is already listening; every payload that the agent will send is first passed to Headroom for compression 【0†L1-L6】 | SKILL.md is loaded by the runtime through the SessionStart hook; a flag file tells the model to prepend a terse system prompt 【1†L1-L6】 | The same SKILL.md is loaded, and an optional outbound proxy can be started alongside the session 【1†L1-L3】 | |
| Input preparation | CacheAligner inspects the inbound payload, warns about volatile fragments that would bust the provider’s KV‑cache, and forwards the data to ContentRouter 【0†L7-L11】 | The model receives the “caveman” instruction and generates a terse answer; no rewriting of the input occurs 【4†L1-L6】 | The proxy (if used) applies the same Headroom‑style compress‑then‑send flow on top of the skill 【0†L1-L6】 | |
| Compression / routing | ContentRouter selects a compressor (SmartCrusher for JSON, CodeCompressor for AST‑aware code, Kompress‑v2‑base for prose) and feeds the data into CCR (Cache‑aligned Reversible compression) 【0†L12-L19】 | No compression layer; the only token savings come from the model’s output style 【4†L1-L4】 | No runtime compression; the agent queries the pre‑built graph via MCP tools (graph_search, graph_path, etc.) instead of reading raw files 【3†L1-L9】 | |
| Transmission | The compressed payload is sent to the LLM provider; the original remains locally available for on‑demand retrieval via headroom_retrieve 【0†L20-L23】 | The model’s terse reply is transmitted directly; the input payload size is unchanged 【4†L1-L4】 | The LLM receives a short graph‑description (≈ 2 k tokens for a 500 k‑token codebase) plus any concrete file fragments the graph points to 【3†L10-L13】 | |
| Post‑response | The agent can call back to retrieve any decompressed block that the model demanded 【0†L21-L23】 | No post‑processing; token count reflects the smaller output only 【4†L1-L4】 | Subsequent queries reuse the same graph; only the sub‑graph relevant to the new question is transmitted 【3†L10-L13】 |
Benchmark applicability – Headroom and the Caveman proxy operate on the input side, so any benchmark that measures bytes sent to the provider (e.g., raw token count per request) captures their effect. Caveman’s skill, by contrast, influences output tokens and cannot be combined with input‑side savings in a single additive claim.
Cache interaction – Headroom’s CacheAligner deliberately preserves KV‑cache prefixes, which means its savings are realized without sacrificing provider‑side caching discounts 【0†L7-L11】. A proxy that rewrites prompts would break the cache and skew cost estimates.
Scope of reduction – Graphify’s numbers (e.g., 71.5× fewer tokens per query 【2†L1-L4】 or up to 70× for large projects 【3†L10-L13】) reflect exploration reads avoided, not compression of the same text. The tool replaces a costly “read‑all‑files” phase with a compact graph lookup, so comparing its percentage‑based savings to Headroom’s “compressed payload” percentages would be misleading.
Evolving shape – Early documentation described Caveman merely as a “style prompt”. Since version 2.0 the project ships both the SKILL.md and an optional out‑of‑band proxy, so older articles that label it “just a prompt” are outdated 【1†L1-L3】. Evaluations must note which variant is in use.
Understanding these lifecycle positions lets developers pick the right metric: input‑side compression (Headroom or Caveman proxy) for raw token budgets, output‑side terseness (Caveman skill) for answer length, or exploration avoidance (Graphify) when the dominant cost is scanning large codebases.

The pipeline starts with CacheAligner, which scans each incoming request for fragments that change on every turn (timestamps, UUIDs, session tokens). When such volatile data is found, CacheAligner emits a warning but never rewrites the prompt—its role is a “smoke detector”, not a “sprinkler” 【4†source】. The warning helps the user keep the static prefix stable, preserving the provider’s KV‑cache hits and the associated cost discounts 【5†source】.
After alignment, Headroom applies live‑zone compression. Only the bytes newly added in the current turn (e.g., fresh tool output) are compressed, while the earlier prefix remains byte‑identical. Because the prefix does not change, the provider’s prompt‑caching mechanism continues to hit, avoiding the latency and token penalty of a busted cache 【2†source】.
The second stage, ContentRouter, determines the payload’s MIME‑type and forwards it to one of the specialized compressors:
| Content type | Engine (as of the v0.33 series) |
|---|---|
| JSON (arrays of dicts, nested objects, mixed types) | SmartCrusher – 60 %–95 % token reduction 【1†source】 |
| Source code (Python, JS/TS, Go, Rust, Java, C/C++, Perl) | CodeCompressor – AST‑aware compression 【1†source】 |
| Free‑form prose | Kompress‑v2‑base – a HuggingFace model trained on agentic traces 【1†source】 |
| Images | ML‑routed image path – 40 %–90 % reduction 【1†source】 |
The README lists three compressors plus the image path, a separate write‑up mentions four engines, and a later document counts six when log, RAG‑chunk deduplication, and conversation‑history compressors are included 【9†source】. This version‑sensitivity means the exact engine count depends on the installed extras and the release tag.
The final stage, CCR (Content Compression Routing), makes compression reversible. Originals are written to a local store and can be fetched on demand via the headroom_retrieve endpoint 【4†source】. This guarantees that any needed detail can be re‑instated without re‑sending the full payload upstream.
pip install "headroom-ai[all]" (or uv tool install --python 3.13 "headroom-ai[all]") pulls in the CLI, proxy, and all compressors 【3†source】.headroom wrap claude (or codex, cursor, aider, etc.) starts a local proxy, installs Serena for semantic code navigation, and launches the agent configured to route through the proxy 【5†source】.headroom proxy --port 8787 exposes OpenAI‑compatible /v1 and Anthropic‑compatible endpoints. Point a client to the proxy with OPENAI_BASE_URL=http://localhost:8787/v1 (Cursor) or ANTHROPIC_BASE_URL=http://localhost:8787 (Claude Code) 【7†source】.headroom doctor performs a health check, headroom stats or headroom dashboard display live token‑savings, request counts, cache‑hit rates, and estimated USD savings 【6†source】【8†source】.Together these components let developers slot Headroom into any Claude Code or Cursor workflow with a single command, while preserving cache economics, providing reversible compression, and surfacing quantitative savings in real time.

contextwindow.Pack()Two distinct parts share the Caveman name. The skill runs inside the LLM session, while the proxy sits between the agent and the provider. Both are optional but are often deployed together because they complement each other.
SessionStart hook loads SKILL.md. The UserPromptSubmit hook writes a tiny flag file that the model reads on every turn, guaranteeing that the instruction set stays active throughout the conversation.Because the model generates a shorter answer by design, the cost reduction is limited to the output‑token side; the skill itself adds a small constant of input tokens (the flag file and rule payload) per turn.
caveman claude wrapper)Deployment: The command caveman claude starts a local HTTP proxy that forwards every request to Claude (or another provider) unchanged. No code changes to the agent are required, and OAuth credentials are proxied transparently.
Recovery: Each compressed payload is stored in a SQLite file (Client Compression Recovery). The copy is byte‑exact, allowing lossless restoration if the provider rejects the request.
Engine internals:
detect() inspects the incoming payload and routes it to a compressor that isolates answer‑critical fragments (error sub‑trees, signature blocks, changed diff lines).contextwindow.Pack() – the proxy’s context‑selection routine:
Benchmark result: In a pinned 54‑run Claude Code benchmark, the proxy delivered 33.2 % fewer provider‑reported input tokens while passing all 18 exact‑answer checks【{"url":"https://skillsllm.com/skill/caveman"}】. This figure measures the input‑side saving; it is separate from the skill’s output‑token claim.
The default wrap installs five MCP utilities—compress, retrieve, stats, and two re‑encoding tools—plus a browse MCP server. Hook scripts for command‑output shrinking are provided for Claude Code, Opencode, Gemini, Hermes, and OpenClaw. They are only loosely compatible with Codex, which currently rejects on‑the‑fly rewrites (see upstream issue OpenAI/codex#18491).
Together, the skill and proxy let developers decide where to focus savings: terse model replies (output reduction) or leaner request payloads (input reduction). Understanding their separate denominators prevents double‑counting and helps choose the right combination for a given Claude Code or Cursor workflow.

Build‑time pipeline – Graphify follows a deterministic, multi‑stage pipeline that runs once per repository and then re‑uses the result for every query. The stages are [detect → extract → build → cluster → analyze → report → export] as described in the official documentation1.
graphify-out/graph.json).Each edge is stamped with a provenance tag that quantifies confidence:
| Tag | Meaning | Confidence |
|---|---|---|
EXTRACTED | Direct AST‑derived relationship | 1.0 |
INFERRED | Model‑derived relationship (Claude) | 0.7 – 0.9 |
AMBIGUOUS | Uncertain or contested link | < 0.7 |
A large monorepo benchmark reported 87 % EXTRACTED / 13 % INFERRED edges, showing that most of the graph is grounded in deterministic code analysis[^confidence‑stats].
Serve‑time – The graph is served via the MCP extra. After installing the extra (uv tool install graphify[mcp]), the server is started with
python -m graphify.serve --graph graphify-out/graph.json
graph.json.The built‑in server exposes ten core tools (query_graph, get_node, get_neighbors, shortest_path, triage_prs, …). The companion graphify‑mcp‑tools package (Node.js runtime only) loads the same JSON into an in‑memory SQLite instance and adds richer operations such as graph_impact (blast‑radius analysis), graph_path (weighted Dijkstra), graph_community, graph_hotspots (god‑node detection), graph_outline, and graph_status. All tools ship with per‑editor wiring for OpenCode, Cursor, Claude Code, and VS Code.
Staleness handling –
--update re‑extracts only files whose SHA‑256 hash changed.--watch watches the source tree and triggers fast AST rebuilds on code saves; non‑code artefacts (docs, images) still need a manual re‑run of the LLM pass.Token‑usage model – Unlike Headroom and Caveman, Graphify does not compress the request payload. Instead, it removes the exploration cost: the LLM never tokenises the whole repository, it only tokenises the subgraph that matches the query. Because token consumption now depends on subgraph size rather than total repo size, large monorepos see a dramatic reduction. Benchmarks show a drop from ~12 k raw tokens to ~2.5 k tokens for a typical five‑file request, i.e. a 60 %–80 % cut2 and, in a separate case, up to 71 × fewer tokens per query on a mixed corpus[^gopenai‑claim].
Consequently, Graphify’s reported savings are not expressed as “tokens saved” but as a change in the denominator: the model’s context window is freed for higher‑level reasoning, while the upfront build cost is a one‑time amortised expense.

Headroom – Vendor case studies quote 60–95 % input‑token reduction on the context payload that reaches the model. The numbers break down as follows:
| Workload | Tokens before → after | Reported reduction | Source |
|---|---|---|---|
| Code search (100 results) | 17,765 → 1,408 | 92 % | 【https://agentconn.com/agents/headroom/】 |
| SRE incident debugging | 65,694 → 5,118 | 92 % | 【https://agentconn.com/agents/headroom/】 |
| GitHub issue triage | 54,174 → 14,761 | 73 % | 【https://agentconn.com/agents/headroom/】 |
These percentages are measured against the raw inbound payload after Headroom’s Cache‑Aligner‑CCR pipeline strips redundant logs and duplicate files. They do not include any extra tokens added by the tool’s own framing metadata or the cost of the extra request round‑trip.
Independent benchmark – a full‑session comparison run on a realistic TypeScript bug‑fix workflow found that, despite a measured 10 % token strip, the overall provider bill was 53 % higher than a baseline run without Headroom【https://tokenade.net/en/articles/headroom-vs-graphify】. This illustrates that payload‑level ratios can be misleading when session‑level overhead (caching invalidation, extra calls) is taken into account.
Caveman – The project consists of two separate products, each reporting a different token sink.
Skill‑only (output‑token compression)
Proxy (input‑token compression)
These two figures are not additive: the skill reduces the output size, while the proxy reduces the input size. Neither measurement includes the extra ~1 k input tokens the skill injects for its own instruction, nor any latency overhead.
Graphify – The tool replaces sending whole files with a pre‑built knowledge graph, so the savings are reported on the exploration reads that are avoided.
| Example | Tokens before → after | Reported saving | Source |
|---|---|---|---|
| 5‑file request (≈12 k tokens) | → ≈2.5 k tokens | ≈80 % reduction | 【https://www.infoq.com/news/2026/09/graphify-codebase-exploration/】 |
| Mixed 52‑file corpus (Karpathy benchmark) | → ≈1.7 k tokens vs ≈123 k naive | 71.5× fewer tokens per query | 【https://graphify.net/】 |
| BFS subgraph query on ~500 k‑word corpus | → ≈2 k tokens vs ≈670 k naive | ≈99.7 % reduction | 【https://blog.gopenai.com/graphify-build-a-knowledge-graph-from-your-entire-codebase-without-sending-your-code-to-anyone-1b6924474b50】 |
All figures measure tokens that would have been read from files if the agent performed naïve file‑by‑file exploration. They do not reflect any compression of the payload itself, nor do they account for the one‑time cost of building the tree‑sitter → Leiden graph.
Independent long‑session benchmark showed no measurable cost saving for Graphify; the tool’s token reductions on individual queries did not translate into lower overall session spend【https://tokenade.net/en/articles/headroom-vs-graphify】.
| Tool | Token sink measured | Typical claim | Benchmark context | Caveats |
|---|---|---|---|---|
| Headroom | Input‑payload context | 60–95 % reduction (up to 92 % on specific workloads) | Vendor case studies; pin‑run on code search / SRE / issue triage | Session‑level cost can increase (‑53 % in independent run); version‑sensitive |
| Caveman (skill) | Output tokens | 65 % reduction (22–87 % range) | Ten‑prompt average; output‑only counting | Extra instruction tokens not counted; not additive with proxy |
| Caveman (proxy) | Provider‑reported input tokens | 33.2 % fewer input tokens | 54‑run pinned benchmark, 18 exact‑answer checks | Measures only inbound payload; adds proxy overhead |
| Graphify | Exploration reads avoided | 60–80 % vs whole‑file sends; up to 71.5× fewer per query | Single‑run examples (5‑file, Karpathy corpus) | No savings seen in long‑session benchmark; graph build cost omitted; version‑sensitive |
When planning adoption for Claude Code or Cursor sessions, focus on the token sink each tool actually targets and verify the methodology (pinned runs, exact‑answer checks, session length) that produced the numbers. High per‑payload reduction does not guarantee lower total cost; real‑world sessions often involve caching, multiple turns, and auxiliary calls that can offset the advertised savings. All three projects are under active development, so benchmark results may shift with newer releases.

| Tool | Architectural source of failure | Typical impact | Built‑in mitigations |
|---|---|---|---|
| Headroom | The CacheAligner → ContentRouter → CCR pipeline rewrites every inbound payload before it reaches the provider. Because the proxy is in‑line, any latency or compression error is applied to each turn of a session, compounding the cost. | A malformed compressor (e.g., Kompress‑v2‑base on unexpected UTF‑8 sequences) can corrupt the prompt, forcing the LLM to reject the request or produce nonsensical output. Short sessions with tiny payloads may not see enough token savings to justify the added round‑trip. | – Local‑only operation keeps the rewrite under the developer’s control. <br>– CCR stores the original uncompressed data, enabling a reversible headroom_retrieve call if the model needs the full text. <br>– CacheAligner emits warnings for volatile content that could break provider KV‑cache prefixes, allowing developers to skip compression for those fragments. (see Headroom’s pipeline description)【0†source】. |
| Caveman | The tool is a SKILL.md/hook package that injects a “be terse” system prompt at SessionStart and writes a per‑session flag file that the agent reads on each turn. The compression is therefore behavioral rather than a post‑process rewrite. | If the flag file is deleted or the hook fails to fire (e.g., because an agent runtime rejects the injected prompt, as documented for Codex), the model falls back to its default verbose style, undoing the token savings. The terse style can also reduce human readability, making debugging harder. | – The flag file acts as an explicit on/off switch; recreating it restores the mode. <br>– Byte‑exact recovery is guaranteed because the model never emits compressed data—its output is directly usable. <br>– Optional local SQLite logging records token counts per turn, helping spot when the hook is inactive. (details on hook‑driven architecture)【2†source】. |
| Graphify | Graphify builds a pre‑computed knowledge graph from a codebase using tree‑sitter AST extraction, then serves it via an MCP server. The graph can become stale if the source files change without invoking --watch, --update, or an explicit push‑triggered re‑index. | An agent that never calls the graph tools receives no token reduction, yet still pays the cost of loading the MCP server. Moreover, stale edges can mislead the model, causing deterministic‑inferred confidence tags to surface as errors. | – CLI flags --watch and --update keep the graph in sync with the repository. <br>– Confidence tags (deterministic vs. inferred) are exposed to the consumer, allowing callers to discard uncertain edges. <br>– The build phase runs locally in Python, with no LLM calls unless the optional semantic pass over docs is enabled (see Graphify pipeline)【7†source】. |
| Dimension | Headroom | Caveman | Graphify |
|---|---|---|---|
| Installation | pip install headroom (or uv‑based wheels); pure Python package. | npm install -g caveman (global CLI) plus optional ~/.caveman-cloud/config.json. | Python build (python -m pip install graphify) to generate graph.json, then npm i -g graphify-mcp-tools for the MCP server. |
| Runtime dependencies | Local proxy process, optional HuggingFace model extras for Kompress‑v2‑base; no external services if compression models are cached. | Node 18+ runtime, SQLite for local stats logging, and optional MCP tools if used. | Python for the build step (tree‑sitter, NetworkX, Leiden); at serve time a Node.js/MCP server with sql.js (WASM) for an in‑memory SQLite DB. |
| Trust posture | All processing stays on‑device; the only network call is the compressed request to the LLM provider. | Code and flag files remain local; the tool does not forward any payload to third‑party services. | By default local‑first: code parsing never leaves the machine. Only the optional semantic extraction over docs may call an LLM endpoint, and a hosted “re‑index” variant is explicitly advertised as the only remote path. (see Graphify privacy notes)【9†source】. |
In practice, Headroom adds a constant per‑turn overhead, Caveman’s cost is a one‑time hook injection that can be toggled, and Graphify incurs a start‑up cost only when the MCP server is launched and the graph is kept current. Choosing between them depends on whether the workload is session‑long (Headroom), prompt‑style oriented (Caveman), or code‑base‑centric with reusable graph queries (Graphify).

1. Match the levers to the workload shape
| Session shape | Token‑saving lever that bites hardest | Why it fits |
|---|---|---|
| Input‑heavy debugging – large logs, JSON tool results, many file reads | Headroom – content‑typed engine routing compresses JSON, code ASTs and raw prose before they reach the provider. Its CacheAligner stabilises volatile prefixes so provider caches hit, giving 40‑90 % input‑token reduction【0†L1-L7】【0†L18-L24】. | A single failed build can inject thousands of log lines; compressing that payload saves the most tokens. |
| Mixed payload (logs + code + text) | Headroom again, because the ContentRouter detects the type of each chunk (JSON, source, free‑form text) and forwards it to the appropriate compressor (SmartCrusher, CodeCompressor, Kompress‑v2‑base)【0†L18-L25】. | Heterogeneous data benefits from the per‑type engines rather than a one‑size‑fits‑all approach. |
| Error‑signal‑first, recency‑biased sessions | Caveman – the proxy packs the most recent error messages and the critical diff via contextwindow.Pack() before any LLM call, keeping the token budget focused on the signal that matters【1†L1-L4】. | Prioritising the latest diagnostic lines yields the biggest cost drop when output is short. |
| Prose‑heavy output – code reviews, walkthroughs, explanations | Caveman – its style layer forces the model to answer in a terse “caveman‑speak”, trimming filler and reducing output tokens by ~65 % (as low as 22 % loss for already‑tight answers)【1†L4-L9】. | The savings come from output compression; installation is a single command and near‑zero runtime overhead. |
| Large repository orientation – 500 + files, repeated multi‑session work | Graphify – builds a tree‑sitter‑derived knowledge graph once, then serves only the sub‑graph relevant to a query. Token use scales with sub‑graph size, not repo size, delivering up to 70‑80 × fewer input tokens for orientation reads【2†L1-L8】【2†L9-L13】. | The graph persists across sessions, so each new query avoids re‑tokenising the whole codebase. |
2. Integration‑cost ladder
| Tool | Approx. install/setup time | Main runtime requirement |
|---|---|---|
| Caveman | One‑command npm i -g @caveman-ai/cli && caveman setup --install (≈30 s)【1†L1-L3】 | MIT‑licensed Node runtime; works as a thin proxy or skill file. |
| Headroom | A few minutes to start the Python wrapper or proxy mode; needs a Python 3.9+ environment and optional wrap or proxy flag【0†L1-L3】 | Runs locally, intercepts every request; optional CacheAligner tuning step. |
| Graphify | Up‑front graph build (minutes to hours depending on repo) plus editor‑specific MCP configuration; requires a habit of re‑indexing after large changes【2†L14-L18】 | Local tree‑sitter parser, MCP server, and per‑editor (Cursor) rule files. |
3. Cursor‑specific considerations
OPENAI_BASE_URL environment variable, so you can point Claude Code or Cursor at any OpenAI‑compatible endpoint without code changes【0†L1-L3】.4. Practical recommendation flow
5. Measuring real impact
After installing the chosen tool, capture a baseline run and then a post‑install run:
| Tool | Metric to record |
|---|---|
| Headroom | Provider‑reported input‑token count (pre‑compression vs. post‑compression). |
| Caveman | The benchmark’s input‑token field (proxy) and output‑token reduction from the skill. |
| Graphify | Session logs of graph query volume and the resulting input‑token count versus raw file concatenation. |
Because the three levers target different token sinks, they are not mutually exclusive; stacking them may yield additional savings, but evaluating combinatorial effects is beyond the scope of this guide. Use the above measurements to decide whether the observed reductions justify the integration effort for your Claude Code or Cursor workflow.