mex-memory/mex
Persistent project memory for AI coding agents. Structured scaffold + drift detection CLI.
What it solves
AI coding agents often struggle with large codebases because they either rediscover the same architectural patterns every session or flood their context windows with massive, stale instruction files. mex solves this by creating a "living wiki"—a repo-local, structured Markdown documentation system that grows and evolves alongside the code, ensuring agents have precise, task-relevant context without redundant repository scans.
How it works
mex uses a combination of a deterministic local code graph and structured Markdown files to maintain project knowledge:
- Code Mapping: It builds a local graph using Tree-sitter and SQLite to index symbols and relationships across languages like TypeScript, Python, and Rust.
- Wiki Generation: Agents use this graph to populate a structured Markdown wiki (e.g., architecture, conventions, and patterns) stored directly in the repository.
- Context Routing: Instead of loading everything, agents use a routing system (
ROUTER.md) to load only the specific wiki pages and code-graph neighborhoods relevant to the current task. - Drift Detection: The tool identifies when code changes invalidate wiki claims through "grounding" (linking claims to exact code symbols), allowing agents to perform targeted repairs via
mex sync.
Who it’s for
Developers using AI coding agents (such as Claude Code, Cursor, Windsurf, or GitHub Copilot) who want to reduce token usage, lower latency, and prevent their AI assistants from losing architectural context between sessions.
Highlights
- Grounded Knowledge: Connects documentation claims to exact code symbols, allowing the system to detect when refactors break the documentation.
- Task-Aware Routing: Reduces context window bloat by loading only the necessary documentation and source code for a specific job.
- Deterministic Retrieval: Uses a code graph to provide source-backed retrieval and impact analysis without spending AI tokens on mechanical search.
- Multi-Agent Compatibility: Provides project anchors for various tools like
.cursorrulesorCLAUDE.mdto integrate seamlessly with different AI coding assistants.
Related
- Project
- Project
- Project
- Project
- Project