programmiere

Matrix for Claude Code

Claude Code needed 5.6× fewer input tokens.

With this free plugin, Claude Code used 182k instead of 1,025k input tokens per question on 442 pages of EU regulations and a report, and it wrote 2.5× fewer output tokens. No loss in quality: all 8 answers were right, against 7 of 8 without it.

Fewer tokens mean your subscription limit lasts longer and Claude's context window keeps room for your work. It was also faster: 20 instead of 48 seconds per question.

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.

It is made for work with documents, for example a lawyer with questions about contracts, regulations or case files. It does not get in the way when you code: Claude picks it for questions about documents and searches source files with its own tools.

Claude Code searches code with its own tools instead of a vector index, and Anthropic has said that worked better for code. But Claude is not only used by developers. For documents, where a question rarely uses the words of the text, an index pays off.

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 more than a dozen tool calls per question.

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

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

Same questions, with and without the plugin.

Claude Code alone against Claude Code with the plugin, on 442 pages of public EU regulations and a report. Same questions, same prompt, two runs each. I wrote down the right answers before the first run.

5.6× fewerinput tokens per question: 182k instead of 1,025k
2.5× feweroutput tokens: 1.6k instead of 3.9k
45 % fewertool calls: 7.9 instead of 14.4
2.4× faster20 s instead of 48 s per question, a side effect of reading less
Input tokens, output tokens and time. Each bar is the average of two runs per question.
Bar chart titled: Claude Code on 442 pages of PDFs, 5.6× fewer input tokens. Average per question, Sonnet, plugin 0.2.9, November 2026, two runs per question each; Claude Code alone against Claude Code with the Matrix plugin. Input tokens: English question on German legal text 851k to 172k, value only in a chart 913k to 232k, answer spread over three regulations 1,415k to 223k, paraphrased question on one regulation 920k to 102k, average 1,025k to 182k. Output tokens, 2.5× fewer, same order: 3.1k to 1.1k, 3.3k to 1.5k, 6.4k to 3.0k, 2.9k to 0.8k, average 3.9k to 1.6k. Time, shown as a side effect, same order: 38 to 21 s, 43 to 21 s, 71 to 27 s, 38 to 12 s, average 48 to 20 s. Footnote: same documents, questions and answers as in October, when it was 651k input tokens alone and 303k with the plugin.
Question (442 pages)AloneWith Matrix
English question, German legal text851k in · 3.1k out · 38 s172k in · 1.1k out · 21 s
A number that exists only in a chart913k in · 3.3k out · 43 s232k in · 1.5k out · 21 s
One answer spread over three regulations1,415k in · 6.4k out · 71 s223k in · 3.0k out · 27 s
Paraphrased question, single regulation920k in · 2.9k out · 38 s102k in · 0.8k out · 12 s

Averages per run, Claude Code 2.1.309 with Sonnet and plugin 0.2.9, November 2026. Two runs per question on both sides. Input tokens add up what the model processes over all turns; output tokens are what it writes, its tool calls and the answer. Cache reads, the same conversation sent again with each turn, make up 93 % of them without the plugin and 86 % with it; without cache reads it is 76k against 25k tokens. With the plugin all 8 answers were right; without it 7 of 8, because Claude Code once read a value from the wrong chart. The second run without the plugin ran while another build used the Mac, so its times may be slightly high; the tokens are unaffected. The questions, the right answers, the raw data and the script to run it again are in the test set below; the full write-up is inDEMO.md.

A second, larger test set was measured in October with plugin version 0.2.3, one run per question: on 1,592 pages in 14 documents and four languages, the plugin used 34 % fewer input tokens and 35 % less time.

The first run of this test, in October with Claude Code 2.1.222 and an earlier plugin version, gave 303k instead of 651k tokens and 42 instead of 126 seconds. Without the plugin, Claude Code now needs more input tokens, 1,025k instead of 651k, but much less time, 48 instead of 126 seconds. So the plugin now saves more than four fifths of the input tokens instead of about half, and a bit more than half the time instead of two thirds.

