MEX: The Git-Native Memory Layer for Humans and Coding Agents

A local-first system that stores team context in the repo, routes AI attention through structured files, and verifies that documentation still matches the code.

8 min read • View on GitHub • More from mex-memory

A wide editorial scene shows a repository as a physical vault of indexed folders. On one side, a developer drops a labeled folder into a tray marked .mex. On the other, an AI agent consults the same tray while a tidy flow of files moves through the system. The image explains that memory lives inside the repo, not in a separate cloud service.
MEX makes the repository itself the memory layer, so context travels with the code and its history.
Key Takeaways

MEX starts with a simple inversion: the repo is not just where code lives, it is where team memory lives too. That matters because coding agents do not merely need more context. They need context that survives commits, handoffs, and code changes without drifting away from reality.

Why MEX Exists

The problem MEX is trying to solve is not subtle. AI coding assistants forget what happened in the last session, and human teams still spend time re-explaining decisions that should have been durable. MEX says the right place for that memory is alongside the code, in `.mex/`, where it can travel with Git instead of living in a separate SaaS layer.

The original idea was to stop coding agents from relearning the same project every session. mex gives them a structured Markdown wiki inside .mex/ for architecture, conventions, decisions, patterns and project state. That solves forgetting.

Daksh Jaitly, Creator / Maintainer · reddit.com

The Repo Becomes the Memory

The local-first idea is the heart of the project. Instead of pushing knowledge into a hosted database, MEX stores context, patterns, events, and handoff data in the repository itself. That means a checkout from six months ago does not just restore source code. It restores the team’s understanding of that code at that moment.

One memory, two entry points, three control layers. The diagram shows how humans and agents share the same local source of truth without flooding the context window.

A close-up view shows a router file as a branching rail switch. Three paths split from one line: one for matching code area, one for architecture context, and one for handoff notes. A small context gauge sits beside the switch, showing that only the needed files are loaded. The image explains that MEX routes attention instead of dumping everything into context.
MEX uses routing to keep agent attention narrow, relevant, and cheaper to load.

The Contract Layer That Keeps Everyone Honest

MEX’s contract layer is where the system stops being a nice idea and becomes infrastructure. In `packages/hub-contracts`, Zod schemas and shared TypeScript types define what counts as a relay, a job, a spec, or a problem detail. The point is bigger than validation. It means the repo’s memory speaks a protocol, not vibes.

import { z } from 'zod';

export const RelaySchema = z.object({
  id: z.string(),
  observedState: z.string(),
  blockers: z.array(z.string()).default([]),
  nextActions: z.array(z.string()).default([]),
});

export const HubProblemDetailsSchema = z.object({
  type: z.string().url().optional(),
  title: z.string(),
  status: z.number().int(),
  detail: z.string().optional(),
  instance: z.string().optional(),
});

That matters because memory systems usually fail at the edges. They store text, but not enough structure to know whether the text still matches the world. MEX tries to make every claim auditable, from project state to filesystem paths, with the same rigor you would expect from an API contract.

Relays Turn Handoffs Into Data

The relay concept is the most human part of the system. A relay captures what was observed, what is blocked, and what should happen next, so the next person or agent does not need a meeting just to reconstruct momentum. It turns “where I left off” into something versioned and reviewable.

Old handoffMEX relay
A teammate explains the state again in a meeting.A relay records the observed state, blockers, and next actions.
Important details live in chat threads.Important details live beside the repo history.
The next person starts by asking questions.The next person starts with a structured baton pass.
Context disappears when the session ends.Context survives as a durable object in Git.

Deterministic Parsing Over Vibes

MEX is unusually serious about proof. Tree-sitter builds a local code graph, and the evaluation suite checks whether that graph and the linked documentation still line up. That is a different bet from a fuzzy semantic memory store. It says the best grounding comes from parsing the code, not guessing what the code probably means.

Deterministic groundingSemantic retrieval
Anchors claims to concrete symbols and files.Returns nearby text that may be relevant.
Can flag drift when code and docs diverge.Can recall similarity without proving correctness.
Fits engineering workflows where exactness matters.Fits conversational recall and broad recall tasks.
Feels like infrastructure.Feels like memory assistance.

What MEX Is, and What It Is Not

MEX is not a general wiki, and it is not just another vector database with a UI. It is closer to a repo-native memory protocol for engineering teams that want AI context to be local, versioned, and trustworthy. That puts it in a different category from tools like Mem0, Zep, Cognee, or commercial coding assistants.

Tool typeTypical modelHow MEX differs
Traditional wikiDocuments live outside the repo.MEX keeps memory in Git and ties it to code history.
Semantic memory storeConversation-first retrieval.MEX focuses on architectural and symbol-grounded knowledge.
Generic coding assistantLarge context dump and prompt steering.MEX routes only the files the task actually needs.
Broad AI memory frameworkFlexible infrastructure.MEX is opinionated about engineering truth and drift detection.

The bigger bet is simple: team memory should behave like source code. It should be reviewable, diffable, and tied to a commit. MEX is interesting because it treats memory as an engineering problem, not a prompt trick.