programmiere

Matrix LLM · how it was built

How I built Matrix with Claude Code.

Almost all of Matrix was written by Claude Code, in many sessions and agents working in parallel. My part was the rules they work under, the checks before anything reaches me, and the decisions. This page shows those rules, where they came from, and what I measured along the way.

The app

What Matrix is.

Matrix answers questions about your own documents, recordings and videos, and every answer cites the exact passage. Plain code checks each citation against the original. The models run on your devices, several of your devices can share them, and Claude can use Matrix as a tool through MCP.

Download on the App Store Get it from Microsoft

Claude Code plugin: matrix-mcp on GitHub · @matthiasnordwig/matrix-mcp on npm · the app · the plugin

Size

Five and a half months, counted.

2,044commits in three repositories since 6 June 2026; 1,018 of the 1,066 code commits are co-authored by Claude
236,000lines of Rust, plus 62,000 lines of TypeScript for the interface
5,248automated tests: 3,707 in Rust, 1,541 for the interface
8,161lines of handbook that every session reads from

Counted on 25 November 2026 from the files under version control, without vendored code. Lines include comments and blank lines. A test is one test function or case, so the number says nothing about coverage.

The setup

One session talks to me. The others do the work.

  1. The main session coordinates

    It talks with me and stays free for that. It does small things itself, under about a minute. Everything bigger goes to a worker: a separate session if I want to steer it, a background agent otherwise.

  2. One package, one worker

    Design, build and fixes of a package stay with the same agent, because every hand-over loses knowledge. A worker splits off only what is independent, produces a lot of output (builds, logs, wide searches) or needs fresh eyes (acceptance, review).

  3. The model is chosen, not inherited

    Sonnet for mechanical work such as running builds and collecting material, Opus for building and judging. When a machine checks the result (an exit code, a count), the agent runs with low effort and only reports red. It does not go looking for the cause; an Opus agent does the diagnosis.

  4. "Green" in a report is not enough

    The main session runs the builds and tests of an agent again itself. A commit happens only after the test's own exit code is green, never after something like cargo test | grep.

  5. An acceptance agent before I see it

    Before anything goes to me for testing, a separate agent uses every changed function the way I would: the real interface in the iOS Simulator or the web version, two instances when devices talk to each other. Only when that is green is the build installed on my devices.

  6. Fixes are bundled

    While known bugs are open, each fix runs only its own tests and is committed locally. The full checks, one push (one CI run) and the installation happen once at the end of the round. A red main branch on GitHub is fixed at once.

Memory

The rules live in the repository, not in my head.

An agent starts with no memory of yesterday. So everything it needs is written down where it will read it, and what can be enforced is enforced by a script.

A short rule file

Every session loads a CLAUDE.md of under 200 lines and the handbook index, then exactly one area file of the handbook, never all of them.

Wrong facts are fixed at once

If an agent finds the handbook contradicting the code, it fixes the handbook in the same step. A wrong entry would mislead every later session.

Find before you build

Every source file starts with a comment on what it does. A generated index of these lets an agent find existing code before it writes a second copy.

Tests per user function

Including whole flows across devices: device A offers, B pairs, B picks, the question runs on A. A bug I find gets a test that reproduces it first.

Hooks that block

A session cannot end while the Rust checks, the project gates or the CI run on the main branch are red. Gates also catch source files over 600 lines (except a short list, each with its own cap) and interface text missing in any of the 22 languages.

The same in every session

When I give a rule that applies to the whole project, it goes into that file right away, not into a single conversation.

Where the rules came from

Most rules are the answer to something that went wrong.

A commit took another session's work

On 9 November an agent committed unfinished changes of a parallel session along with its own; the next commit put them back. Similar slips happened twice more in the next two weeks. Rule: never git add -A when there are changes you did not make.

Checks that said green on an empty page

The interface checks passed although the web version delivered no app at all. Now a check is red unless every view was really measured, and an empty page counts as a finding.

Only I saw the red CI

A failed GitHub run used to reach me by e-mail and nobody else. Since 21 November a hook reports it to the session, which has to fix it before it can stop.

The acceptance agent found what tests did not

Unpairing on the Mac never reached the iPhone; after the fix it arrives in 0.8 seconds. "Who was Goethe? Answer in two sentences." got the app's help pages and a refusal, because everyday words counted as questions about the app.

A crash, first reproduced

From its second start on, the Windows app crashed after 5 to 15 seconds: three threads set up the graphics card at the same time. The test reproduces it. On the PC, 8 of 10 runs crashed before the fix, 15 of 15 passed after.

My own test, then a test

A question from my iPhone to the Mac's 35B model came back as "this device is busy", although the Mac had nothing loaded. The fix came with tests for exactly that case and for the error message.