How it was measured

Check it yourself: the test set is public.

Anyone can download the documents. The questions, the right answers, the script and the raw results of all 16 runs are in the test set, so anyone can check the numbers above or run the test again.

Test set on GitHubDownload ZIP (23 KB)

The ZIP holds the five files of the measurement of 19 November 2026: README.md (method and limits), questions.json (document sources, questions, right answers, pages),results-2026-11-19.jsonl (one line per run, with the full answer),probe-2026-11-19.json (search hits without Claude) and bench_claude_plugin.py (the script). The PDFs are not in it; the script downloads them.

The documents

442 pages in four PDFs: three EU regulations in German from the EU Publications Office, and one English report whose numbers sit in charts. The script downloads them and compares each file with the one measured (by its SHA-256 checksum), because a new rendering of a PDF can shift its pages.

FileDocumentPages
dora.pdfDORA, Regulation (EU) 2022/2554, German79
ai-act.pdfAI Act, Regulation (EU) 2024/1689, German144
dsgvo.pdfGDPR, Regulation (EU) 2016/679, German88
enisa-tl-2024.pdfENISA Threat Landscape 2024, English, CC BY 4.0131

The questions and the right answers

Written down with their pages before the first run. Pages are PDF pages, 1 is the first page of the file.

  1. Q1 “Under the EU rules on digital operational resilience of the financial sector, how often do the larger financial entities have to run advanced testing that simulates real attackers?”

    English paraphrase of German text. Right answer: at least every three years (threat-led penetration testing, TLPT); the authority may ask for a lower or higher frequency. dora.pdf p. 46, Art. 26(1)

  2. Q2 “In ENISA's threat landscape report for 2024, which share of the analysed incidents concerned threats against data (breaches, leaks)?”

    A value that exists only in a chart. Right answer: 19.01 % (about 1.91 K incidents), third after DoS/DDoS/RDoS (41.1 %) and ransomware (25.79 %). enisa-tl-2024.pdf p. 10 (printed 9), Figure 2

  3. Q3 “An incident at a bank affects personal data, a high-risk AI system and the bank's ICT at the same time. What deadlines for reporting to the authorities do the GDPR, the AI Act and DORA each set?”

    One answer spread over three regulations. Right answer: GDPR without undue delay, where feasible within 72 hours. AI Act at the latest 15 days, 2 days for a widespread infringement or critical infrastructure, 10 days in case of death. DORA sets no hours itself: initial, intermediate and final report within limits set by technical standards. dsgvo.pdf p. 52, Art. 33(1); ai-act.pdf p. 101–102, Art. 73(2)–(4); dora.pdf p. 42–43, Art. 19(4), 20(a)(ii)

  4. Q4 “For how long must the provider of a high-risk AI system keep its technical documentation available for the national authorities?”

    English paraphrase, single regulation. Right answer: ten years after the system was placed on the market or put into service. ai-act.pdf p. 63, Art. 18(1)

The runs

  • Claude Code 2.1.309 without its interactive interface (claude -p), model Sonnet, plugin 0.2.9.
  • A, Claude Code alone: the tools Read, Grep and Glob, and Bash only for pdftotext.
  • B, with the plugin: the same tools plus the plugin (--plugin-dir), with its read tools approved, plus the built-in tools ToolSearch and Skill.
  • The same prompt for both, apart from where to look (B names the Matrix collection): the question, then “Give a short answer and, for every fact, its source as file name and PDF page number (1 = first page of the file). Do not answer from memory.”
  • Every run starts in an empty folder, with the PDF folder added (--add-dir) and only project settings, so my own settings, plugins and CLAUDE.md stay out. No session is saved.
  • Two runs per question and configuration, 16 runs, one configuration after the other. A first attempt that ran them in parallel was discarded, because times on a shared machine are not comparable.
  • Indexing ran once before the B runs and is not in the numbers per question: 1,745 passages in 277 s on an Apple-silicon Mac, with no Claude tokens.

