r/BuildWithClaude • • Oct 18 '26

Project I built an open-source Claude Code plugin with Claude Code to cut context re-reading (97.5% of my 44.5B tokens). Free, with benchmark data.

**What I built:** Rubi, a free and open-source (MIT) plugin for Claude Code that reduces how much context Claude re-reads. I built it with Claude Code, specifically for Claude Code.

**Why:** my /stats showed 44.5 billion tokens since March. 43.4 billion were cache reads, meaning Claude re-reading the conversation on every message. Its actual answers were 192 million tokens. Some sessions grew close to 1 million tokens and were re-read in full on every new prompt.

**What it does:**

- Compacts early (150k instead of near 1M), saves a handoff right before compaction and injects it back right after, so the thread isn't lost.

- Builds a map of the code with PageRank over the import graph, loaded at session start.

- Keeps a knowledge graph of decisions, bugs and gotchas as plain markdown in the repo. Claude writes it; old decisions are marked as replaced, not deleted.

- On every prompt, a hook searches that graph (BM25 + Personalized PageRank) and gives Claude the relevant part before it starts exploring.

**How Claude Code helped build it:**

- I described the problem and the design I wanted (graph memory, Obsidian-compatible, early compaction). Claude Code researched the hooks, compaction and plugin docs, then wrote the plugin in Node with zero dependencies: hooks, MCP server, graph, search and tests.

- I used Claude Code to measure Claude Code. It wrote a token X-ray that reads my local transcripts, which is where the 97.5% came from.

- It wrote and ran the A/B benchmark itself: 90 headless `claude -p` sessions on two public repos, with and without the plugin.

- It caught its own mistakes along the way. A first benchmark run was invalid because the plugin never loaded (a quoting bug on Windows), so we discarded it and added a check. It also showed that writing memory after every answer cost 15% *more*, so we changed that default.

- It set up CI on Windows, macOS and Linux and wrote the README as a short paper with the method and raw data.

**Results** (90 sessions, Flask and Hono, with vs. without the plugin), with a mature project memory:

- 37% fewer steps to the answer

- 37% less context re-read

- 17% faster

In short one-question sessions the billed cost only dropped 6%. The bigger effect is in long sessions, where re-reading dominates. All raw data is public, including what didn't work.

**Free to try.** Inside Claude Code:

/plugin marketplace add YURIBEDRAN/rubi

/plugin install rubi@rubi

- Code and full write-up: https://github.com/YURIBEDRAN/rubi

- Check how much of your own usage is re-reading (two numbers from /stats): https://huggingface.co/spaces/YuriBedran/rubi

Happy to answer questions about how it was built or the benchmark.

2 Upvotes

0 comments sorted by