Not every rule has a recorded incident. Most rule commits hold only the new text, so this list has only cases where a commit names the cause.

Measure, don't guess

A measurement decides, and often against my first idea.

QuestionMeasuredDecision
Is Apple's built-in speech recognition good enough, or does the iPhone need Whisper?19.6 % word errors against 18.8 % for Whisper turbo, on 95 recordings (20.6 minutes) of accents, Swiss German and street noiseApple's text is enough on the iPhone; Whisper turbo stays the default elsewhere
Does skipping the silence detection help Whisper?Worse: 220 instead of 187 wrong words, and more invented words in noisy filesKeep it
Should the re-ranker read the whole passage instead of the first 512 characters?27 more hits, none fewer, across four test tables (McNemar p < 0.001); 1.05 instead of 0.64 seconds per questionWhole passage
Do more candidates for the re-ranker find more?120 candidates: MRR 0.645 in 6.6 s; 20 candidates: 0.680 in 1.3 s20
Which re-ranker for the public plugin?jina scored best (MRR 0.69), but its licence is non-commercial; bge int8 0.63, same as its full-size version at a quarter of the sizebge, slower but free to use
Is Apple's document recognition worth adding for scans?6 questions better, 5 worse, for about 1,100 lines and a Swift bridgeRemoved again
Do slide titles in a talk's transcript help search?One question won, one lost. The rule written down before the run: only with at least 4 moreWithout
Does a second device speed up tables?Mac and PC together were only 6 % faster than the PC aloneRebuilt the split: 16 % now; embedding on both is 41 % faster than the best single device
Do parallel table rows on one model help?1.20× in the self-test, under the 1.3× thresholdOne row at a time, on every device today
Does a fourth tool help the local model?Its mere presence in the prompt broke a hard check; the model never called it in 9 runsRemoved

MRR (mean reciprocal rank) is 1 if the right passage is always the first hit, 0.5 if it is always second. All runs on a Mac M4 Pro or one PC (Ryzen 7 7800X3D, Radeon RX 7900 XTX), July to November 2026.

How the measuring works

The agents measure. The method is checked first.

Answers fixed in advance

For every test question, the passage it should find is chosen from the raw text before the app has seen the question.

A second agent checks the method

Before any run over about 30 minutes, an agent that did not pick the candidates checks a list: same model family, same settings, hidden caps in the code, a seed that really changes between repetitions.

Why that list exists

A hidden cap limits a result without anyone noticing. A fixed seed turns five repetitions into five copies of the same run.

Never in parallel when timing

On Apple chips two model runs share the memory bandwidth and the times roughly double. Ranks and quality stay the same, so only timed runs have to wait.

One change per comparison

And the noise is named: with 30 questions, one or two ranks are chance.

The real app as a sample

Every series of headless model runs also gets 3 to 5 of its questions through the built app, because the interface shares memory and graphics card with the model.

One result

Claude Code with and without Matrix.

Four questions on 442 pages of EU regulations and an ENISA report, each asked twice, with Claude Code alone and with the Matrix plugin (Sonnet, 19 November 2026).

20 sper question with Matrix, 48 s without
182kinput tokens per question with Matrix, 1,025k without (both including cache)
8 of 8answers right with Matrix, 7 of 8 without

Eight runs are no proof of better answers; the gain is in time and tokens. The set and the script are public: benchmark on GitHub.

Architecture

One Rust core, three ways in.

Who uses it
iPhone and iPad
Mac and Windows
BrowserLinux container in your own network
Claude Code and other agents
Adapters
Tauri 2 appReact UI, typed calls into Rust
Web adapteraxum server, same calls over HTTP
MCPinside the running app, or as a stand-alone program from npm
Shared logic (Rust)
Import, ask with tools, tables, knowledge graph, background jobs, model pool
Core (Rust, no network, no UI)
Chunking, embeddings, retrieval, SQLitevectors as plain blobs, searched in pure Rust
Other Matrix devices
Paired over TLS in the local networkthey lend their models, re-ranking and embedding
Models, on the device by default
GGUF via llama.cppMetal, Vulkan or CPU
ONNX RuntimeCore ML on Apple, CPU elsewhere
Apple's on-device model
whisper.cppspeech to text

Optional: OpenAI-compatible endpoints, Azure, Ollama.

Everything above the core is a thin layer; the apps, the browser version and the agents call the same code.

Limits

What this page does not show.

The numbers come from my own devices and test sets of 30 questions or a few dozen recordings, not from many users. The rules grew one problem at a time, so some of them came after the damage. I don't read the code line by line any more; I read the tests, the measurements and the app in my hands. And a test count says how much is checked, not how well.

Back to Matrix