From zero to a working memory
Sign in, connect your coding agent, and learn how realms work, from creating one to merging two. Every CLI command is explained at the end.
1. Sign in
Install the CLI once, then sign in. Your browser opens, you confirm, and this machine gets its own API key.
npm install -g @memstackai/cli mem login # opens the browser; this machine gets its own key mem status # who you are, the realm in use, this month's usage
Prefer not to install? Put npx @memstackai/cli in place of mem. On a server without a browser, create a key in the console under Settings → API keys, then run mem login --key rc_… or set MEMSTACK_API_KEY.
2. Connect your coding agent
One command adds MemStack to your agent. At the start of each session the agent gets what MemStack knows about the project, relevant notes arrive with your prompts, and the conversation is saved as you work.
mem setup claude # or codex, gemini, cursor, copilot, opencode, qwen,
# factory, devin (Windsurf), kiro, cline, amp
mem setup --all # every agent found on this machine
mem doctor # check that everything is connected- Claude Code: also install the plugin for capture:
/plugin marketplace add infinimemory/infinimemory-plugins, then/plugin install mem@memstack. - Codex: approve the MemStack hooks once with
/hooks. - Something private?
mem pause 2stops capture on this machine for two hours, andmem pause offturns it back on. Find keeps working.
3. Realms
A realm is one separate memory: one per project, user or customer. Nothing saved in one realm can be found from another.
Create a realm
There is no create step: a realm is created the first time you save to it.
# the first save to team-handbook creates it mem save "We deploy on Tuesdays." --realm team-handbook mem realms # list realms with their notes and files
- Names use letters, digits,
_,:and-, up to 100 characters, and are case-sensitive. A typo makes a new, empty realm. - Use
:for hierarchy, such asacme:user:42. - Every account has a realm named
default, which can't be deleted.
Which realm a command uses
The CLI and every agent plugin follow the same order, so they share one realm per repository:
--realm <name>on the command.- A
.memstack.jsonin this folder or a parent, up to the repository root.mem connectwrites it. - The
MEMSTACK_REALMenvironment variable. - Otherwise, a realm of its own for this repository.
mem connect my-app # link this folder, and agents working in it, to "my-app" mem connect # show which realm this folder uses
To keep a folder out of capture, add "save": false to its .memstack.json. Find still works there.
Tell Sync what a realm is about
In the console, open Realms and click Context on a realm to describe it in up to 1,500 characters. Sync reads it when it decides whether a new note supersedes an older one.
4. Save, find and manage notes
Saving is instant and uses no AI: your text is split into pieces and embedded, and facts become notes by rules. Sync runs later, in the background, and decides whether each new note is new, supersedes an older one, or repeats one. The older note stays as history. Find never calls a model.
mem save "The team switched from npm to pnpm." mem save --file notes.md --wait # wait until it is findable mem save --url https://example.com/changelog cat meeting.txt | mem save mem find "which package manager?" mem find "where was the office?" --as-of 2025-06-01 mem timeline --from 2026-01-01 mem about # core and changing facts mem files # list files; mem files <id> shows one mem remove "old staging url" # shows the matches, then asks mem sync # run Sync now mem explore MEMSTACK.md # the realm as a Markdown file
5. Merge realms
Merge when two realms should really be one memory: you saved the same project under two names, or mem doctor reports an Old realm left over from an earlier CLI version.
- Open the console and go to Realms.
- Click Merge on the realm you want to fold in.
- Type the realm to merge into: an existing one, or a new name, which is created for you.
- Confirm. The move runs in the background, and the console tells you when it is done.
Every file, piece and note moves across, with its history and connections. If both realms use the same External ID, the moved file gets a _merge_ suffix. Then the old realm is removed, unless it is default or an API key or integration uses it; in that case it stays, empty.
A merge can't be undone. Only the organization's owner can merge, from the console. The CLI and API keys can't.
The console calls this API, which you can also call with an owner's console session:
DELETE /v1/realms/{realm}?moveTo={other} -> 202 {operationId, kept}
GET /v1/operations/{operationId} -> queued | running | done | failed6. CLI reference
Every command except login, doctor and pause needs you to be signed in.
| Command | What it does |
|---|---|
| Account | |
mem login | Sign in through the browser; this machine gets its own API key. --key rc_… signs in with an existing key instead (servers without a browser). |
mem logout | Sign out on this machine. The key keeps working until you revoke it in the console. |
mem status | Who you are, the realm in use, and this month's usage. |
| Realms | |
mem connect [realm] | Link this folder to a realm (saved in .memstack.json). With no name, show which realm this folder uses. |
mem realms | List your realms with their notes and files. |
| Notes and files | |
mem save <text> | Save text, or --file <path>, --url <url>, or text piped in. --wait waits until it is findable; --title names it. |
mem find <query> | Find notes and file pieces. --as-of <date> shows what was true then; a question about time also prints the computed answer. |
mem timeline | The realm's dated events, oldest first (--from, --to <date>). |
mem about | The realm's core facts and changing facts. |
mem remove <query> | Remove notes by meaning. Shows the matches first, then asks. |
mem files [id] | List files, or show one with its notes. mem files rm <id> deletes one. |
mem sync | Run Sync now: decide which notes supersede, build on or repeat others. |
mem explore [path] | File Explorer: list the realm as files, or print one, such as MEMSTACK.md. |
| Coding agents | |
mem setup <agent> | Connect an agent (MCP and capture hooks): claude, codex, gemini, cursor, copilot, opencode, qwen, factory, devin (Windsurf), kiro, cline, amp. --all sets up every agent found. |
mem doctor | Check the login, this folder's realm, each agent's hooks and its last capture. |
mem pause [hours|off] | Stop capture on this machine for a while (default 1 hour). Find still works. |
mem mcp | MemStack's MCP server over stdio, signed in as you. Agents start this; you don't need to. |
mem hook --host <h> <event> | An agent hook: start, prompt, turn_end, compact, end. Agents run this; you don't need to. |
Options
--realm <name> | Use this realm instead of the folder's. |
--limit <n> | How many results find and files return. |
--json | Machine-readable output, for scripts. |
--yes, -y | Skip the confirmation in remove and files rm. |
--help, -h | Print every command. |
--version, -v | Print the CLI version. |
Environment
MEMSTACK_API_KEYandMEMSTACK_BASE_URLoverride the saved login.MEMSTACK_REALMsets the realm when the folder has no.memstack.json.
Older names still work
add (save), search (find), profile (about), forget (remove), docs (files), ls and cat (explore), whoami and usage (status).