# memU
### Personal memory, stored as files
**Across Agents. Fast retrieval. Lower cost.**
[](https://badge.fury.io/py/memu-cli)
[](https://opensource.org/licenses/Apache-2.0)
[](https://www.python.org/downloads/)
[](https://discord.com/invite/hQZntfGsbJ)
[](https://x.com/memU_ai)
---
memU is a 500-line memory system for AI agents. Agents write what's worth keeping as Markdown; memU stores it, embeds it, and retrieves ranked context in a single call — embeddings are the only model calls it makes. The entire memory logic lives in [`agentic.py`](src/memu/app/agentic.py) + [`service.py`](src/memu/app/service.py); everything else is pluggable storage and embedding transport.
**Installation is agent-driven.** The guides are written for the agent, not for you. One message is the whole setup — tell your agent:
> Read https://raw.githubusercontent.com/NevaMind-AI/MemU/main/SKILL.md and follow it to install memU.
It works for Codex, Claude Code, Cursor, OpenClaw, Hermes — and any other agent, via detection. Details in [Host adapters](#host-adapters-memory-for-desktop-coding-agents).
## Quick start
```python
from memu.app import MemoryService
service = MemoryService(
database_config={"metadata_store": {"provider": "sqlite", "dsn": "sqlite:///memu.sqlite3"}},
)
# 1. Persist agent-prepared memory: recall files (memory/skill tracks) + resources
await service.commit_results(
recall_files=[
{
"name": "Profile",
"track": "memory",
"description": "who the user is",
"content": "# Profile\n- prefers dark roast coffee\n- ships on Fridays",
},
{
"name": "deploy-checklist",
"track": "skill",
"description": "how to deploy this repo",
"content": "1. run tests\n2. tag\n3. push",
},
],
resource=[{"path": "/abs/path/notes.md", "description": "meeting notes from the launch review"}],
)
# 2. See what is stored, across every track
files = await service.list_all_recall_files()
# 3. Single-shot embedding retrieval over segments / files / resources
context = await service.progressive_retrieve("What should I know about this user's launch preferences?")
```
Or straight from the terminal — no code:
```bash
export OPENAI_API_KEY=sk-... # embedding API key — the only model calls memU makes
npx memu-cli commit results.json # {"recall_files": [...], "resource": [...]}
npx memu-cli list-files
npx memu-cli retrieve "What should I know about this user's launch preferences?"
```
State persists in a local SQLite database (`./data/memu.sqlite3` by default), so commit in one invocation and retrieve in the next.
## How it works

### The data model
Memory is a set of **recall files** — one Markdown document per topic (`track="memory"`) or per learned skill (`track="skill"`). Committing a file also writes its search index:
| Record | What it is | How it's embedded |
|---|---|---|
| **RecallFile** | The Markdown document itself (`name`, `track`, `description`, `content`) | `name: description`, once at creation |
| **RecallFileSegment** | Searchable slices of a file | memory track: one per content line (headings skipped); skill track: one `name: description` segment per skill |
| **Resource** | A raw source on disk (`url`, `caption`) | its one-line caption |
Segments are reconciled on every commit: lines that disappeared are deleted, only genuinely new lines are embedded, unchanged lines keep their vectors — so re-committing a lightly edited file is nearly free.
### Retrieval
`progressive_retrieve(query)` embeds the query **once** and returns three ranked layers:
- `segments` — the matched slices, narrowest and usually most on-point, each with a `score`
- `files` — the documents those segments belong to (usually what you want), each scored by its best segment and carrying its linked `resource_urls`
- `resources` — matching raw sources, for when summaries are not enough
There is no intention routing, sufficiency checking, or summarization — one embedding call in, ranked context out.
## Host adapters: memory for desktop coding agents
memU runs as a sidecar to a desktop agent (ADR 0008/0009/0010), one binary per host. Each binds two seams:
- **record** — a scheduled bridging task slices new session logs into self-contained job files; the agent itself distills them into memory/skill Markdown; `commit` submits whatever the agent left on disk back through `commit_results`.
- **inject** — a standing instruction in the host's instruction file tells the agent to run `