Your AI agent forgets everything. mex gives it long-term memory.
mex is a CLI that builds persistent, routed project memory for AI agents and checks it for drift so your context window stays small and honest.

What it does
mex generates a .mex/ directory inside your repo containing a structured markdown scaffold—ROUTER.md, context/, patterns/, and an append-only event log. The agent loads only a tiny anchor file, which routes it to task-specific context instead of dumping the entire project history into the prompt. A built-in drift detector validates paths, dependencies, commands, and staleness without burning any AI tokens.
The interesting bit
The clever part is the separation of “memory structure” from “memory content.” mex doesn’t just store notes; it enforces a routing protocol so the agent loads only what it needs, and its eight checkers score scaffold honesty out of 100. When reality diverges from the docs, the sync subcommand generates targeted repair prompts rather than rewriting everything.
Key highlights
- Claims ~60% average token reduction per session by routing context instead of dumping giant rules files.
- Supports Claude Code, Cursor, Windsurf, GitHub Copilot, OpenCode, and Codex via tool-specific anchor files.
- Drift detection runs fully offline: eight checkers validate paths, commands, dependencies, and cross-file consistency.
- Includes an “agent memory mode” for persistent operational agents (homelab, infrastructure) with heartbeat health checks.
- Community-tested on Ubuntu/Kubernetes/Docker scenarios with a reported 10/10 pass rate and 100/100 drift scores.
Caveats
- The token-reduction benchmarks come from a single community member’s test on one project; your mileage may vary.
- Initial scaffold population still relies on an AI agent to interpret the prompt and write the memory files.
Verdict
Worth a look if you use Claude Code, Cursor, or similar tools on a codebase long enough that repeated “here is my project” prompts feel absurd. Skip it if you live in one-off scripts or prefer your agent context unstructured and chatty.