# shmem — persistent memory for AI agents > Single-binary memory system with multi-index retrieval. MCP-native. Works with Claude Code, Codex, Antigravity, OpenCode, Cursor, and any MCP client. 95% QA accuracy on LongMemEval. ## Setup, for agents With a shell, run: `curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh` It installs shmem and runs `shmem install`, which is idempotent: it wires every agent it detects, imports their past sessions, and picks an LLM to answer with. If you run `shmem install` yourself, pass `--yes` so it never stops to ask. Relay its output to the user. Don't ask for API keys in chat; if no LLM was found, the output says how to add one. Then verify: `shmem ask "what was I working on last week?"`, and relay the answer. Without a shell, give the user that command to run in a terminal. Full agent guide: https://shmem.secondmoment.ai/docs/latest/install/ ## Signing in, for agents Memory stays on the machine until the user signs in to a shmem account (it then syncs with their other machines and the Claude app). Offer sign-in only when the user asks for it or agrees to it. Use shmem's MCP `login` tool first: it opens the browser and waits up to 45 seconds, then returns the result lines, or a link to show the user before calling it again. Over SSH, ask the user for the code the sign-in page shows and call `login` with `code`. A question it returns (switching account) goes to the user; pass `switch_account` with their answer. For another server, the user runs `shmem login --remote ` themselves. Without the MCP tools, run `shmem login` in the background or with your longest timeout, relay the link, then relay the result lines. New machine ("set up shmem, I already use it on my laptop"): install, sign in as above, then verify with ask_memory and relay the answer. Details: https://shmem.secondmoment.ai/docs/latest/install/#signing-in-only-when-the-user-asks ## Docs Each page is short and covers one topic. Everything in one file: https://shmem.secondmoment.ai/docs/latest/llms-full.txt ### Get started - [Install and quickstart](https://shmem.secondmoment.ai/docs/latest/get-started/): Install with one command, what `shmem install` does, first question, updating, per-repo projects with `shmem init`. - [Things to try](https://shmem.secondmoment.ai/docs/latest/try-it/): Example workflows — picking up where you left off, remembering decisions, multi-agent continuity, debug history. - [LLM providers](https://shmem.secondmoment.ai/docs/latest/llm-providers/): How `shmem install` picks an LLM for answers, and per-provider configuration (Anthropic, OpenAI, Gemini, OpenRouter, Ollama). - [Agent install guide](https://shmem.secondmoment.ai/docs/latest/install/): What `shmem install` does, per-agent wiring, LLM detection, and troubleshooting — written for an agent installing on a user's behalf. ### Guides - [Projects](https://shmem.secondmoment.ai/docs/latest/projects/): The unified-memory model — one DB at `~/.shmem/db/`, project as a tag column, default queries span everything, explicit `--here` / `--project` / `--mine` flags to scope. - [Projects across repos](https://shmem.secondmoment.ai/docs/latest/cross-repo/): How captured memories are tagged with a project, and working across several repositories. - [Filtering captures](https://shmem.secondmoment.ai/docs/latest/shmemignore/): `.shmemignore` rules that redact, substitute or drop secrets and noise before anything is stored. - [Sharing](https://shmem.secondmoment.ai/docs/latest/sharing/): Sharing as memberships — projects are sets of facts, a share adds a membership row (one fact id everywhere, no copies), grants decide who reads, and share-rules.yml nominates/distills/auto-shares. Retraction leaves no residue. - [Sharing rules](https://shmem.secondmoment.ai/docs/latest/sharing-rules/): The rules file — where it lives, fields, resolution order, defaults, and how to verify a setup. ### Hosted and teams - [Hosted](https://shmem.secondmoment.ai/docs/latest/hosted/): A shmem account on our server: machines sign in with `shmem login` and stay in sync, with full history on new machines; isolated per user, shared per project. - [The Claude app](https://shmem.secondmoment.ai/docs/latest/claude-app/): The shmem connector for claude.ai, Claude Desktop and mobile, for one person or a whole organization; same account as `shmem login`, and turned off in Claude Code where local shmem is signed in. - [Signing in](https://shmem.secondmoment.ai/docs/latest/hosted-setup/): `shmem login` on a first machine, a new machine, over SSH, and to other servers; signing out; which clients reach the account and how. - [Team setup (self-hosted)](https://shmem.secondmoment.ai/docs/latest/team-setup/): Deploy the server, create API keys, configure each developer's client, query across the team. - [Embedding shmem](https://shmem.secondmoment.ai/docs/latest/embedded/): For apps with their own agents — provision a private shmem account per end user, mint short-lived per-user session keys, and run shmem as remote MCP or bundled local. ### Reference - [Reference overview](https://shmem.secondmoment.ai/docs/latest/reference/): Index of the reference pages. - [CLI](https://shmem.secondmoment.ai/docs/latest/cli/): Every `shmem` command and flag. - [shmem import](https://shmem.secondmoment.ai/docs/latest/cli-import/): Importing history from agent transcripts, ChatGPT exports, GitHub and files. - [shmem gateway serve](https://shmem.secondmoment.ai/docs/latest/cli-gateway/): Capturing traffic from an LLM gateway. - [shmem admin](https://shmem.secondmoment.ai/docs/latest/cli-admin/): Status, models, projects, groups, telemetry. - [MCP server](https://shmem.secondmoment.ai/docs/latest/mcp-server/): The `shmem-mcp` tools and their arguments. - [Transports](https://shmem.secondmoment.ai/docs/latest/transports/): stdio, SSE and streamable HTTP, with auth. - [Environment variables](https://shmem.secondmoment.ai/docs/latest/environment/): Everything `shmem` and `shmem-mcp` read. - [Compatibility](https://shmem.secondmoment.ai/docs/latest/compatibility/): Which surfaces are stable, experimental, or unstable by design. ### Under the hood - [How it Works](https://shmem.secondmoment.ai/docs/latest/how-it-works/): Architecture deep-dive — FactStore (SQLite), multi-index retrieval (keyword FTS5/BM25 + temporal + opt-in embeddings), and QA pipeline. - [Benchmarks](https://shmem.secondmoment.ai/docs/latest/benchmarks/): LongMemEval results across 14 models. Accuracy vs cost and latency frontiers. Methodology and per-category breakdowns.