memrig
v0.2.0
Published
SQLite memory brain for AI coding assistants — per-user + shared memory via MCP
Maintainers
Readme
memrig
SQLite memory brain for AI coding assistants. Per-user + shared team memory, hybrid search, zero config.
What It Does
memrig gives AI coding assistants (Claude Code, Cursor, etc.) persistent memory that survives across sessions. Each team member gets their own private memory plus a shared team brain — all searchable via full-text + semantic search.
your-project/
├── .mcp.json ← committed to git
├── .memory/
│ ├── shared.db ← team knowledge (committed)
│ └── users/
│ ├── alice.db ← Alice's memories (gitignored)
│ └── bob.db ← Bob's memories (gitignored)Install
npm install memrigQuick Start
# In your project directory:
npx memrig init
# That's it. Restart Claude Code and memrig is connected.memrig init does the following:
- Creates
.memory/directory withshared.dbandusers/{you}.db - Adds
.memory/users/to.gitignore(personal memories stay private) - Creates
.mcp.jsonwith the memrig server config
Manual Setup
If you prefer to configure manually, add this to your .mcp.json:
{
"mcpServers": {
"memrig": {
"command": "npx",
"args": ["-y", "memrig"],
"env": {
"MEMORY_DIR": ".memory",
"MEMRIG_USER": "${USER}"
}
}
}
}MCP Tools
| Tool | What It Does |
|------|-------------|
| remember | Save a memory (personal by default, or shared) |
| recall | Search memories — hybrid FTS5 + vector search |
| forget | Delete a memory by ID |
| share | Promote a personal memory to shared team memory |
| import_memory | Copy a shared memory to your personal space |
| list_memories | Browse memories with filters |
| link | Create an explicit relation between two memories (related, supersedes, or contradicts) |
Live Graph
npx memrig graphOpens http://127.0.0.1:4319 in your browser — a live, force-directed graph of your memories.
Flags:
| Flag | Description |
|------|-------------|
| --port <n> | Use a different port (default: 4319) |
| --no-open | Start the server without opening a browser tab |
| --user <name> | View a specific user's memory (defaults to MEMRIG_USER) |
Respects the MEMORY_DIR environment variable.
What you see:
- Nodes — each memory; color-coded by type, size reflects importance, faded when Ebbinghaus strength is low
- Edges — three kinds, each togglable in the top bar:
- Explicit links (red =
contradicts, arrow =supersedes, plain =related) — created by thelinktool - Dotted lines — semantic similarity derived from sqlite-vec embeddings
- Faint lines — shared tags
- Explicit links (red =
- Search — highlights matching nodes
- Click a node — opens a side panel with full content and a Forget button
- Live updates — the graph refreshes via SSE as the assistant remembers, recalls, or links
Memory Types
decision— Architectural or product decisionspreference— Personal or team preferencescontext— Background context about the projectbug— Known bugs and workaroundspattern— Code patterns and conventionsarchitecture— System architecture notes
How Search Works
recall uses hybrid retrieval:
- FTS5 BM25 — keyword matching across content and tags
- sqlite-vec — semantic similarity (MiniLM-L6-v2 embeddings, runs locally)
- Reciprocal Rank Fusion — merges both ranked lists with
score = Σ 1/(k + rank) - Ebbinghaus decay — older, less-accessed memories rank lower (decay rate varies by type)
- Cross-DB merge — personal results weighted 1.1x higher than shared
Memories below 5% strength are auto-pruned during recall.
Configuration
Environment variables (set in .mcp.json):
| Variable | Default | Description |
|----------|---------|-------------|
| MEMORY_DIR | .memory | Path to memory directory |
| MEMRIG_USER | $USER | Username for personal memory isolation |
For Teams
- One person runs
npx memrig initand commits.mcp.json+.memory/shared.db - Everyone else pulls and runs
npx memrig init(idempotent — won't overwrite existing config) - Shared memories sync via git. Personal memories stay local.
- Use the
sharetool to promote personal memories to the team,import_memoryto pull shared memories into your personal space.
Development
git clone https://github.com/RiggdAI/memrig.git
cd memrig
npm install
npm test # run tests (vitest)
npm run build # compile with tsupLicense
MIT
