programmiere

Matrix for Claude Code

Claude Code needed a third of the time and half the tokens.

I measured Claude Code with and without this free plugin on 442 pages of EU regulations. With it, a question took 42 instead of 126 seconds on average and 303k instead of 651k input tokens. The answers stayed the same.

The plugin gives Claude Code a local index of your PDFs, Word files, scans and charts. Every answer comes with file, page and passage. Claude Code is the language model, so you need no extra model and no API key.

Get it on GitHub

The problem

Without an index, every question starts from zero.

Claude Code converts the PDFs to text, greps, opens pages and greps again. That works, but on a few hundred pages it takes 20 or more tool calls per question.

Matrix reads the documents once. It splits them by their structure, indexes them and gives Claude Code short hits instead of whole pages.

What it does

It finds the passage and the page.

Answers with sources

Every answer names file, page and passage. The citations are checked against the original text.

Tables across documents

One question for every document or passage, returned as a table with a source in each cell.

Other words, other languages

Search works on meaning, so an English question finds the German provision.

Scans and charts

Scanned pages are searchable. A value that exists only in a chart is found on its page.

Cross-references

"Pursuant to Article 26" leads to Article 26, and Claude can read the whole article, not just a snippet.

Stays current

New and changed files in the folder are indexed again automatically. Deleted files drop out of the search.

The measurement

Two test sets, all public.

Claude Code alone against Claude Code with the plugin, on public EU regulations and reports. Same questions, same prompt. I wrote down the right answers before the first run.

42 saverage time per question on 442 pages, instead of 126 s without the plugin
303kaverage input tokens per question, instead of 651k
9.5average tool calls per question, instead of 21
−34 %input tokens on 1,592 pages in 14 documents and four languages; 35 % less time
Question (442 pages)AloneWith Matrix
English question, German legal text86 s · 381k tokens26 s · 187k tokens
A number that exists only in a chart109 s · 585k tokens51 s · 407k tokens
One answer spread over three regulations245 s · 1,279k tokens62 s · 428k tokens
Paraphrased question, single regulation64 s · 357k tokens27 s · 191k tokens

Averages per run, Claude Code with Sonnet, October 2026. The questions, the right answers and the script to run it again are in DEMO.md.

The limits

It saves time and tokens. The answers did not get better.

Claude Code alone answered every question correctly too.

More documents, more gain

The gain is largest when the question uses different words or another language than the text. For one short document it is small.

Spread-out questions gain less

On the larger set, a question across three acts saved almost nothing, because Claude still searches once per act.

Indexing takes minutes

Once per folder: 16 minutes for 1,592 pages, with no Claude tokens. It pays off if you ask more than once.

Page numbers slipped

In the measured version, two citations were one page off where a passage crosses a page break. File, article and passage were right in every answer.

One miss, then fixed

One answer was wrong because a chart label was too small to read. After a fix in the skill, 4 of 4 were right.

Small samples

Two runs per question in the first test, one in the second. Differences of 10–20 % between runs are normal.

How it works

Code finds the passages. Claude reads them.

  1. Split along the real structure rules

    By PDF layout, headings, articles and tables. No language model decides where a section ends. Scans and charts are indexed too.

  2. Search by meaning and by keyword rules

    Vectors from a multilingual embedding model plus full-text search, merged by rank. The vector database is built in and runs on SQLite: nothing to install, no server. An optional second model re-sorts the top hits.

  3. Short hits rules

    About 1,160 tokens per search instead of 5,500. Each hit is an excerpt with file, pages and the path document › chapter › article.

  4. Read before citing AI

    Claude Code opens the passage or the article it wants to quote. Then it answers with file, page and passage.

  5. Check the citations rules

    Each citation is checked against the original text.

Installation

Two commands, then ask.

claude plugin marketplace add matthiasnordwig/matrix-mcp
claude plugin install matrix@matrix-mcp

Start Claude Code in the folder with your documents and ask. The first time, it walks you through the setup. For now it needs a Mac with Apple silicon and Node.js 18 or later. The engine is portable Rust and also builds for Linux and Windows. If you want it on your platform, tell me.

Matrix reads the folder you started in and asks before it opens any other. It never changes or deletes your files. The only text that leaves your Mac is what Claude Code reads anyway.

Where it comes from

It started as an app.

The plugin runs on the same Rust core as Matrix, my document app for Mac, Windows and iPhone. In the app a local model does the reading; here Claude Code does it.

Get it on GitHubWrite to me