What is counted

Everything comes from the result Claude Code prints at the end of each run.

  • Input tokens: input_tokens + cache_creation_input_tokens +cache_read_input_tokens, over all turns. Cache reads are most of them (A 93 %, B 86 %) and are kept as their own field in the raw data.
  • Output tokens: output_tokens.
  • Time: duration_ms, Claude Code's own measure.
  • Tool calls: the tool_use blocks in the stream (--output-format stream-json).
  • The raw data also hold the cost Claude Code reports at API prices. It is not used on this page.

How the answers were scored

The script scores first: an answer counts as right if it contains every key term of the right answer (patterns in questions.json, such as “72 hours” or “15 days”), and as cited if it names the right file with one of the right pages. Then every answer was checked by hand, and the figures on this page are the checked ones.

The two differ in one place. The script marks both answers to Q3 with the plugin as wrong. They came in German, and the script's pattern for DORA's technical standards only knows the English words, so it missed “technische (Regulierungs-)Standards”. The other four key terms matched. Their content is right: 72 hours, 15 days, 2 and 10 days, DORA without fixed hours, the right pages. The first answer to Q2 without the plugin is wrong in both: 15.87 % from another chart instead of 19.01 %.

What it does not show

  • Two runs per question and configuration. Two runs of the same question can differ a lot (see the limits below).
  • One model (Sonnet), one Claude Code version, one machine, one set of documents. Claude Code alone got much faster between October and November, so the gap depends on the version.
  • The four questions are known: after a miss on Q2 in October, the plugin's ask skill was changed.
  • The raw data of the October measurement were not kept. Its numbers on this page come from DEMO.md.

Run it yourself

You need Python 3.9 or later, Node.js 18 or later, Claude Code logged in, andpdftotext (poppler). The script expects the plugin in the folder above it, so run it from thebenchmark folder of the repository:

python3 bench_claude_plugin.py fetch --corpus ~/matrix-bench/corpus
python3 bench_claude_plugin.py index --corpus ~/matrix-bench/corpus --bench ~/matrix-bench/run
python3 bench_claude_plugin.py run   --bench ~/matrix-bench/run

fetch needs a new, empty folder. index downloads the plugin's search model once, about 1.2 GB, and keeps its data apart from your own Matrix data. run makes the 16 runs in about 10 minutes and counts against your Claude usage. Then report --bench ~/matrix-bench/run prints the table per question.

The limits

It saves tokens and time. Better answers are not proven.

Claude Code alone got 7 of 8 answers right. One wrong answer in eight runs is not an error rate.

Made for documents

The gain comes from questions about documents. For code, Claude leaves the plugin aside and searches the source files with its own tools, so installing it costs nothing there.

More documents, more gain

Here the paraphrased question on one regulation saved the largest share (920k → 102k tokens), the one spread over three regulations the most tokens (1,415k → 223k). For one short document the gain is small.

Spread-out questions: mixed

On the larger set, in October with version 0.2.3, a question across three acts saved almost nothing, because Claude still searches once per act. On the 442 pages in November it was the other way round: 1,415k → 223k tokens, 71 → 27 s.

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 October test of version 0.2.3, two citations were one page off where a passage crosses a page break. File, article and passage were right in every answer. Fixed in the released 0.2.3: a hit lists every page its passage covers.

Charts are easy to misread

Without the plugin, in one of two runs, Claude Code took 15.87 % from another chart (p. 13) in a low-resolution page image, instead of 19.01 % on p. 10. In October the plugin had the same problem once, because the page image was too small. This time it found and read the chart page right in both runs.

Small samples

Two runs per question on both sides on 442 pages in November, one run on 1,592 pages in October. Without the plugin, the two runs of one question differed by up to 56 % in tokens (665k and 1,037k).

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

    A search returns as many short excerpts as fit into one result, each 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. It runs on macOS (Apple silicon), Windows 10 or later (x64) and Linux (x64 and arm64), with Node.js 18 or later. If it does not run on your system, 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 computer 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