Skip to content
memex

memex · authored context compression

Find the code worth reading.

memex turns your repo’s knowledge into a map agents can search. They see the whole codebase at a glance, open only the files that matter, and leave a trail for the next one.

The name is Vannevar Bush’s, from 1945. Here’s why.

Principles

A feature earns its place by removing friction an agent actually hit in a playtest.

Get started

Paste this into your agent, in the repo you want to index. It installs memex, looks around, asks you a few questions, and sets up what you choose.

INSTALL.md
Install memex in this repo: follow https://github.com/aswemaythink/memex/blob/main/INSTALL.md

Or install it yourself

One command in the repo. It installs the binary if needed, creates .memex/, and adds a block to AGENTS.md that tells any agent to read intent before code. It is safe to repeat.

npx @aswemaythink/memex init
Other ways to install

Manual, one command per toolchain, then memex init, or download a binary from GitHub Releases. The last line builds the binary from a checkout of the repo. It is one codebase for Linux, macOS and Windows.

brew install aswemaythink/tap/memex
cargo install agent-memex
curl -LsSf https://github.com/aswemaythink/memex/releases/latest/download/agent-memex-installer.sh | sh
powershell -c "irm https://github.com/aswemaythink/memex/releases/latest/download/agent-memex-installer.ps1 | iex"
git clone https://github.com/aswemaythink/memex && cd memex && cargo install --path . --locked

On Claude Code, an optional plugin carries the snippet and a start hook that prints memex info:

/plugin marketplace add aswemaythink/memex
/plugin install memex@memex

After a manual install, run memex init in the repo. To uninstall, delete .memex/ and the marked block in AGENTS.md.

Context compression

memex is authored context compression. A README compresses a folder, a header a file, a case a test, a log an agent’s run. Whoever knew the most writes it, when they knew it best, so nothing has to summarise it later.

How an agent explores your codebase

Agents use the memex CLI to walk your codebase as a tree: a README at each folder, a header at the top of each file. Here two agents take turns. One wants to understand the API: the READMEs and the headers of the api files tell it enough, and it opens no code. The other is changing the schema: it finds the two files it must touch, the model and the migration, and opens only those.

A repo tree with a dotted rail beside it and a dim chip for each folder and file. The first agent, to understand the API, reads the READMEs of repo, src and api and the headers of model.ts, handler.ts and store.ts, and opens no code. The second, to change the schema, reads the same READMEs and the header of model.ts and opens it, then reads the db README and the header of 001_orders.sql and opens that migration. Each chip lights as it is read.

The intent layer

READMEs, headers, collections and logs are the intent layer. The table runs from the most compressed at the top to the code at the bottom. READMEs and headers are found by where they are, collections by what they are, logs by when. An agent reads down it and opens code last.

Tap a row for an example.

  • READMEs What a module is. One README.md per folder, saying what that module is and what it does.
  • Headers What a file does. A comment at the top of the file that describes what it does.
  • Collections Additional knowledge worth keeping, found by what it is. Any Markdown file joins a collection with one memex: line in its frontmatter. See Patterns for ways to use them.
  • Logs Notes agents leave for each other. Findings, hand-offs and messages, in .memex/logs/, out of git. Pruned as new ones arrive.
  • Code The source itself. Agents usually scan it wholesale, with grep, rg and the like. memex reads only the comment at the top of each file.

The bigger picture

In a large codebase, reading the code to see the whole picture costs more context than any agent has. memex gives agents a compressed version to traverse instead: what each part does, conceptually. They still read code. They find the code worth reading faster, and make better decisions once they are there.

A grid of forty files, each a dim block of code under a faint orange header strip. An agent starts at the top left and zigzags down the gaps between the blocks; each strip it reads lights up, one per row. Then the code of three of those files lights up, one after another: the files its headers pointed to. The other strips and files stay dim.

Trailblazing

Compression gets an agent to the right code. Trails let the next agent start where the last one stopped. Bush’s memex was built around them: a reader linked what they found into a path someone else could follow later. memex gives agents two kinds: logs for work in progress, and collections for what stays true.

Logs

Logs are how an orchestrator and its worker agents talk to each other.

A worker logs what it did and what it found, and hands back a single line, the log’s ref; the orchestrator opens the full log only when it needs the detail. Reports, hand-offs and messages all travel this way, so logs fit whatever orchestration pattern your agents run. Logs are like chats: useful in the moment, stale soon after. memex prunes old ones as new ones arrive. Whatever is still true gets written into a README, a header or a collection; the rest can go.

Two agents, worker-1 and worker-2, on the left and an orchestrator on the right, with an impl log stream between them drawn as a stack of entries, newest on top, each labelled with its ref. Each worker adds an entry to the top of the stack and sends the orchestrator one line, report: and the ref, not the whole log. Each new entry pushes the stack down and the oldest entry fades out. The orchestrator opens one ref, parallel-walk, and that entry lights up; one line from it moves into a README.

Collections

A collection is a set of records on one topic that agents keep and search.

Each record is small and does one job: one attempt, one decision, one test. Any Markdown file joins a collection with one frontmatter line, so records live next to the work they describe.

Take performance work on an app. Every optimisation an agent tries gets a record: what it changed, what it measured, kept or cut. The next agent searches the collection before it starts. It sees what was tried, skips what failed, and goes straight to what is still worth trying.

