Engram logo # Engram > **Persistent Memory Cortex for AI coding agents. Gives agents session continuity, change tracking, decision logging, and multi-agent coordination across sessions.** ![npm](https://img.shields.io/npm/v/engram-mcp-server?style=flat-square&logo=npm) ![Build](https://img.shields.io/github/actions/workflow/status/keggan-std/Engram/ci.yml?style=flat-square) ![Claude Compatible](https://img.shields.io/badge/Claude-Compatible-D97706?style=flat-square&logo=anthropic) ![Multi-Agent](https://img.shields.io/badge/Multi--Agent-Ready-22C55E?style=flat-square) ![VS Code Support](https://img.shields.io/badge/VS%20Code-Supported-007ACC?style=flat-square&logo=visualstudiocode) ![Visual Studio Support](https://img.shields.io/badge/Visual%20Studio-Supported-5C2D91?style=flat-square&logo=visualstudio) ![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)
--- > โญ **If Engram saves you tokens and context, give it a star โ€” it helps other developers find it.** --- ## ๐Ÿ“‹ Table of Contents - [Overview](#overview) - [Why Engram?](#why-engram) - [How Engram Works?](#how-engram-works) - [Installation](#installation) - [Features](#features) - [Dashboard](#dashboard) - [Architecture](#architecture) - [Tools Reference](#tools-reference) - [AI Agent Instructions](#ai-agent-instructions) - [Multi-Agent Workflows](#multi-agent-workflows) - [Contributing](#contributing) - [Security](#security) - [Author](#author) - [License](#license) --- ## Overview **Engram** is an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that gives AI coding agents persistent memory across sessions. Instead of re-reading files, re-discovering architecture, and re-learning conventions every time a session starts, the agent calls `engram_session(action:"start")` and instantly receives everything it needs. It operates seamlessly as a background brain for popular AI tools like **Claude Code**, **Claude Desktop**, **Cursor**, **Windsurf**, **Cline**, **Trae IDE**, **Antigravity IDE**, **Android Studio**, and **GitHub Copilot** (VS Code & Visual Studio). --- ## Why Engram? Every AI coding agent is **stateless by default**. Each new session starts from scratch: - The agent re-reads file structures and re-discovers architecture. - Architectural decisions made in previous sessions are forgotten. - Conventions agreed upon are lost. - Work-in-progress tasks have no continuity. - **Time, tokens, and patience are wasted on repeated discovery.** Engram solves this by providing a **persistent brain** using a native SQLite (WAL mode) database. An AI agent should only need to deeply review a file once. When you ask it to change something, it should already know where to go. ### How Engram Compares | Tool | Approach | Local / No cloud | MCP native | Multi-agent | Works today | |------|----------|:---:|:---:|:---:|:---:| | **Engram** | Structured SQLite memory | โœ… | โœ… | โœ… | โœ… | | mem0 | Cloud vector DB | โŒ | โš ๏ธ wrapper | โš ๏ธ | โœ… | | MemGPT / Letta | In-context manipulation | โœ… | โŒ | โŒ | โœ… | | Plain `CLAUDE.md` | Static text file | โœ… | โœ… | โŒ | โœ… | Engram is the only solution that is **local-first, MCP-native, multi-agent-ready, and structured** (queryable, rankable, exportable) โ€” not just a text file appended to every prompt. --- ## How Engram Works? Engram runs as a local MCP server alongside your AI tool. It maintains a **project-local SQLite database** at `.engram/memory.db` โ€” one per project, created automatically on first use. No cloud, no API keys, no data leaving your machine. ### The Session Lifecycle ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ AGENT SESSION LIFECYCLE โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Session โ”‚ engram_session(action:"start") โ”‚ โ”‚ Start โ”‚ โ† previous summary, open tasks, decisions, file notes, โ”‚ โ”‚ โ”‚ conventions, triggered events โ€” all ranked by focus โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Active Work โ”‚ get_file_notes โ†’ skip re-reading if notes are fresh โ”‚ โ”‚ โ”‚ record_change โ†’ every file edit captured with context โ”‚ โ”‚ โ”‚ record_decision โ†’ why you built it, persisted forever โ”‚ โ”‚ โ”‚ add_convention โ†’ project standards stored once, used โˆž โ”‚ โ”‚ โ”‚ create_task โ†’ work items survive session boundaries โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Context โ”‚ check_events fires at 50% / 70% / 85% fill โ”‚ โ”‚ Pressure โ”‚ โ†’ checkpoint to offload working memory mid-session โ”‚ โ”‚ โ”‚ โ†’ or end early and resume cleanly in the next session โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Session โ”‚ engram_session(action:"end", summary:"...") โ”‚ โ”‚ End โ”‚ โ†’ summary stored, open tasks preserved, memory locked โ”‚ โ”‚ โ”‚ โ†’ next session โ€” same agent or different โ€” starts fresh โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### What the Agent Receives at Start When an agent calls `engram_session(action:"start", focus:"topic")`, the response includes: | Field | What it contains | | -------------------------- | ------------------------------------------------------------------------- | | `previous_session.summary` | What was done last session โ€” files, functions, blockers | | `active_decisions` | Binding architectural decisions. Follow them or supersede with rationale. | | `active_conventions` | Project standards (naming, patterns, style) โ€” enforced every session | | `open_tasks` | Pending work items with priority and blocking chains | | `abandoned_work` | Work declared via `begin_work` that was never closed โ€” resume or discard | | `handoff_pending` | Structured handoff from the previous agent โ€” instructions, branch, tasks | | `triggered_events` | Scheduled reminders or deferred tasks now due | | `agent_rules` | Live-loaded behavioral rules from the README (7-day cache) | | `tool_catalog` | Available actions, scoped to the agent's familiarity tier | All context is **FTS5-ranked** around the `focus` topic โ€” the most relevant memory surfaces first. The `suggested_focus` field auto-derives the topic for the next session when none is provided. ### Token Efficiency by Mode | Mode | Schema tokens | Works with | | ----------------------------- | ------------- | ------------------ | | Standard 4-dispatcher | ~1,600 | All MCP agents | | `--mode=universal` (built-in) | ~80 | All MCP agents | | `engram-thin-client` | ~0 (deferred) | Anthropic API only | ### Storage All data lives in a local SQLite WAL database. There is no telemetry, no external sync, and no authentication surface. The database is a plain file โ€” portable via `backup`, exportable to JSON, restorable on any machine. --- ## Installation Engram is published to the npm registry. **You do not need to download or compile any code.** Your IDE launches it with `npx`. > **Always install with `@latest`.** Every command below says > `engram-mcp-server@latest`, and the `@latest` is not decoration โ€” see > [Upgrading](#upgrading) for the measurement that made it mandatory. Without > it, `npx` can silently run a version it cached months ago. ### Prerequisites - **Node.js v20 or newer.** This is a hard floor, not a recommendation: `better-sqlite3@12` declares `20.x || 22.x || 23.x || 24.x || 25.x` and `open@11` declares `>=20`. On Node 18 you get `EBADENGINE` followed by a native build failure in the dependency that *is* the database. Releases up to and including v1.13.0 wrongly advertised v18+. Engram stores data in **SQLite** via `better-sqlite3`, which ships a native C++ addon. Prebuilt binaries cover most platforms. If none matches yours, npm compiles from source, which needs: - **Windows:** [Node.js](https://nodejs.org) v20+ and Visual C++ Build Tools + Python โ€” install **"Desktop development with C++"** from the [Visual Studio Installer](https://visualstudio.microsoft.com/downloads/). - **Mac:** Xcode Command Line Tools (`xcode-select --install`) - **Linux:** `build-essential` and `python3` (`sudo apt install build-essential python3`) ### Option 1: The Magic Installer (Interactive) โ€” **use this one** Detects your IDE and injects the configuration safely. Install in **universal mode**, which is the recommended setup: ```bash npx -y engram-mcp-server@latest --install --universal ``` Universal mode exposes Engram as a **single `engram` tool with an ~80-token schema** instead of four dispatcher tools. Every action is still available โ€” you call `engram({action:"record_decision", ...})` instead of `engram_memory({action:"record_decision", ...})`, and a BM25 resolver forgives near-miss action names. Nothing is given up: the universal catalogs and the four-tool action enums were compared programmatically and match exactly, **39 of 39** memory actions and **37 of 37** admin actions reachable. > **One naming difference worth knowing.** `action:"search"` resolves to > *memory* search in universal mode, because the resolver checks the memory > dispatcher before the find dispatcher. To search the **tool catalog** โ€” what > `engram_find({action:"search"})` does in four-tool mode โ€” use its alias: > `engram({action:"discover", query:"..."})`. If you would rather have the four separate tools, see [Classic four-tool mode](#classic-mode) at the end of this section. **Non-interactive (CI/CD / scripting):** ```bash npx -y engram-mcp-server@latest install --ide vscode --universal --yes ``` **Clean removal:** ```bash npx -y engram-mcp-server@latest install --remove --ide claudecode ``` **Check what is installed against what npm has:** ```bash npx -y engram-mcp-server@latest --check ``` `--check` searches **this project first** โ€” climbing up to four parent directories, so it works from `src/` and not only from the repo root โ€” and then the machine. For each install it prints the config file, the version stamped in it, whether that version is behind npm, and **where that install's memory database is**. When something is out of date it offers to update it rather than making you retype a command per install. ```bash npx -y engram-mcp-server@latest --check --scope local # just this project and its parents npx -y engram-mcp-server@latest --check --scope global # just user-level IDE configs npx -y engram-mcp-server@latest --check --walk-up 0 # do not climb at all ``` **Installing without being listed.** Every install is recorded in `~/.engram/installs.json` so `--check` can find it again โ€” including installs into a custom directory, which no config scan could rediscover. `--isolated` skips that record: ```bash npx -y engram-mcp-server@latest install --ide cursor --local --isolated ``` The install still happens; it simply will not appear in `--check`. The installer prints the config path when you use it, because that path becomes the only record โ€” write it down. **Nothing is written before you have seen it.** An interactive project-local install shows the IDE, the mode, the config file, the database location and whether it will be findable, then offers *Install / change directory / toggle isolation / abort*. Answer with the arrow keys or the number keys. ### Upgrading **Re-run the installer with `@latest`:** ```bash npx -y engram-mcp-server@latest --install npx -y engram-mcp-server@latest --check # confirm ``` Engram does not upgrade itself. The entry the installer writes into your IDE config pins an exact version โ€” `engram-mcp-server@1.13.0`, not a floating tag โ€” so the version recorded in the config is the version that runs. Moving to a new release is a deliberate act: run the command above. > **Why `@latest` is mandatory, measured rather than assumed.** `npx` caches > per **exact spec string** and will reuse that cache instead of asking the > registry. On the author's machine the day after v1.13.0 was published: > > ``` > npx -y engram-mcp-server --version -> v1.12.0 (cached in April) > npx -y engram-mcp-server@latest --version -> v1.13.0 > ``` > > Both answer with the network disabled, so both are cache reads โ€” the bare > spec is not "stale until it refreshes", it is pinned to an old snapshot > indefinitely. A user who ran the old README's bare command would keep > installing the version they first cached, forever, while the installer > cheerfully reported success. > > Releases up to v1.13.0 also wrote that bare spec into the IDE config itself, > so the config could record `_engram_version: "1.13.0"` beside arguments that > launched 1.12.0. Re-running the installer with `@latest` repairs such an > entry. **If `--check` still reports an old version after upgrading**, you have a stale `npx` cache or a global install shadowing it. Clear both: ```bash npm cache clean --force npm install -g engram-mcp-server@latest # only if you use the global install ``` ### Option 2: Global Install (Windows Fallback) If `npx -y engram-mcp-server@latest --install` fails on Windows, install globally first, then run the installer from the global copy: ```bash npm install -g engram-mcp-server@latest engram install --ide ``` `@latest` matters here too: `npm install -g engram-mcp-server` on a machine that already has an older global copy is not guaranteed to move you forward, and `engram --version` will keep reporting the old number. To upgrade a global install later, re-run `npm install -g engram-mcp-server@latest`. Available `--ide` values: `vscode`, `cursor`, `windsurf`, `antigravity`, `claudecode`, `claudedesktop`, `visualstudio`, `cline`, `roocode`, `geminicli`, `firebasestudio`, `trae`, `jetbrains`, `androidstudio` > **Note:** During install you may see `npm warn deprecated prebuild-install@7.1.3`. This is a cosmetic warning from a transitive dependency used to download SQLite prebuilt binaries. It does not affect functionality and is safe to ignore. ### Option 3: Universal Mode written by hand (reference) This is what `--install --universal` in [Option 1](#installation) writes for you. Use it if you configure MCP servers by hand, or to check what the installer produced. Since v1.7.0 the main server itself exposes a **single `engram` tool** (~80 token schema) via the `--mode=universal` flag โ€” no separate proxy package needed. BM25 fuzzy routing and `discover` action built in. **VS Code Copilot** (`.vscode/mcp.json`): ```json { "servers": { "engram": { "type": "stdio", "command": "npx", "args": [ "-y", "engram-mcp-server", "--mode=universal", "--project-root", "${workspaceFolder}" ] } } } ``` **Cursor** (`~/.cursor/mcp.json`), **Claude Desktop**, **Windsurf** โ€” same pattern with `--mode=universal` added to `args`. Or set `ENGRAM_MODE=universal` as an environment variable instead of using the flag. ### Option 4: Universal Thin Client Package (Legacy โ€” v1.6.x) โ€” **UNPUBLISHED, does not install** > **This option does not work, and never has.** `engram-universal-client` and > `engram-thin-client` have **never been published to npm** โ€” both return > `E404 Not Found`. The configuration below is kept for reference only, because > the source still lives in `packages/`; any `npx` line naming either package > will fail. > > **Use Option 3 (`--mode=universal`) instead.** It is built into this package, > gives the same single-tool surface, and needs nothing extra installed. > See [`docs/foundations/10-public-surface.md`](docs/foundations/10-public-surface.md) ยง2.4. The original separate proxy package design, for maximum token efficiency. **Cursor** (`~/.cursor/mcp.json`): ```json { "mcpServers": { "engram": { "command": "npx", "args": [ "-y", "engram-universal-client", "--project-root", "/absolute/path/to/project" ] } } } ``` **VS Code Copilot** (`.vscode/mcp.json`): ```json { "servers": { "engram": { "type": "stdio", "command": "npx", "args": [ "-y", "engram-universal-client", "--project-root", "${workspaceFolder}" ] } } } ``` **Windsurf / Gemini CLI / any MCP agent** โ€” same pattern, replace `--project-root` with your project path. > The agent should call `engram({"action":"start"})` first. The response includes `tool_catalog` with all available actions. ### Engram Database Location Engram maintains a **SQLite database** โ€” one per project โ€” that stores all agent memory. | How you run Engram | Database path | |---|---| | Project-local MCP config (default) | `/.engram/memory.db` โ€” auto-detected via git root, `.engram` marker, `package.json` walk-up | | No project root found (non-project dir) | `~/.engram/global/memory.db` โ€” global fallback, logged as a warning | | `npm install -g engram-mcp-server` + global IDE config (no `--project-root`) | `~/.engram/global/memory.db` โ€” global memory shared across all projects | > **`--project-root` flag** โ€” The most reliable way to pin the database. IDEs that support workspace variables (VS Code, Cursor, Visual Studio, Trae) inject this automatically. For IDEs without workspace variable support (Windsurf, Antigravity, Gemini CLI, Claude Desktop), add `"--project-root=/absolute/path/to/your/project"` to the `args` array manually. > > `npm install -g engram-mcp-server` makes the `engram` command available globally. When Engram is configured in a **user-level** (global) IDE config without `--project-root`, it cannot detect a specific project and initializes its database at the global fallback `~/.engram/global/memory.db`. This is intentional โ€” a global config serves all projects simultaneously. --- ### Option 5: Manual Configuration If you prefer to configure manually, find your IDE below. Each entry shows the correct config file path and JSON format. > **Config key note:** VS Code, Visual Studio, and JetBrains use `"servers"` as the top-level key. All other IDEs (including Android Studio) use `"mcpServers"`.
VS Code (GitHub Copilot) **Local (recommended)** โ€” create `.vscode/mcp.json` in your project root: ```json { "servers": { "engram": { "type": "stdio", "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=${workspaceFolder}"] } } } ``` **Global** โ€” `%APPDATA%\Code\User\mcp.json` (Windows) / `~/Library/Application Support/Code/User/mcp.json` (Mac) / `~/.config/Code/User/mcp.json` (Linux): ```json { "servers": { "engram": { "type": "stdio", "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > `${workspaceFolder}` is expanded by VS Code at spawn time โ€” the database is always placed at the correct project root automatically.
Cursor **Local** โ€” `.cursor/mcp.json` in your project root: ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=${workspaceFolder}"] } } } ``` **Global** โ€” `~/.cursor/mcp.json`: ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > `${workspaceFolder}` is supported in Cursor's `args` field and is expanded at spawn time.
Windsurf **Global** โ€” `~/.codeium/windsurf/mcp_config.json` (Windsurf only supports a single global config): ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=/absolute/path/to/your/project"] } } } ``` > Windsurf does not expand workspace-folder variables in MCP args. Replace `/absolute/path/to/your/project` with the actual path, or omit `--project-root` to let Engram auto-detect it (requires the IDE to spawn the process from within a project directory).
Antigravity IDE (Gemini) **Global** โ€” `~/.gemini/config/mcp_config.json` **Project** โ€” `.agents/mcp_config.json` in your workspace: ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--mode=universal", "--project-root=/absolute/path/to/your/project"] } } } ``` > **Corrected in v1.14.0.** Releases up to and including v1.13.0 wrote this entry > to `~/.gemini/antigravity/mcp_config.json`, which Antigravity does not read โ€” > so the installer reported success and Engram never appeared. The paths above > are the ones [Antigravity's own MCP documentation](https://antigravity.google/docs/mcp) > gives. If you installed with an earlier version, run > `npx -y engram-mcp-server@latest install --remove --ide antigravity` to clear > the stale entry (the old path is still searched, for exactly this reason) and > then install again. > Antigravity does not expand workspace-folder variables in MCP args, so > `--project-root` must be a real absolute path. A project-local install writes > one for you.
Claude Code (CLI) **Via CLI (user-level, recommended):** ```bash # Windows claude mcp add-json --scope=user engram '{"type":"stdio","command":"cmd","args":["/c","npx","-y","engram-mcp-server"]}' # Mac / Linux claude mcp add-json --scope=user engram '{"type":"stdio","command":"npx","args":["-y","engram-mcp-server"]}' ``` **Project-level** โ€” `.mcp.json` in your project root: ```json { "mcpServers": { "engram": { "type": "stdio", "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` **User-level** โ€” `~/.claude.json`: ```json { "mcpServers": { "engram": { "type": "stdio", "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > Claude Code auto-detects the project root from the working directory when the server is spawned. Add `"--project-root=/path/to/project"` to `args` to pin it explicitly.
Claude Desktop Edit `claude_desktop_config.json`: - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json` - **Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json` - **Linux:** `~/.config/Claude/claude_desktop_config.json` ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=/absolute/path/to/your/project"] } } } ``` **Windows** (use `cmd` wrapper โ€” `npx` is a `.cmd` file on Windows): ```json { "mcpServers": { "engram": { "command": "cmd", "args": ["/c", "npx", "-y", "engram-mcp-server", "--project-root=C:\\path\\to\\your\\project"] } } } ``` > Claude Desktop is a global app with no concept of a current project. Always specify `--project-root` to direct Engram to the correct project database. Without it, Engram falls back to `~/.engram/global/memory.db`.
Visual Studio 2022 / 2026 **Local (recommended)** โ€” `.vs/mcp.json` or `.mcp.json` in your solution root: ```json { "servers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=${SolutionDir}"] } } } ``` **Global** โ€” `%USERPROFILE%\.mcp.json`: ```json { "servers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > Note: Visual Studio uses `"servers"` (not `"mcpServers"`) as the config key. `${SolutionDir}` is expanded by Visual Studio at spawn time.
Cline Open the Cline extension settings โ†’ MCP Servers, or edit the settings file directly: - **Windows:** `%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json` - **Mac:** `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` - **Linux:** `~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > Cline spawns the MCP server with the VS Code workspace as CWD, so Engram auto-detects the correct project root in most cases.
Roo Code **Global** โ€” open Roo Code settings โ†’ MCP Servers, or edit: - **Windows:** `%APPDATA%\Code\User\globalStorage\rooveterinaryinc.roo-cline\settings\mcp_settings.json` - **Mac:** `~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json` - **Linux:** `~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json` **Local (project-level)** โ€” `.roo/mcp.json` in your project root: ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > Roo Code is the fork of Cline under a separate VS Code extension (`rooveterinaryinc.roo-cline`). The settings filename is `mcp_settings.json` โ€” different from Cline's `cline_mcp_settings.json`.
Gemini CLI **Global** โ€” `~/.gemini/settings.json`: ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=/absolute/path/to/your/project"] } } } ``` **Local (project-level)** โ€” `.gemini/settings.json` in your project root: ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > Gemini CLI reads both `~/.gemini/settings.json` (global) and `.gemini/settings.json` (project-level). The project-level config is only read when Gemini CLI is invoked from within that directory. Gemini CLI expands `$VAR` and `${VAR}` OS environment variables only โ€” not workspace-folder placeholders.
Firebase Studio (Project IDX) **Local** โ€” `.idx/mcp.json` in your workspace root (Firebase Studio / Project IDX uses project-level config only): ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server"] } } } ``` > Create the file via **Explorer โ†’ `.idx` directory โ†’ New file โ†’ `mcp.json`**, or use the Command Palette: **Firebase Studio: Add MCP Server**. For Gemini CLI inside Firebase Studio, use `.gemini/settings.json` instead (see Gemini CLI above).
Trae IDE **Local** โ€” `.trae/mcp.json` in your project root: ```json { "mcpServers": { "engram": { "type": "stdio", "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=${workspaceFolder}"] } } } ``` > Trae IDE supports `${workspaceFolder}` in `args` and expands it at spawn time. Trae only supports project-level (local) MCP config โ€” no user-level global config path is documented.
JetBrains (GitHub Copilot Plugin) **Recommended:** configure via **Settings โ†’ Tools โ†’ AI Assistant โ†’ Model Context Protocol (MCP)**. **Manual file** โ€” `~/.config/github-copilot/intellij/mcp.json` (community-sourced path; not officially documented by JetBrains): ```json { "servers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=/absolute/path/to/your/project"] } } } ``` > Note: JetBrains uses `"servers"` (not `"mcpServers"`) as the config key โ€” same as VS Code. The file-based path above is best-effort; use the Settings UI for a guaranteed configuration.
Android Studio **Global** โ€” `%APPDATA%\Google\AndroidStudio\mcp.json` (Windows) or `~/Library/Application Support/Google/AndroidStudio/mcp.json` (Mac): The installer automatically discovers all installed Android Studio versions and writes to each one. ```json { "mcpServers": { "engram": { "command": "npx", "args": ["-y", "engram-mcp-server", "--project-root=/absolute/path/to/your/project"], "enabled": true } } } ``` > Android Studio requires `"enabled": true` in each MCP server entry. The config path is version-specific (e.g., `AndroidStudio2024.3`, `AndroidStudio2025.1`). The installer's `--check` flag shows the status of all discovered versions.
### Classic four-tool mode โ€” only if you want the explicit tool surface Everything above installs **universal mode**, and that is the recommendation. This section is here for people who want to explore the alternative. Drop `--universal` and the installer registers Engram as **four separate dispatcher tools** โ€” `engram_session`, `engram_memory`, `engram_admin`, `engram_find`: ```bash npx -y engram-mcp-server@latest --install npx -y engram-mcp-server@latest install --ide vscode --yes # non-interactive ``` **What the four-tool surface costs and buys:** | | Universal (`--universal`) | Classic (no flag) | |---|---|---| | Schema tokens, every request | ~80 | ~1,600 | | Actions reachable | 39 memory + 37 admin + 5 session | identical | | Call shape | `engram({action:"get_tasks"})` | `engram_memory({action:"get_tasks"})` | | `action:"search"` | memory search (use `discover` for the catalog) | unambiguous โ€” separate tools | | Agent picks the wrong tool | impossible โ€” there is one | possible | The ~1,600 figure is the schema cost paid on **every** request for the life of the session, not once. That is the whole reason universal mode leads this section. Choose classic if you specifically want each dispatcher's parameter documentation in front of the agent, or if you are debugging which dispatcher an action lands in. Switching later is just a re-install with or without the flag โ€” the database is untouched either way. ### Verifying Your Installation After installing, verify Engram is working by running: ```bash npx -y engram-mcp-server@latest --check ``` Or use the MCP Inspector for a full interactive test: ```bash npx @modelcontextprotocol/inspector npx -y engram-mcp-server@latest ``` In your IDE, open the AI chat and ask the agent to call `engram_session(action:"start")`. If it returns a session ID and tool catalog, Engram is running correctly. --- ## Features Engram gives an AI coding agent **persistent memory** โ€” the ability to pick up exactly where it left off, across sessions, IDEs, and teams. Here is what that means in practice. --- ### ๐Ÿง  Sessions That Actually Continue An AI agent without Engram starts cold every session โ€” re-reads files, rediscovers architecture, re-learns conventions. That warm-up wastes tokens and your patience, every single time. With Engram, `engram_session(action:"start")` delivers the full context in one call: the previous session's summary, open tasks, architectural decisions, project conventions, and a `suggested_focus` auto-derived from recent activity. The agent arrives already knowing your codebase. > The agent that worked on your project yesterday is effectively present today. --- ### ๐Ÿ—๏ธ Decisions That Outlive Sessions Every architectural choice gets stored with rationale, affected files, tags, and dependency chains. It lives in Engram indefinitely โ€” not in a chat history that scrolls away. Six months later, a new agent asks why something works a certain way. Engram answers precisely, with the original reasoning intact. `depends_on` chains warn when changing one decision risks cascading to others. Decisions are superseded, never deleted โ€” the full evolution of your architecture is always recoverable. --- ### ๐Ÿ“ Smart File Notes With Staleness Detection The agent learns a file once โ€” its purpose, layer, complexity, and dependencies โ€” writes a 2-3 sentence `executive_summary`, and never reads it from scratch again. Future sessions query the note for instant context with zero file reads. Notes use **SHA-256 content hashing** to catch silent edits from formatters and auto-saves that preserve `mtime`. A `branch_warning` fires when the current branch diverges from when the note was written, preventing cross-branch confusion. --- ### โœ… Tasks That Survive Everything Work items persist across sessions, restarts, agent switches, and context resets โ€” with priority, tags, and blocking chains. `claim_task` is **atomic**: two parallel agents can never start the same work. `begin_work` declarations surface as `abandoned_work` in the next session โ€” nothing falls through the cracks. --- ### ๐Ÿค– Parallel Agents Without Conflicts Run multiple AI agents on the same codebase simultaneously. Engram provides the coordination layer so they never step on each other. | Mechanism | What it prevents | | --------------------------------- | ---------------------------------------- | | `lock_file` / `unlock_file` | Two agents editing the same file at once | | `claim_task` (atomic) | Duplicate work from parallel agents | | `broadcast` / `agent_sync` | Missed messages between agents | | `route_task` | Work going to the wrong specialization | | `handoff` / `acknowledge_handoff` | Context loss when switching agents | --- ### ๐ŸŒก๏ธ Always Land Cleanly โ€” Context Wall Warnings AI agents hit their context limit and abruptly stop, mid-task and mid-thought. Engram fires `context_pressure` events at **50%, 70%, and 85%** fill โ€” giving the agent time to `checkpoint` its progress and wrap up gracefully before the wall hits. The next session resumes exactly where it left off. --- ### ๐Ÿ“ Convention Enforcement That Sticks Project conventions โ€” naming rules, testing standards, logging patterns, response shapes โ€” are stored once and returned at every session start. `engram_find(action:"lint")` actively checks any code against them. Conventions do not get forgotten when a session ends or a new agent joins. --- ### ๐Ÿ“ Unified Change History โ€” Agent and Human Every file change is recorded with `change_type`, `description`, `impact_scope`, and optional diff. Git hook integration captures commits from both agents and humans into one timeline. `what_changed` returns a full diff report from any point in time or since session start. --- ### โšก Minimal API Footprint โ€” 4 Tools or 1 All capabilities route through **4 dispatcher tools** via an `action` parameter. Add `--mode=universal` to collapse to a single `engram` tool at ~80 schema tokens โ€” a 99% reduction from the original 50-tool surface. BM25 fuzzy routing handles typos and near-miss action names automatically. | Mode | Schema tokens | Compatibility | | --------------------- | ------------- | ------------------ | | Standard 4-dispatcher | ~1,600 | All MCP agents | | `--mode=universal` | ~80 | All MCP agents | | `engram-thin-client` | ~0 deferred | Anthropic API only | --- ### ๏ฟฝ Built-in Project Management Framework Engram ships a two-tier project management framework that runs inside the agent โ€” no external PM tool needed. **PM-Lite (always on):** Passive workflow nudges delivered at session start โ€” reminders to record changes, check file notes before opening, log decisions, and end sessions cleanly. Zero configuration. Disable with `engram_admin({ action: "disable_pm_lite" })`. **PM-Full (opt-in):** A full 6-phase execution framework with phase-aware task tagging, automated phase gate checklists, a built-in knowledge base (principles, phase instructions, PERT estimation), and extended discipline nudges for scope control and risk management. Engram offers PM-Full automatically when it detects structured project patterns. Activate manually with `engram_admin({ action: "enable_pm" })`. PM errors are always isolated โ€” they never block core Engram operations. --- ### ๏ฟฝ๐Ÿ’พ Your Data, Your Machine No cloud. No telemetry. No authentication surface. Memory lives in a local SQLite WAL file at `.engram/memory.db`. `backup` creates a portable copy to any path. `export` serializes everything to JSON. You own it entirely. --- > For the full version history and per-release breakdown, see [RELEASE_NOTES.md](RELEASE_NOTES.md). --- ## Dashboard โ€” repository-only, not part of the npm package > **This is a development tool for people working on Engram itself, and it is > not finished.** It is documented here so the `packages/` directory is not a > mystery, not because it is a feature you are meant to use. > > **It does not ship to npm.** `package.json`'s `files` field is > `["dist/", "SECURITY.md", "THIRD-PARTY-NOTICES.md"]`; `packages/` is not in > it, and `npm pack` produces no dashboard files. If you installed Engram with > `npx` or `npm install -g`, **you do not have the dashboard and no command in > this section will work for you.** Running the server with `--mode=dashboard` > in that case serves an API-only stub page, because `http-server.ts` resolves > `../packages/engram-dashboard/dist` relative to `dist/` and that path does > not exist in an installed package. > > Until v1.13.0 this section claimed the opposite โ€” "Engram **ships with** a > built-in visual dashboard" and "the dashboard **is included in the > package**". Both were false for every user who did not clone the repository. > They are corrected rather than quietly deleted, and > `tests/public-surface/public-surface.test.ts` now fails the build if the > README claims the dashboard ships while `npm pack` disagrees. ### Running it from a clone ```bash git clone https://github.com/keggan-std/Engram.git cd Engram npm install npm run dashboard ``` `npm run dashboard` is a **repository script**. It builds the server, installs the dashboard's own frontend dependencies, and runs the API and the Vite dev server together. The terminal prints a URL with the auth token in the fragment: ``` [api] Engram HTTP server running on port 7432 [ui] VITE ready in 320ms โžœ Local: http://localhost:5173#token= ``` Open that URL as printed โ€” the token is required. It travels in the URL **fragment** (`#token=`), which browsers never transmit, so it does not reach an access log and is stripped from `Referer`. The page moves it into `sessionStorage` and clears the address bar, so a copied link is inert. ### What the token does and does not do - It stops **a web page you visit** from reading your memory. That is the real threat: any site you browse can issue requests to `localhost`, and without the token they would succeed. Requests are also refused unless addressed to `localhost` by name, which is what closes DNS rebinding. - It does **not** stop another process running as **you**. `.engram/token` is mode `0600`, which excludes other *users*, not other *processes under your own account* โ€” and file modes are a no-op on Windows. - There is **no encryption at rest or in transit**. The database and the token are plain files; dashboard traffic is plain HTTP over loopback. Do not expose ports `5173` or `7432` to a network. ### State of the implementation The pages below exist and render. The dashboard is nonetheless **not considered complete**, it is outside the `knip` dead-code gate (`knip.json` is scoped to `src/**`), its dependencies are not covered by this project's dependency auditing, and its correctness has never been reviewed. Treat anything it displays as informational. | Page | Shows | |------|-------| | **Dashboard** | Session, task, decision and change counts; per-database instance cards; recent change volume | | **Tasks** | Work items with status, priority, tags | | **Decisions** | Architectural decisions with rationale and affected files | | **Changes** | File-edit history recorded by agents and git hooks | | **Conventions** | Project standards | | **File Notes** | Per-file purpose, layer, complexity, summary | | **Sessions** | Past session summaries | | **Events** | Scheduled and triggered events | | **Milestones** | Named milestones | | **Audit** | Raw event log | | **Settings** | Runtime config keys | Live updates arrive over a WebSocket. HTTP requests authenticate with `Authorization: Bearer `; the WebSocket upgrade accepts the token via `Sec-WebSocket-Protocol` or, for older bundles, a `?token=` query parameter. Comparison is constant-time, and a foreign `Host` header is refused with `403`. ### Requirements Node.js **v20+** and, for the first run only, an internet connection so the dashboard's frontend dependencies can be installed. A working clone of this repository is required โ€” see the banner above. --- ## Architecture ```mermaid graph TB A1([Agent 1]) A2([Agent 2]) A3([Agent N]) MCP([MCP Protocol Server]) NPM([npm Registry / GitHub]) subgraph Core Services TS[Task Service] CS[Compaction Service] GS[Git Tracking Service] ES[Event Trigger Service] US[Update Service] CO[Coordination Service] end subgraph Data Layer DB[(SQLite WAL\nProject DB)] FTS[FTS5 Search Index] GDB[(Global KB\n~/.engram/global.db)] end A1 & A2 & A3 <-->|JSON-RPC| MCP MCP --> TS & CS & GS & ES & US & CO TS & CS & GS & ES & CO --> DB US -->|async, fire-and-forget| NPM US --> DB DB --> FTS MCP -->|export_global| GDB MCP -->|get_global_knowledge| GDB ``` --- ## Tools Reference Engram v1.7.0 exposes **4 dispatcher tools** (or 1 tool in `--mode=universal`). Every operation routes through one of them via an `action` parameter. Token overhead is ~1,600 tokens for the standard surface, or ~80 tokens in universal mode โ€” a ~95-99% reduction from the previous 50-tool surface. > **Use `engram_find`** when you don't know the exact `action` name. It returns parameter schemas and descriptions for any operation. ### `engram_session` โ€” Session Lifecycle | Action | Purpose | | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `start` | Begin a session. **`agent_name` is required.** Returns `session_id`, context, agent rules, tool catalog, handoff_pending, abandoned_work, suggested_focus. Pass `verbosity` to control response depth. | | `start` + `agent_role:"sub"` | **v1.7** Sub-agent mode. Pass `task_id` to receive focused context (~300-500t): task details, relevant files, matching decisions, and capped conventions only. Records `parent_session_id`. | | `end` | End session with a summary. Pass `session_id` (or `agent_name`) to say which session. Warns on unclosed claimed tasks. | | `get_history` | Retrieve past session summaries. | | `handoff` | Package open tasks, git branch, and instructions for the next agent. | | `acknowledge_handoff` | Clear a pending handoff from future start responses. | #### Session ownership under concurrency A session belongs to exactly one agent. Starting a session retires **only your own** previous session โ€” an orchestrator and the sub-agents it spawns stay open side by side, and no agent can close or overwrite another's record. Three rules follow from that: 1. **`agent_name` is required on `start`** and should be stable across sessions. It is the identity everything else is scoped by. 2. **`start` returns a `session_id`.** Pass it back as `session_id` on `end`, `handoff`, and `acknowledge_handoff` when other agents may be running. Passing your `agent_name` instead resolves to your own newest open session. With neither, the newest open session of any agent is used and the response says so in `session_resolution`. 3. **A sub-agent session records `parent_session_id`**, inferred from the most recent open session belonging to another agent, or set explicitly by passing `parent_session_id`. ```js // Orchestrator const { session_id } = engram_session({ action: "start", agent_name: "lead" }); // Sub-agent โ€” does not disturb the orchestrator's session engram_session({ action: "start", agent_name: "sub-1", agent_role: "sub", task_id: 42, parent_session_id: session_id }); // Each closes its own engram_session({ action: "end", session_id, summary: "..." }); ``` ### `engram_memory` โ€” All Memory Operations | Action | Purpose | | ------------------------ | ------------------------------------------------------------------------------------------------------------------- | | `get_file_notes` | Retrieve file notes with `confidence` (hash-based staleness), `branch_warning`, `lock_status`, `executive_summary`. | | `set_file_notes` | Store file intelligence (purpose, layer, complexity, dependencies, `executive_summary`, `content_hash`). | | `set_file_notes_batch` | Store notes for multiple files atomically. | | `record_change` | Log file changes with `change_type`, `description`, `impact_scope`, `diff_summary`. | | `get_file_history` | Change history for a file. | | `record_decision` | Log architectural decisions with `rationale`, `tags`, `affected_files`, `depends_on`, `supersedes`. | | `record_decisions_batch` | Record multiple decisions atomically. | | `get_decisions` | Retrieve decisions by status, tag, file, or dependency chain. | | `update_decision` | Change decision status. Returns `cascade_warning` if dependents exist. | | `add_convention` | Record a project convention. | | `get_conventions` | Retrieve active conventions. | | `create_task` | Create a persistent work item with priority, tags, and blocking chains. | | `update_task` | Update task status, priority, description, or blocking. | | `get_tasks` | Retrieve tasks by status, priority, or tag. | | `checkpoint` | Save current understanding + progress to a persistent checkpoint. | | `get_checkpoint` | Restore the last saved checkpoint. | | `search` | FTS5-ranked full-text search across all memory. Results include `confidence`. | | `what_changed` | Diff report of all changes since a given time or session. | | `get_dependency_map` | File dependency graph for a module. | | `record_milestone` | Log a project milestone. | | `schedule_event` | Schedule deferred work with a trigger type. | | `check_events` | Check triggered events including `context_pressure` at 50%/70%/85%. | | `agent_sync` | Heartbeat โ€” registers agent with optional `specializations[]`. Returns unread broadcasts. | | `claim_task` | Atomically claim a task. Returns advisory `match_score` vs agent specializations. | | `release_task` | Release a claimed task back to the pool. | | `get_agents` | List all registered agents with status, last-seen, and specializations. | | `route_task` | Find the best-matched agent for a task based on specialization scoring. | | `broadcast` | Send a message to all agents. | | `dump` | Auto-classify unstructured text into decisions, tasks, conventions, findings. | | `get_knowledge` | **v1.10** Query the PM knowledge base (PM-Full only). `knowledge_type`: `principles` \| `phase_info` \| `checklist` \| `estimation`. Pass `phase: N` for phase-specific content. | ### `engram_admin` โ€” Maintenance & Git Hooks | Action | Purpose | | --------------- | ---------------------------------------------------------- | | `backup` | Create a database backup. | | `restore` | Restore from a backup. | | `list_backups` | List available backup files. | | `export` | Export memory to JSON. **Not everything:** covers sessions, changes, decisions, file notes, conventions, tasks, milestones and scheduled events. Observations, handoffs, agent registrations and the audit log are **not** included โ€” use `backup` for a complete copy. | | `import` | Import from exported JSON. | | `compact` | Compress old session data. | | `clear` | Clear memory tables (destructive โ€” requires confirmation). | | `stats` | Project stats with per-agent contribution metrics. | | `health` | Database health check and diagnostics. | | `config` | Read or update runtime config values. | | `scan_project` | Scan and cache project filesystem structure. | | `install_hooks` | Write Engram post-commit git hook to `.git/hooks/`. | | `remove_hooks` | Remove Engram hook from `.git/hooks/post-commit`. | | `enable_pm` | Activate PM-Full mode (phase gates, checklists, knowledge). | | `disable_pm` | Deactivate PM-Full mode. | | `disable_pm_lite` | Disable PM-Lite workflow nudges. | | `decline_pm` | Permanently dismiss the PM-Full offer for this project. | | `reset_pm_offer` | Clear the PM-Full offer/declined flags. | | `pm_status` | Get PM health, active mode, advisor stats, and diagnostics. | ### Project Management Mode Engram includes a built-in Project Execution Framework with two levels: **PM-Lite (ON by default):** Provides smart workflow nudges โ€” reminders to record changes, check file notes, and log decisions. Zero configuration needed. Disable with `engram_admin({ action: "disable_pm_lite" })`. **PM-Full (opt-in):** Activates the full 6-phase project management framework with: - Phase-aware task tagging (`tags: ["phase:planning"]`) - Phase gate checklists (auto-triggered when all tasks for a phase complete) - Built-in knowledge base: principles, phase instructions, estimation guidance - Extended workflow nudges for phase discipline, scope control, and risk management Activate with `engram_admin({ action: "enable_pm" })`. Engram also offers PM-Full automatically when it detects structured project work (3+ tasks, phase tags, or PM keywords). **Knowledge Base (PM-Full only):** | Query | Returns | |-------|---------| | `engram_memory({ action: "get_knowledge", knowledge_type: "principles" })` | 5 core PM principles | | `engram_memory({ action: "get_knowledge", knowledge_type: "phase_info", phase: 3 })` | Phase 3 entry/exit criteria + instruction summaries | | `engram_memory({ action: "get_knowledge", knowledge_type: "checklist", phase: 3 })` | Phase Gate 3โ†’4 checklist | | `engram_memory({ action: "get_knowledge", knowledge_type: "estimation" })` | PERT formula and estimation guidance | **Diagnostics:** `engram_admin({ action: "pm_status" })` returns PM health, detected phase, advisor nudge state, and recent failures. PM errors are always isolated โ€” they never block core Engram operations. ### `engram_find` โ€” Discovery & Linting | Action | Purpose | | -------------------- | --------------------------------------------------------------------------------------- | | `search` _(default)_ | Search the tool catalog by keyword. Returns action name, description, and param schema. | | `lint` | Check a code/text snippet against all active conventions. Returns `violations[]`. | --- ## AI Agent Instructions > **Important:** AI agents have a strong tendency to skip Engram tool calls โ€” particularly `engram_session(action:"start")` at the beginning of a chat and `engram_memory(action:"get_file_notes")` before opening files โ€” and proceed directly to reading and reviewing. This defeats the purpose of the memory system entirely. **For any session that involves file exploration or codebase work, explicitly instruct the agent in your prompt to use Engram before acting.** A simple addition like *"Before doing anything, start an Engram session. Before opening any file, check its Engram notes first."* is sufficient to enforce compliance. > **Copy-paste ready.** The block below can be dropped directly into `CLAUDE.md`, `.github/copilot-instructions.md`, Cursor Rules, or any equivalent agent instruction file โ€” no reformatting needed. ### Session Start โ€” ALWAYS FIRST ```js engram_session({ action: "start", agent_name: "claude", verbosity: "summary", focus: "topic if known", project_root: "/absolute/path/to/project" }) ``` - `project_root` (optional): Pass the absolute path to the workspace when the IDE may not set cwd to the project directory (e.g. Antigravity, Windsurf, Claude Desktop). Engram will re-initialize its database at the correct location. Omit if the IDE already provides `${workspaceFolder}` (VS Code, Cursor). Act on everything returned: `active_decisions` (binding), `active_conventions` (enforce), `open_tasks`, `agent_rules` (binding), `pm_agent_rules` (binding when PM-Full active), `triggered_events`, `abandoned_work` (resume or discard). Unknown action? โ†’ `engram_find({ query: "what I want to do" })` ### Before Opening Any File ```js engram_memory({ action: "get_file_notes", file_path: "..." }) ``` `high` confidence โ†’ use notes, skip opening. `stale`/absent โ†’ read file, then immediately call `set_file_notes` with `executive_summary`. ### Before Architecture/Design Decisions ```js engram_memory({ action: "search", query: "...", scope: "decisions" }) ``` Follow existing decisions. Supersede with `record_decision({ ..., supersedes: })`. Always include `rationale`. ### After Every File Edit ```js engram_memory({ action: "record_change", changes: [{ file_path, change_type, description, impact_scope }] }) ``` `change_type`: `created|modified|refactored|deleted|renamed|moved|config_changed` `impact_scope`: `local|module|cross_module|global` โ€” batch all edits in one call. ### Documentation Rule Multi-step plans, analyses, proposals โ†’ write to `docs/.md`. Chat gets summary only. ### Session End โ€” ALWAYS LAST 1. Record unrecorded changes 2. Mark done tasks: `engram_memory({ action: "update_task", id: N, status: "done" })` 3. Create tasks for incomplete work 4. `engram_session({ action: "end", session_id: , summary: "files touched, pending work, blockers" })` ### Sub-Agent Sessions (v1.7+) ```js engram_session({ action: "start", agent_name: "sub-agent-X", agent_role: "sub", task_id: 42, parent_session_id: }) ``` Returns only the assigned task, its file notes, matching decisions, and up to 5 conventions (~300โ€“500 tokens). Sub-agents still call `record_change` and `session end` as normal. `agent_name` is required and must be unique per agent โ€” it is what stops concurrent agents from closing each other's sessions. Pass your own `session_id` on `end`. --- ## Multi-Agent Workflows When running multiple agents simultaneously on the same project, use the coordination tools to keep them in sync: ### Agent Registration & Heartbeat Each agent should call `agent_sync` periodically to stay visible and receive broadcasts: ```js // On startup and every ~2 minutes engram_memory({ action: "agent_sync", agent_id: "agent-frontend", agent_name: "Frontend Specialist", status: "working", current_task_id: 42, specializations: ["typescript", "react", "ui"], // โ† new in v1.6.0 }); // Returns: { agent, unread_broadcasts: [...] } ``` ### Atomic Task Claiming Use `claim_task` to safely grab a task without duplicating work. Returns advisory `match_score`: ```js engram_memory({ action: "claim_task", task_id: 42, agent_id: "agent-frontend", }); // Returns: { task, match_score: 85, match_warning? } ``` ### Find the Best Agent for a Task ```js engram_memory({ action: "route_task", task_id: 42 }); // Returns: { best_match: { agent_id, agent_name, match_score }, all_candidates: [...] } ``` ### Broadcasting Between Agents ```js engram_memory({ action: "broadcast", from_agent: "agent-backend", message: "โš ๏ธ auth.ts API changed โ€” agents touching auth endpoints need to update", expires_in_minutes: 60, }); ``` ### The `dump` Power Tool ```js engram_memory({ action: "dump", raw_text: ` We decided to use JWT with 15-minute expiry. TODO: add refresh token endpoint Always use bcrypt cost factor 12. `, agent_id: "agent-research", }); // Auto-classifies into decisions, tasks, conventions, findings ``` ### Coordination Quick Reference | Situation | Call | | -------------------------- | --------------------------------------------------------- | | Register / heartbeat | `engram_memory(action:"agent_sync")` | | Find best agent for task | `engram_memory(action:"route_task", task_id)` | | Claim a task atomically | `engram_memory(action:"claim_task", task_id, agent_id)` | | Release a task | `engram_memory(action:"release_task", task_id, agent_id)` | | List active agents | `engram_memory(action:"get_agents")` | | Send a team message | `engram_memory(action:"broadcast", message, from_agent)` | | Dump unstructured findings | `engram_memory(action:"dump", raw_text, agent_id)` | --- ```json [ { "priority": "CRITICAL", "rule": "Call engram_session(action:'start', verbosity:'summary') FIRST โ€” before reading any file or taking any action." }, { "priority": "CRITICAL", "rule": "Call engram_memory(action:'get_file_notes', file_path) before opening any file. Use notes to skip re-reading already-analysed files." }, { "priority": "CRITICAL", "rule": "Call engram_memory(action:'record_change') after every file edit โ€” changes, file_path, change_type, description, impact_scope." }, { "priority": "CRITICAL", "rule": "Call engram_session(action:'end', summary) before terminating โ€” be specific about what was done, what is pending, and any blockers." }, { "priority": "HIGH", "rule": "Call engram_memory(action:'record_decision') for every architectural or design choice โ€” even small ones." }, { "priority": "HIGH", "rule": "Check engram_memory(action:'get_decisions') before starting any implementation to avoid contradicting existing decisions." }, { "priority": "HIGH", "rule": "Use engram_find(query) when unsure which action to call โ€” never guess parameter names." }, { "priority": "MEDIUM", "rule": "Use engram_memory(action:'checkpoint') when approaching context limits โ€” save current_understanding and progress before losing context." }, { "priority": "MEDIUM", "rule": "Respect active_conventions returned by start_session โ€” enforce them in every file touched this session." }, { "priority": "MEDIUM", "rule": "Use verbosity:'nano' or 'minimal' for start_session when context is tight; use 'summary' (default) for normal sessions." }, { "priority": "MEDIUM", "rule": "When PM-Full mode is active: tag tasks with phase:N, check phase gate checklists before advancing phases, use get_knowledge for PM guidance.", "condition": "pm_full_enabled" } ] ``` --- ## Troubleshooting ### Windows: `'engram' is not recognized` when using `npx` If your Windows username contains special characters (tildes `~`, spaces, accented letters, etc.), `npx` may fail to resolve the binary: ``` 'engram' is not recognized as an internal or external command, operable program or batch file. ``` **Cause:** `npx` downloads packages to a temp directory under your user profile (e.g., `C:\Users\~ RG\AppData\Local\npm-cache\_npx\...`). Special characters โ€” especially tildes โ€” are misinterpreted as DOS 8.3 short-path prefixes, and spaces compound the issue. The generated `.cmd` shim fails to resolve its own path. **Fix โ€” use a global install instead of `npx`:** ```bash npm install -g engram-mcp-server@latest ``` Then update your MCP config to use the binary directly: ```jsonc // .vscode/mcp.json (or equivalent for your IDE) { "servers": { "engram": { "type": "stdio", "command": "engram-mcp-server", "args": [ "--mode=universal", "--project-root", "${workspaceFolder}", ], }, }, } ``` **Note:** With a global install, you won't get automatic version updates. After publishing a new version, update manually: ```bash npm install -g engram-mcp-server@latest ``` ### Database locked or corrupted If you see `SQLITE_BUSY` or corruption errors: 1. Stop all IDE instances using Engram 2. Delete the project-local database: `rm -rf .engram/` 3. Restart โ€” Engram will re-create the database and run all migrations automatically The global database at `~/.engram/memory.db` can be reset the same way if needed. --- ## Contributing Contributions are welcome โ€” bug reports, feature proposals, documentation improvements, and code. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for the full contribution guide, including: - Development environment setup - Branch naming and commit message conventions - Testing requirements before submitting a PR - How to propose new features or architectural changes - Code review process and expectations For questions and discussion, open a [GitHub Issue](https://github.com/keggan-std/Engram/issues). --- ## Security For responsible disclosure of security vulnerabilities, please read [SECURITY.md](SECURITY.md). **Do not open a public GitHub issue for security vulnerabilities.** The short version: Engram has no network-facing server, no authentication surface, and no telemetry. All data stays on your machine in a local SQLite file. The primary attack surface is the local filesystem and the `npx` execution model. --- ## Author Built by **Renald Shao** (aka **Keggan Student**) โ€” [GitHub](https://github.com/keggan-std) ยท [Behance](https://www.behance.net/renaldshao) --- ## License This project is licensed under the [MIT License](LICENSE). Copyright © 2026 Renald Shao (aka Keggan Student), Tanzania. ---
Because your AI agent shouldn't have amnesia.
Copyright © 2026 Renald Shao (aka Keggan Student) โ€” Tanzania