
# Engram
**Universal AI Brain — persistent memory and cognition layer for any AI model**
[](https://github.com/ayvazyan10/engram/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/@engram-ai-memory/core)
[](https://www.npmjs.com/package/@engram-ai-memory/mcp)
[](https://smithery.ai/skills/ayvazyan10/engram)
[](LICENSE)
[](https://nodejs.org)
[](https://pnpm.io)
[**Quick Start**](#quick-start) · [**Features**](#features) · [**CLI**](#cli) · [**Docs**](docs/) · [**Live Demo**](#live-demo) · [**Integrations**](#integrations) · [**Contributing**](CONTRIBUTING.md)
---
## What is Engram?
Engram gives any AI model **human-like memory** that persists across sessions, systems, and restarts. Connect it once and every AI you use — Claude Code, Ollama, or any custom integration — shares a single, growing brain.
Most AI tools forget everything the moment a session ends. Engram solves this by acting as a universal memory backend: it stores what your AIs learn, retrieves the right memories at the right time, and presents them as context — automatically.
```
┌─ You tell Claude Code about your stack ──→ stored as semantic memory
└─ Next day, different tool, new session ──→ Engram recalls it automatically
```
---
## Features
| Feature | Description |
|---|---|
| **3 Memory Types** | Episodic (events), Semantic (facts + knowledge graph), Procedural (trigger→action patterns) |
| **7-Step Recall Pipeline** | Embed → Vector search → Graph expand → Score → Rank → Truncate → Log |
| **Memory Decay & GC** | Ebbinghaus forgetting curve, auto-archive stale memories, episodic→semantic consolidation |
| **Memory Reflection** | AI-driven insight engine — the AI connected over MCP reasons over your memories to surface patterns, knowledge gaps, trends, and contradictions. Engram runs no LLM of its own — no API keys, no external calls. |
| **Atlas dashboard** | Map, Recall, Review, Timeline, Insights and Settings; light/dark and ⌘K command palette |
| **Optional Namespaces** | Disabled by default; enable filtering or strict isolation per project/agent |
| **Contradiction Detection** | Auto-detect conflicting memories, 5 resolution strategies (keep_newest/oldest/important/both/manual) |
| **Embedding Upgradability** | Swap embedding models, store model ID alongside vectors, batch re-embedding pipeline |
| **Streaming Recall** | SSE endpoint — high-confidence memories first, graph-expanded backfill later |
| **Index Persistence** | Save/load vector index to disk for fast startup (27-37x speedup) |
| **CLI Tool** | `engram store/search/recall/stats/forget/export/import/reflections/cloud` from the terminal |
| **Import/Export** | Full backup & restore as JSON or NDJSON via CLI or API |
| **Webhooks** | Subscribe external systems to memory events (stored, forgotten, decayed, consolidated, contradiction, reflected) |
| **Tagging & Collections** | Tag cloud, filter by tag, prefix-based collections (e.g. `project:alpha`) |
| **Plugin System** | 7 lifecycle hooks (onStore, onRecall, onForget, onDecay, onReflect, onStartup, onShutdown) |
| **Importance Decay** | Source-aware default importance, daily decay for unused memories, protection rules for AI clients |
| **Inline Edit & Bulk Ops** | PATCH individual memories, bulk tag/archive via API and dashboard |
| **Observability** | Debug endpoints, scoring breakdowns, Swagger UI at `/docs` |
---
## How it works
Every time an AI connected to Engram receives a query:
1. **Embeds** the query into a 384-dimensional semantic vector *(locally — no API, no cost)*
2. **Searches** its vector index for similar past memories
3. **Expands** via the knowledge graph to retrieve related concepts
4. **Scores** candidates by semantic similarity + recency + importance + access frequency
5. **Checks** for contradictions with existing memories
6. **Injects** the assembled context into the AI's prompt
The AI responds with awareness of everything it has ever learned. After the exchange, the response is stored as a new memory — the brain grows continuously.
---
## Memory model
| Type | What it stores | Example |
|---|---|---|
| **Episodic** | Events, conversations, timestamped interactions | *"User asked about deployment on 2026-03-15"* |
| **Semantic** | Facts, knowledge, concepts + knowledge graph | `concept: TypeScript` → *"typed superset of JavaScript"* |
| **Procedural** | Patterns, skills, trigger→action rules | *"When user asks about DB migrations → use drizzle-kit generate"* |
| **Working** | Dynamically assembled context for a query | *(assembled at query time, not stored)* |
---
## Integrations
```
Claude Code ──MCP──────────→ ┐
Claude Desktop ──extension────→ │ Engram → SQLite
Ollama ──proxy────────→ │ REST :4901
Any app ──REST─────────→ │
CLI ──direct───────→ ┘
```
| Integration | Method | How |
|---|---|---|
| **Claude Code** | MCP (24 native tools) | `store_memory`, `recall_context`, `request_reflection`, … |
| **Claude Desktop** | 1-click Desktop Extension | [Smithery](https://smithery.ai/skills/ayvazyan10/engram) or `.mcpb` from releases |
| **Ollama** | Transparent HTTP proxy | Point client at `:11435` instead of `:11434` |
| **Any app** | Direct REST API | `POST /api/recall` + `POST /api/memory` |
| **Terminal** | CLI | `engram recall "what was the last decision?"` |
---
## Quick start
### One-command install
For Claude Code, choose the [recommended plugin](docs/INTEGRATIONS.md#claude-code-plugin-recommended) OR `engram setup` for MCP and hooks, never both.
```bash
# Memory for your AI client — npx-based MCP config, no clone/build
npx -y @engram-ai-memory/cli setup --npx
# Optional: REST API + Atlas dashboard on :4901 (the wizard clones and builds the server)
npm i -g @engram-ai-memory/cli
engram setup
engram start
```
The first command is all an MCP client needs. With the server running, open http://localhost:4901 for the dashboard, `/docs` for Swagger UI.
### CLI commands
```bash
engram setup # Clone, build, install the CLI globally, wire up MCP
engram setup --npx # Fast setup — npx-based MCP config, no clone/build
engram setup --source cursor # Also picks WHICH client config file to write (see below)
engram init # Generate AI memory instructions (CLAUDE.md, .cursorrules, etc.)
engram init --client cursor # Generate instructions for a specific client
engram update # Pull, rebuild, re-link the CLI, restart the server
engram update --force # Update even with local repo changes (stashed, or kept on a backup branch)
engram update --no-restart # Update without restarting the server
engram start # Start the server (detached)
engram start --foreground # Run it in this terminal instead
engram stop # Stop the server — waits for it to actually exit
engram doctor # Health checks; exits 1 when it finds something
engram status # Server status + memory count
engram configure show # Print the current config
engram configure set