A performance-optimize collection drawn as a column of four records: PERF-01 virtualise the product list, kept; PERF-02 memoise cart totals, cut; PERF-03 serve images as WebP, kept; PERF-04 sort on the server, cut. An agent with the task make checkout faster runs memex search --in performance-optimize and reads down the column; each record lights as it is read, the cut ones dim and are struck through as dead ends, and the kept ones stay lit. Then a fifth record appears with a dashed outline: PERF-05 split the checkout bundle, trying.

Audit

Code moves on and the intent layer can fall behind it. memex audit checks for the drift: files with no header, folders with no README, files grown too long, one-liners that run long, references that resolve to nothing, duplicate ids. Agents run it on the paths they changed and fix what it lists in the same change, or log the rest to drift.

$ memex audit src
audit       src · 148 files · 12 folders · 2 findings
headers     (showing 1 of 1; files with no header)
  src/a.rs
(no header): add a comment block atop the file; its first sentence states the file's purpose
cites       (showing 1 of 1; unresolved)
  src/z.rs  → NAME-404
(cites): fix the reference or remove it

See memex audit and Drift.

API at a glance

Six verbs, all read-only except init and log. Every list says showing N of M and takes --limit; --json gives one JSON document.

memex init
Set memex up in a repo, once. Safe to repeat.
memex info
Where everything is: the graph, collections, log streams and messages waiting for you.
memex show <path|id>
Read one thing’s intent, then walk its trail: what it cites and what cites it.
memex search <words>
Find by words across READMEs, headers, collections and logs.
memex audit <paths>
List where intent is missing or a citation is broken.
memex log <stream>
Record a finding and hand back a one-line ref.

Read the full docs →

The story

Good work was being lost, not because it was wrong, but because nobody could get back to it.

1945

Vannevar Bush ran American science through the Second World War. When it ended, what kept him up at night wasn’t weapons. It was the record. Science was producing findings faster than anyone could find them again.

In July 1945 he published “As We May Think” in The Atlantic. In it he imagined a desk: two slanted translucent screens, a keyboard, levers, and inside, on microfilm, every book, letter and note you owned. He called it the memex.

A memex desk, sketched: two slanted translucent screens side by side, with a dotted trail joining a highlighted line on the left screen to one on the right.
The memex, sketched: two documents side by side, tied together.

Storage wasn’t the point. The point was trails. Libraries index by alphabet and category; the human mind, Bush wrote, “operates by association.” On the memex you would put two documents side by side, press a button, and tie them together. Do it again and again, add your own notes, and you’ve laid a trail through the material: your reasoning, kept, so you or anyone you handed it to could walk it later.

The process of tying two items together is the important thing.

Vannevar Bush, “As We May Think”, The Atlantic, July 1945

Bush predicted a new profession: trail blazers, people who take delight in making useful paths through the common record.

The memex was never built. But Douglas Engelbart read the essay in 1945 as a young radar technician and spent his life on it. That became the 1968 demo that gave us the mouse and hypertext. Ted Nelson named hypertext with Bush in mind. From there, the web. Every link you’ve ever clicked descends from that desk.

The camera and the trail

The same essay has a second machine in it. Bush pictures a scientist with a camera the size of a walnut strapped to his forehead, taking a picture of everything he sees. Nothing is chosen at the moment of capture. You record it all, and sort it out later.

So the essay holds two answers to the same flood. The camera says: keep everything, and hope to find it again. The trail says: when you understand something, tie it to what it belongs with, so the next reader can follow. Those links are made on purpose, by someone who understood the material, at the moment they understood it.

The trail is the idea that changed the world. It became hypertext, then the web. The camera is the one we keep coming back to.

Now

Eighty years later, the flood is back, and this time agents produce it. Every run writes logs, reports, notes and hand-offs into folders nobody will open again.

And we are still building cameras. Hooks that record every step, servers that store it, vector databases that index it, models that summarise the pile after the fact. Smaller cameras, more film, the same hope: capture everything now, and something will make sense of it later. But a recording knows what happened, not what it meant. Whoever understood the work was there at the time, and nobody asked them to write it down.

memex takes Bush’s other idea.

memex

memex is authored context compression: trails of intent, for humans and agents.

Code records what a system does. The intent layer records what it’s for: a README says why a folder exists, a header says what a file is for, a case says what’s claimed and how it’s proven, and a log says what an agent was trying and what it found. Whoever understood it best compresses it, at the moment they understood it. Citations become trails, and memex walks them both ways (the intent layer, above).

Developers and agents are the trail blazers. An agent that finishes a job compresses what it learned and cites what it touched; the next agent walks that trail instead of starting from zero. Logs are the camera’s film: kept while the work is live, then thrown away. What’s still true gets authored into the layer.

No server, no database, no model in the loop. Markdown files and a CLI. Because the compression was already done, by whoever understood it.

Why this matters to us

When the story came together, the reaction was goosebumps. It wasn’t the history alone. It was recognising that the thing we’d been designing for practical reasons (READMEs everywhere, headers, case ids cited in prose, logs that expire, no automated capture) was Bush’s idea all along, and that it had been the right idea for eighty years.

The camera has always been tempting.
The trail has always been what mattered.