# 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. --- # Source: https://shmem.secondmoment.ai/docs/latest/benchmarks/ --- # Benchmarks ![LongMemEval efficient frontier: accuracy vs cost](../img/cost_frontier.png) ![LongMemEval efficient frontier: accuracy vs average latency](../img/efficient_frontier.png) ![LongMemEval efficient frontier: accuracy vs p90 latency](../img/efficient_frontier_p90.png) ## The task [LongMemEval](https://arxiv.org/abs/2410.10813) is a benchmark for evaluating long-term memory in conversational AI. It tests whether a system can answer questions about past conversations spanning thousands of facts across multiple sessions. The benchmark contains **500 questions** across six categories: | Category | Count | Tests | |----------|-------|-------| | Temporal reasoning | 133 | "When did we last discuss caching?" — requires reasoning about dates and ordering | | Multi-session | 133 | "What approaches have we tried for auth?" — spans multiple conversations | | Knowledge update | 78 | "What's our current rate limit?" — most recent info should override earlier | | Single-session (user) | 70 | "What did I say about the API design?" — retrieving specific user statements | | Single-session (assistant) | 56 | "What code did you suggest for parsing?" — retrieving agent responses | | Single-session (preference) | 30 | "What testing framework do I prefer?" — inferring preferences from patterns | Each question has a ground-truth answer. The system retrieves up to 50 facts, then a QA model generates an answer from them. An independent judge (Claude Sonnet 5) scores correctness. ## Setup **Retrieval**: shmem's multi-index retrieval (keyword + temporal + semantic) with `max_facts=50`. The memory database is built once per question set using a mock LLM, so retrieval is identical for every model — what varies is only the model reading the retrieved context. **QA model**: each model answers from the same retrieved facts, so the comparison isolates reasoning over context rather than retrieval quality. Prompts average **10,400 input tokens**; answers are short, typically under 300 characters. **Judge**: Claude Sonnet 5, with type-specific judging (preference questions accept superset answers; knowledge-update questions check for the most recent value). A shortcut that skips the judge now applies only when the answer equals the ground truth exactly. It used to apply whenever the ground truth appeared anywhere in the answer, which credited an answer for naming the right option while choosing the wrong one. On questions that offer a choice, the judge scores what the answer selects, not what it mentions. **Token budget**: every non-Anthropic model runs with a 16,384-token output budget. This matters more than it sounds. Models that reason before answering bill those reasoning tokens against the same budget as the answer, so too small a budget produces an empty answer rather than a wrong one — and an empty answer scores as wrong without ever looking like a failure. A handful of models still exhaust it (noted below). **Infrastructure**: Anthropic and OpenAI models via their own APIs, Gemini via the Gemini API, and every open-weight model via OpenRouter — one provider for that whole group, so a single rate card covers the cost axis. ## Results 500 questions per model, 50 max facts, Claude Sonnet 5 judge. Answers generated 2026-09-14; every answer re-scored with the current judge 2026-10-26. The re-score moved each model by at most 1.4 points, and two re-scores of the same answers disagreed on 1 question in 500. Six models were added 2026-11-09 and 10 with the same corpus, settings and judge: Claude Sonnet 5.5, Claude Haiku 5.5, GPT-6.1 Terra, GPT-5.6 Terra, GPT-6 Luna and GPT-5.6 Luna. The OpenAI models ran synchronously over all 500 questions, one model at a time at concurrency 6, as in the main run. Claude Sonnet 5.5 and Haiku 5.5 ran through the Batch API, with latency from the same 101-question sample as the other Anthropic models. Claude Haiku 4.5, re-run alongside them as a control, scored the same 90.2% it did in October. Three more were added 2026-11-18, again with the same corpus, settings and judge: Claude Fable 5.2, Gemini 4 Neon and Gemini 4 Carbon. The two Gemini models ran synchronously over all 500 questions at concurrency 8, side by side. Their first pass used an 8,192-token output budget by mistake; the 11 questions that came back empty were asked again at 16,384, which leaves every other answer as it would have been, since the budget only changes answers that reach it. Claude Fable 5.2 ran through the Batch API, with latency from the 101-question sample. Amazon Ergo 1.0 was added 2026-12-01, again with the same corpus, settings and judge. It ran through OpenRouter, synchronously over all 500 questions at concurrency 6, alongside its long-haystack run on the same machine. | Model | Accuracy | Avg latency | Input $/Mt | Provider | |-------|----------|-------------|------------|----------| | Claude Fable 5.2 | **98.4%** | 4.7s\* | $8.00 | Anthropic | | Claude Fable 5.1 | 96.8% | 6.3s\* | $10.00 | Anthropic | | Gemini 4 Neon | 96.4% | 19.5s | $3.00 | Google | | Claude Sonnet 5.5 | 95.8% | 2.7s\* | $2.00 | Anthropic | | Gemini 4 Carbon | 95.6% | 14.6s | $2.00 | Google | | Claude Fable 5 | 95.0% | 6.8s\* | $10.00 | Anthropic | | Claude Haiku 5.5 | 95.0% | 2.4s\* | $0.10 | Anthropic | | Claude Opus 5 | 94.8% | 5.2s\* | $5.00 | Anthropic | | GLM-5.3 Flash | 94.4% | 7.8s | $0.15 | Z.ai (OpenRouter) | | Amazon Ergo 1.0 | 94.4% | 6.9s | $1.00 | Amazon (OpenRouter) | | GPT-6 Astra | 94.0% | 3.3s | $10.00 | OpenAI | | Inkling Small | 94.0% | 4.8s | $0.45 | Thinking Machines (OpenRouter) | | GLM-5.3 | 94.0% | 6.9s | $1.40 | Z.ai (OpenRouter) | | GPT-5.6 Terra | 93.8% | 1.9s | $2.00 | OpenAI | | GPT-6 Luna | 93.8% | 2.5s | $0.10 | OpenAI | | Kimi K3 | 93.8% | 18.4s | $2.65 | Moonshot AI (OpenRouter) | | Claude Sonnet 4.6 | 93.6% | 4.8s\* | $3.00 | Anthropic | | Claude Opus 4.8 | 93.4% | 3.3s\* | $5.00 | Anthropic | | Claude Sonnet 5 | 93.4% | 3.5s\* | $2.00 | Anthropic | | Claude Opus 4.5 | 93.2% | 4.5s\* | $5.00 | Anthropic | | GPT-5.6 Luna | 93.2% | 1.9s | $0.20 | OpenAI | | GLM-5.2 | 93.2% | 9.1s | $0.68 | Z.ai (OpenRouter) | | Inkling | 93.0% | 9.4s | $1.00 | Thinking Machines (OpenRouter) | | DeepSeek V4.1 Flash | 92.8% | 14.6s | $0.15 | DeepSeek (OpenRouter) | | Gemma 4 31B | 92.4% | 5.1s | $0.09 | Google (OpenRouter) | | GPT-5.6 Sol | 92.2% | 3.9s | $4.00 | OpenAI | | Gemini 3.8 Flash | 92.0% | 3.8s | $0.75 | Google | | Qwen3.5 397B | 92.0% | 70.7s | $0.55 | Alibaba (OpenRouter) | | Qwen3.8 Max | 92.0% | 33.7s | $2.00 | Alibaba (OpenRouter) | | GPT-6.1 Terra | 91.8% | 2.1s | $1.00 | OpenAI | | DeepSeek V4 Pro | 91.6% | 15.2s | $0.66 | DeepSeek (OpenRouter) | | Gemini 3.1 Pro | 90.6% | 9.8s | $2.00 | Google | | Claude Haiku 4.5 | 90.2% | 2.6s\* | $1.00 | Anthropic | | Gemma 4 26B A4B | 88.2% | 7.0s | $0.09 | Google (OpenRouter) | \* latency sampled over 101 questions; see below. ### Cost frontier Input-token pricing, verified against each provider's own rate card on the day of the run. Input dominates: prompts average 10,400 tokens against answers of a few hundred, so ranking by input price ranks by what a run actually costs. The Pareto-optimal models — no other model is both cheaper *and* more accurate: - **Gemma 4 31B** (92.4%, $0.09/Mt) - **Claude Haiku 5.5** (95.0%, $0.10/Mt) - **Claude Sonnet 5.5** (95.8%, $2.00/Mt) - **Gemini 4 Neon** (96.4%, $3.00/Mt) - **Claude Fable 5.2** (98.4%, $8.00/Mt) **The interesting result is how little the top of this chart now costs.** Claude Haiku 5.5 answers 95.0% of the benchmark at **$0.10 per million input tokens**: level with Claude Fable 5 and 3.4 points behind Claude Fable 5.2, the most accurate model in the study, at one eightieth of its price. Spending 80× more buys about three more correct answers per hundred questions. Between them on the frontier sit Claude Sonnet 5.5 (95.8%, $2.00) and Gemini 4 Neon (96.4%, $3.00). GPT-6 Luna, also at $0.10, reaches 93.8%. That is a different shape again from the previous version of this page, where the best model under $1 was GLM-5.3 Flash at 94.4% for $0.15, and before that, when the cheap end topped out around 91-93%. The sub-$1 tier now reaches 95%, and the remaining premium buys the last three points. Claude Fable 5.2 is the first model in the study to clear 98%, and it costs less than Fable 5.1 ($8.00 against $10.00) while answering 1.6 points more. Three caveats worth stating plainly, because they cut against the headline: - **Gemini 3.8 Flash's $0.75 is promotional**, through the end of 2026. At its scheduled 2027 rate of $1.50 it moves off the value tier entirely at 92.0%. - **Gemini 4 Carbon's $2.00 is introductory**, through 2026-11-30. At $4.00 from December it sits further below the frontier than it already does (95.6%, below Claude Sonnet 5.5 at the same $2.00). - **Cheap and fast are not always the same axis.** Claude Haiku 5.5 happens to sit on both frontiers, at $0.10 and 2.4s, but GLM-5.3 Flash, the value leader before it, averages 7.8s per answer. If latency is the binding constraint rather than cost, read the latency chart, not this one. ### Latency frontier Anthropic models ran through the Batch API for the main sweep, which records no per-call timing. Their latency comes from a synchronous re-run over a 101-question stratified sample, at the same concurrency as every other model, and is marked with an asterisk in the table. Accuracy is always the full 500-question number. - **GPT-5.6 Terra** (93.8%, 1.9s) - **Claude Haiku 5.5** (95.0%, 2.4s) - **Claude Sonnet 5.5** (95.8%, 2.7s) - **Claude Fable 5.2** (98.4%, 4.7s) GPT-5.6 Terra is the fastest model in the study, at 1.9s for 93.8%. From there the frontier is short: Claude Haiku 5.5 adds 1.2pp for half a second, and Claude Sonnet 5.5 another 0.8pp at 2.7s. The top of the frontier is no longer slow: Claude Fable 5.2 reaches 98.4% at 4.7s, faster than Claude Fable 5.1 (6.3s) and Claude Opus 5 (5.2s), both of which it outscores. The tail matters more than the average for anything interactive. Qwen3.5 397B averages 70.7s per answer and its p90 is worse; Kimi K3 averages 18.4s. Gemini 4 Neon sits on the cost frontier at 96.4% but averages 19.5s, and Gemini 4 Carbon 14.6s. All are respectable on accuracy and hard to use behind a prompt someone is waiting on. ### By question type Averaged across all models, the hardest categories are **multi-session** (89.5% — evidence spread across several conversations) and **preference** (87.5% — inferring a preference never stated outright). The easiest are **single-session assistant** (98.8%) and **single-session user** (97.6%): finding one statement in one conversation is close to solved. Multi-session is where the spread between models is widest — from 77.4% to 97.7%. It is the category that most rewards a stronger model, and the one where retrieval and reasoning are hardest to separate: the facts that answer the question rarely share vocabulary with each other, so the model has to do the joining that keyword search cannot. | Model | Temporal | Multi-session | Knowledge update | SS-User | SS-Asst | Preference | |-------|------|------|------|------|------|------| | Claude Fable 5.2 | 98.5% | 97.7% | 100.0% | 100.0% | 100.0% | 90.0% | | Claude Fable 5.1 | 97.0% | 94.0% | 98.7% | 100.0% | 100.0% | 90.0% | | Gemini 4 Neon | 97.0% | 94.0% | 100.0% | 98.6% | 98.2% | 86.7% | | Claude Sonnet 5.5 | 97.7% | 95.5% | 97.4% | 97.1% | 100.0% | 73.3% | | Gemini 4 Carbon | 98.5% | 91.7% | 100.0% | 97.1% | 98.2% | 80.0% | | Claude Fable 5 | 93.2% | 92.5% | 97.4% | 98.6% | 100.0% | 90.0% | | Claude Haiku 5.5 | 94.0% | 89.5% | 98.7% | 97.1% | 100.0% | 100.0% | | Claude Opus 5 | 93.2% | 93.2% | 94.9% | 98.6% | 98.2% | 93.3% | | GLM-5.3 Flash | 94.0% | 91.7% | 97.4% | 97.1% | 98.2% | 86.7% | | Amazon Ergo 1.0 | 94.7% | 91.7% | 94.9% | 100.0% | 98.2% | 83.3% | | GPT-6 Astra | 95.5% | 91.7% | 89.7% | 98.6% | 98.2% | 90.0% | | Inkling Small | 97.0% | 90.2% | 92.3% | 98.6% | 100.0% | 80.0% | | GLM-5.3 | 94.7% | 89.5% | 93.6% | 95.7% | 100.0% | 96.7% | | GPT-5.6 Terra | 94.7% | 90.2% | 92.3% | 98.6% | 100.0% | 86.7% | | GPT-6 Luna | 95.5% | 86.5% | 93.6% | 98.6% | 98.2% | 100.0% | | Kimi K3 | 93.2% | 90.2% | 94.9% | 100.0% | 100.0% | 83.3% | | Claude Sonnet 4.6 | 97.0% | 89.5% | 91.0% | 95.7% | 100.0% | 86.7% | | Claude Opus 4.8 | 94.7% | 88.7% | 91.0% | 97.1% | 100.0% | 93.3% | | Claude Sonnet 5 | 94.7% | 90.2% | 91.0% | 95.7% | 98.2% | 93.3% | | Claude Opus 4.5 | 94.7% | 85.7% | 93.6% | 100.0% | 98.2% | 93.3% | | GPT-5.6 Luna | 96.2% | 91.0% | 91.0% | 100.0% | 96.4% | 73.3% | | GLM-5.2 | 93.2% | 88.7% | 93.6% | 97.1% | 98.2% | 93.3% | | Inkling | 94.7% | 88.7% | 88.5% | 100.0% | 100.0% | 86.7% | | DeepSeek V4.1 Flash | 94.7% | 88.7% | 89.7% | 97.1% | 100.0% | 86.7% | | Gemma 4 31B | 93.2% | 86.5% | 93.6% | 98.6% | 96.4% | 90.0% | | GPT-5.6 Sol | 92.5% | 91.0% | 91.0% | 92.9% | 96.4% | 90.0% | | Gemini 3.8 Flash | 95.5% | 87.2% | 89.7% | 95.7% | 98.2% | 83.3% | | Qwen3.5 397B | 91.7% | 90.2% | 92.3% | 92.9% | 98.2% | 86.7% | | Qwen3.8 Max | 91.7% | 87.2% | 91.0% | 95.7% | 100.0% | 93.3% | | GPT-6.1 Terra | 92.5% | 83.5% | 96.2% | 98.6% | 98.2% | 86.7% | | DeepSeek V4 Pro | 90.2% | 88.0% | 88.5% | 98.6% | 100.0% | 90.0% | | Gemini 3.1 Pro | 94.0% | 85.7% | 91.0% | 94.3% | 98.2% | 73.3% | | Claude Haiku 4.5 | 90.2% | 85.7% | 88.5% | 98.6% | 96.4% | 83.3% | | Gemma 4 26B A4B | 94.0% | 77.4% | 85.9% | 97.1% | 98.2% | 76.7% | ### Known limitations - **A few models still exhaust the output budget.** At 16,384 tokens, Qwen3.5 397B returns an empty answer on 1.4% of questions (7 of 500) and DeepSeek V4.1 Flash on 1.0% (5 of 500), after 30-240 seconds of reasoning. Gemini 4 Carbon does it 3 times, and GLM-5.3, DeepSeek V4 Pro and Gemini 4 Neon once or twice each. Those count as wrong, so those models are understated by roughly that much, and the budget is held uniform across models rather than tuned per model, because a per-model budget would make the column mean different things in different rows. - **Latency for Anthropic models is sampled**, not measured over the full 500 (see above). - **One benchmark, one retrieval configuration.** LongMemEval at 50 facts measures reading comprehension over retrieved context. It does not measure retrieval on a corpus where the right facts are hard to find — see LoCoMo below, where they are. ## Long haystack (LongMemEval-S) The leaderboard above uses the oracle corpus, which hands every model only the sessions that hold the answer, so it measures the reader alone. This section measures retrieval too. On `longmemeval_s_cleaned`, each question comes with about 48 sessions and 490 turns of history, and the evidence is buried among distractors. shmem has to find it before any model can read it. ![Long haystack: accuracy vs cost](../img/lme_s_cost_frontier.png) ![Long haystack: accuracy vs average latency](../img/lme_s_efficient_frontier.png) 500 questions per model, run 2026-11-19; Amazon Ergo 1.0 was added 2026-12-01 under the same settings. Retrieval sends a budget of facts per question type, from 15 for single-session-user questions to 110 for multi-session ones, ranked by fusing keyword and POTION embedding ranks. The answer prompt and the Claude Sonnet 5 judge are the same as above. The question type is the benchmark's own label for each question: it picks the budget and, as in the leaderboard above, the answer prompt and the judge's rubric. In the product shmem's question classifier assigns the type, with a coarser default budget table (25 facts for knowledge-update, 85 for temporal, 120 otherwise), so these scores assume the type is known. Claude Opus 5 was re-run as a control against the previous best on this corpus, a 2026-10 run under an earlier prompt and retrieval setup: it scored 94.8% against 94.2% then, a difference within noise. | Model | Accuracy | Avg latency | Input $/Mt | |-------|----------|-------------|------------| | Claude Fable 5.2 | **97.4%** | 3.2s\* | $8.00 | | Claude Sonnet 5.5 | 94.8% | 3.4s\* | $2.00 | | Claude Opus 5 | 94.8% | 6.5s\* | $5.00 | | Gemini 4 Neon | 94.6% | 14.1s | $3.00 | | Gemini 4 Carbon | 93.6% | 15.3s | $2.00 | | Amazon Ergo 1.0 | 93.4% | 8.6s | $1.00 | | GPT-6.2 Sol | 92.2% | 2.2s | $2.00 | | GPT-6.2 Astra | 92.2% | 3.3s | $8.00 | | Claude Haiku 5.5 | 91.6% | 2.6s\* | $0.10 | | GPT-6 Luna | 89.6% | 2.9s | $0.10 | | GPT-6.1 Terra | 88.8% | 2.4s | $1.00 | \* latency sampled over the same 101 questions as above, synchronously; the full runs went through the Batch API. Cost frontier: - **Claude Haiku 5.5** (91.6%, $0.10/Mt) - **Amazon Ergo 1.0** (93.4%, $1.00/Mt) - **Claude Sonnet 5.5** (94.8%, $2.00/Mt) - **Claude Fable 5.2** (97.4%, $8.00/Mt) Latency frontier: - **GPT-6.2 Sol** (92.2%, 2.2s) - **Claude Fable 5.2** (97.4%, 3.2s) **Claude Fable 5.2 leads at 97.4%**, ahead of Gemini 4 Neon (94.6%) by a margin that holds up on a paired test of the same questions, and it answers in 3.2s. Claude Sonnet 5.5, Claude Opus 5 and Gemini 4 Neon form a second tier within a few questions of each other, but Neon takes 14 seconds per answer. **The cheaper models lose the most when the haystack is real.** Claude Haiku 5.5 drops from 95.0% on the oracle corpus to 91.6% here, GPT-6 Luna from 93.8% to 89.6%, and GPT-6.1 Terra from 91.8% to 88.8%. Claude Sonnet 5.5 and Claude Fable 5.2 each lose about a point. With fifty to a hundred retrieved facts and distractors among them, the reader has to do more of the work, and the stronger models do it better. If your memory store is large, read this table rather than the one above. Amazon Ergo 1.0 also loses about a point, from 94.4% to 93.4%, and at $1.00 it joins the cost frontier between Claude Haiku 5.5 and Claude Sonnet 5.5. A few answers came back empty and count as wrong: 3 for Claude Fable 5.2, 3 for Gemini 4 Neon, 4 for Gemini 4 Carbon and 1 for Amazon Ergo 1.0. --- ## LoCoMo [LoCoMo](https://arxiv.org/abs/2402.11753) is a second benchmark for conversational memory, with 1,540 questions across 10 multi-session conversations (5,882 facts total). It tests four categories: open-domain, temporal, single-hop, and multi-hop retrieval. LoCoMo is a harder retrieval challenge than LongMemEval because evidence is scattered across sessions and often uses different vocabulary than the question. At 50 retrieved facts, keyword search misses critical evidence — 93% of evidence turns share no keywords with the question. Sending all facts (400–700 per conversation) bypasses this retrieval bottleneck. **These LoCoMo numbers are from an earlier run and were not re-measured for this refresh** — they are reported here for the retrieval finding, not for model comparison. ### Results | Config | Overall | open_domain | temporal | single_hop | multi_hop | |--------|---------|-------------|----------|------------|-----------| | shmem + Opus (all facts) | **84.1%** | 90.2% | 87.2% | 71.6% | 56.2% | | shmem + Sonnet (all facts) | 79.8% | 87.7% | 79.5% | 69.4% | 44.9% | | shmem + Opus (50 facts) | 71.8% | 80.0% | 78.5% | 47.2% | 50.0% | | shmem + Sonnet (50 facts) | 68.3% | 76.2% | 74.8% | 45.0% | 45.8% | | Letta | 74.0% | — | — | — | — | | Mem0 | 68.5% | — | — | — | — | | Zep | 63.8% | — | — | — | — | With all facts, shmem beats Letta by 10pp (84.1% vs 74.0%) and Mem0 by 16pp. The biggest gain is single_hop (+24pp), where the retrieval fix surfaces evidence that keyword search missed. ### Key findings - **Date context matters**: Using conversation-era dates instead of today's date improved temporal accuracy by 9pp - **Retrieval is the bottleneck**: 98% of LoCoMo's "single_hop" questions require evidence from 2+ sessions, and keyword IDF can't find evidence that uses different vocabulary than the question - **All-facts mode works for small conversations**: For conversations under 1,000 facts (~25K tokens), sending everything outperforms selective retrieval - **Multi-hop remains hardest**: Even with all facts and Opus, multi-hop is 56.2% — these require cross-topic reasoning that's genuinely difficult --- # Source: https://shmem.secondmoment.ai/docs/latest/claude-app/ --- # The Claude app The Claude app (claude.ai on the web, Claude Desktop, and Claude on mobile) reaches your shmem memory through a **connector**. It signs in to the same shmem account your machines sign in to with `shmem login`, so it answers from the same memory, and what it saves reaches your machines. The rule of thumb: a computer with shmem installed signs in with `shmem login`, and its agents use local shmem. Surfaces with no local install (the Claude app, Cowork) use the connector, whose sign-in is the login. Same account, same memory, no tokens to copy anywhere. ## Add the connector (one person) 1. In the Claude app, open **Settings → Connectors → Add custom connector**. 2. Name it `shmem`, and enter the URL: ``` https://shmem.secondmoment.ai/mcp ``` 3. Click **Connect**, sign in **with the same email you use for `shmem login`**, and allow access. Then ask Claude something you've worked on, such as *"what did I decide about the billing retries?"*, and it answers from your shmem account. Hosted shmem is invite-only for now; if you can't sign in, [request access](../signup/). A self-hosted server works the same way with its own URL (`https:///mcp`). ## Add it for your whole organization On a Claude Team or Enterprise plan, an Owner adds the connector once, for everyone: 1. An Owner opens **Admin settings → Connectors** and adds a custom connector with the URL `https://shmem.secondmoment.ai/mcp`. **Keep "shmem" in the connector's name** (`shmem`, or something like `Acme shmem`): that's how shmem recognizes it on members' machines (see [below](#on-a-computer-with-shmem-installed)). 2. Each member finds it under **Settings → Connectors**, clicks **Connect**, and signs in with their own email. Every member reaches their own account; nobody sees anyone else's memory through the connector. ## Where the app's memory comes from The Claude app has no capture hooks, so shmem doesn't see your conversations there. What it remembers from the app is what Claude saves through the connector: the server's instructions ask Claude to save the durable facts of a conversation (decisions, findings, preferences) at natural milestones, and you can always say *"remember this"*. Transcripts are not captured. Most of your memory comes from your coding agents, which a local install captures in full. An account that's new to the app and has nothing from a computer yet says so: ``` This shmem account has no memory yet. Memory comes from your coding agents: install shmem on your computer (https://shmem.secondmoment.ai/install) and sign in with this same email. ``` Memory the app saves belongs to no project, so it's **account-wide**: on your machines, it shows up in every project's answers (`shmem ask`, `shmem query`, and the MCP tools), not only under `--project default`. Choosing a project from the app isn't supported yet. ## On a computer with shmem installed Claude Code can see claude.ai connectors too, so a computer with both local shmem and the connector would offer two sets of shmem tools for the same account, and split writes across two paths. shmem avoids that on its own: - **Signed in here: the connector is turned off in Claude Code.** When this machine is signed in with `shmem login`, shmem adds a permissions deny rule for the connector's tools (`mcp__claude_ai_shmem__*`, or the name your connector has) to `~/.claude/settings.json`. Claude Code then hides those tools, and every other connector keeps working. Local shmem already syncs with the account, so nothing is lost. `shmem login` and `shmem install` add the rule for a connector they find, the capture hook checks for a newly added connector at most once a day, and `shmem logout` removes the rule. `shmem status` shows it: ``` Account: you@example.com on shmem.secondmoment.ai synced 2 min ago claude.ai shmem connector off here (this machine covers it) ``` - **Not signed in here: the connector stays on, and shmem asks you to sign in.** The connector is then the only way this machine's agents reach your account, and memory saved on this machine isn't reaching it. `shmem install` offers to sign in right away, `shmem status` reads `Account: not signed in · you have an account (Claude app)`, and commands and agent answers end with a one-line reminder until you run `shmem login`. Signing in is usually one click, since your browser already holds the session from connecting the app. Nothing saved before then is lost: that first sign-in asks which of this machine's projects sync. The server's instructions say the same to the model: the local server names itself the one to use, and the connector defers to a local shmem server when one is connected. ## Claude Code without a local install On a machine where you won't install shmem, Claude Code can reach the hosted server directly over OAuth: ```bash claude mcp add --transport http shmem https://shmem.secondmoment.ai/mcp ``` Claude Code opens the sign-in the first time it uses the server. This works, but it isn't the recommended path: without a local install there is no automatic capture, so memory comes only from what the model saves. With shmem installed, use `shmem login` instead. --- # Source: https://shmem.secondmoment.ai/docs/latest/cli-admin/ --- # shmem admin Administrative commands. **Hosted vs local routing.** When a default remote is configured in `~/.shmem/remotes.json`, every `shmem admin group …` and `shmem admin project …` command transparently routes to the server's authoritative state via the matching MCP tool (`create_group`, `share_project`, etc.) — the local `~/.shmem/groups.json` and `~/.shmem/projects/` are not touched. Without a configured remote, the same commands run against local files as before. This is the only correct behavior for a multi-machine team: pre-routing, `shmem admin group create` on a hosted client silently updated only the local file, and the server never saw the group. ## shmem admin status `shmem status` gives the short version in plain words, and `shmem status -v` the full view below: ``` Setup: OK · capturing from Claude Code, Codex Memory: 24,779 memories · since Mar 3 QA LLM: anthropic (claude-haiku-5-5) Account: you@example.com on shmem.secondmoment.ai synced 2 min ago ``` ``` Project: my-project Path: /Users/you/.shmem/projects/my-project Facts: 247 Sources: llm=98, user=142, tool=7 Last: 2026-02-28 14:30 (5h ago) Used: asked or searched in 3 of the last 4 weeks QA LLM: anthropic/claude-haiku-5-5 (OK — provider serves this model) Config: /Users/you/.shmem/.env Setup: OK — capturing from Claude Code, Codex ``` The QA line verifies the configured model against the provider's live catalog — not just that an API key is present. Presence in the catalog alone isn't enough either: OpenAI keeps retired models in `/v1/models` with a past `shutdown_date` even though invoking them 404s, so the check requires the model to be listed *and* not past its retirement date. A model the provider has retired breaks reads while leaving writes working, so the summary line reflects it: ``` QA LLM: openai/gpt-5.3-chat-latest (MODEL NOT AVAILABLE — openai does not serve "gpt-5.3-chat-latest"; reads will fail) openai rejected model "gpt-5.3-chat-latest": no such model — it does not exist, has been retired, or this API key has no access to it fix: SHMEM_QA_MODEL is set to a model openai does not serve — edit SHMEM_QA_MODEL in ~/.shmem/.env, or unset it to use shmem's default (gpt-5.6-terra) openai currently serves: gpt-5.6-luna, gpt-5.6-sol, gpt-5.6-terra see the full live list: `shmem admin models openai` Setup: DEGRADED — writes work, reads will fail (QA model unavailable) ``` A model that still works but has a published retirement date is reported without failing the setup, so there's time to act on it: ``` QA LLM: openai/gpt-4.1-nano (OK for now — openai retires this model on 2026-10-23 (59 days); pick a replacement before then) Setup: OK — capturing from Claude Code (hooks and MCP server) ``` | Flag | Description | |------|-------------| | `--no-probe` | Skip the live model verification (no network calls) | | `--json` | Machine-readable probe; adds `qa_model` and `qa_model_status` (`ok` / `expiring` / `dead` / `unverified` / `skipped`) | ## shmem admin models Lists the models a provider serves right now, marking the one shmem is configured to use. Run this when a model string needs replacing — the provider's own catalog is the authority, so there's nothing to guess at. ``` $ shmem admin models openai openai lists 124 models: gpt-5.6-sol gpt-5.6-terra <- shmem is configured to use this gpt-5.6-luna gpt-4.1-nano <- retires 2026-10-23 gpt-5.3-chat-latest <- RETIRED 2026-08-10 — not invokable ... ``` Retirement state is part of the listing, not a footnote: OpenAI keeps retired models in its catalog, so an unannotated list would show a dead model as if it were a valid choice. When the configured model is retired or scheduled for retirement, that's called out explicitly at the end. With no argument it uses the configured QA provider. `--json` emits the list (with `shutdown_date` and `retired` per entry) for scripting. Bedrock is not listable here — its catalog needs separate AWS permissions. ## shmem admin project | Subcommand | Description | |------------|-------------| | `list` | List all projects with fact counts. Signed in, it compares this machine with your account: each project's memories here and on the account, and which are on this machine only, local-only, or only on your other machines | | `create ` | Create a new project (optional `-d` description) | | `info ` | Show project path, fact count, and sharing info | | `delete ` | Delete a project and its facts; each fact is deleted as `shmem delete` would, so shared facts are retracted first (requires confirmation or `-y`) | | `share ` | Share a project with a group (`-g group -p r\|rw`) | | `unshare ` | Remove group access from a project; its readers drop their copies on their next sync | | `shared` | List projects shared with you via your groups | | `unsync ` | Take a project off your account and keep it on this machine only (requires typing the name, or `-y`) | | `sync ` | Sync a local-only project: upload its memory here to your account, and sync it from now on. Projects you didn't pick at your first sign-in are local-only too | **Unsyncing a project** makes its memory local to this machine again. On your account, memories only in the project are deleted, and your other machines drop their copies on their next sync. Memories also in another project stay on the account in that one and just leave this one. This machine keeps all of it, marked local-only: - it stays searchable here; - new memory saved in the project doesn't sync; - `shmem push --all` leaves it out unless you name it with `--project`. A shared project is unshared first, once you confirm; its members lose access. `default` names memory in no project. The mark is this machine's alone: another machine that later saves memory in the project still syncs that. `shmem admin project sync ` undoes it. ## shmem admin group Manage groups for project sharing. Groups use `owner/name` namespacing (e.g. `alice/team-a`); a group you own can be named without the owner. Requires `SHMEM_CALLER_USER` to be set. | Subcommand | Description | |------------|-------------| | `create ` | Create a new group (created as `/name`) | | `delete <[owner/]name>` | Delete a group you own | | `invite <[owner/]name> ` | Invite a user | | `accept ` | Accept a pending invitation | | `list` | List groups you own, belong to, and pending invitations | | `members <[owner/]name>` | Show members of a group | ## shmem admin migrate-owner-identity Repoint `owner_user` at your account identity on facts written before that account was known. Rewrites `owner_user` only — authorship (`caller_user`, including its device suffix) is left untouched. Only **locally-authored** facts are eligible. Facts replicated into your store from other accounts (swept or pulled from shared projects) keep their real owner and are reported as skipped. | Flag | Description | Default | |------|-------------|---------| | `--to NAME` | Account identity to set as owner | Discovered via `whoami` | | `--from NAME` | Only rewrite facts with this owner | Every owner that isn't `--to` | | `--execute` | Actually rewrite (otherwise dry-run) | `false` | ```bash shmem admin migrate-owner-identity # dry-run, target from the server shmem admin migrate-owner-identity --to alice --execute ``` ## shmem admin telemetry Turn anonymous usage reporting on or off. It is **off by default**. See [Telemetry](../environment/#telemetry) for what is sent once it is on. | Subcommand | Description | |------------|-------------| | *(none)* | Show the current state of both usage reporting and the update check | | `on` | Turn usage reporting on (writes `on` to `~/.shmem/telemetry`) | | `off` | Turn it off, and silence the daily update check with it | You can also set `SHMEM_TELEMETRY=on` or `SHMEM_TELEMETRY=off` in your environment. --- # Source: https://shmem.secondmoment.ai/docs/latest/cli-gateway/ --- # shmem gateway serve Receives OTLP access logs from an agent gateway and stores them as memories, capturing agent traffic centrally instead of installing a hook on every machine. ```bash shmem gateway serve # listen on 127.0.0.1:4318 shmem gateway serve --addr 0.0.0.0:4318 --token "$T" # accept remote exporters shmem gateway serve --project acme-api # force a project tag ``` | Flag | Description | Default | |------|-------------|---------| | `--addr` | Address to listen on | `127.0.0.1:4318` | | `--path` | OTLP logs path | `/v1/logs` | | `--token` | Required bearer token (else `$SHMEM_INGEST_TOKEN`); unauthenticated if unset | — | | `-p, --project` | Force a project tag on every ingested fact | — | | `--include-system` | Store system-role prompt messages too | off | | `--verbose` | Log every stored fact | off | The gateway accepts OTLP/HTTP protobuf only (`Content-Type: application/x-protobuf`, which OTLP exporters send) and refuses requests from a browser (any request with an `Origin` header), so a web page can't write into your memory through it. A project tag carried in a record's attributes is used only when it is a plain project name. Without `--token`, any program on this machine can still post to it; set a token when other users share the machine. `GET /healthz` returns running counts of records, facts, duplicates and skips. Point agentgateway at it — no OpenTelemetry Collector is needed, though one still works if you already fan out to other backends: ```yaml frontendPolicies: accessLog: otlp: host: shmem-ingest.internal:4318 protocol: http path: /v1/logs add: shmem_identity: 'coalesce(apiKey.user, apiKey.user_id, apiKey.owner, apiKey.name, jwt.sub, jwt.email, basicAuth.username, "")' shmem_team: 'coalesce(apiKey.group, apiKey.team, jwt.groups[0], "")' shmem_project: 'coalesce(request.headers["x-shmem-project"], apiKey.project, jwt.project, "")' shmem_client: 'coalesce(request.headers["x-title"], request.headers["user-agent"], "")' shmem_tool: 'mcp.tool.name' shmem_tool_args: 'mcp.tool.arguments' shmem_tool_res: 'mcp.tool.result' shmem_prompt: 'llm.prompt' # content tier — opt in per route shmem_completion: 'llm.completion' ``` The identity expression coalesces deliberately rather than reading `apiKey.user` alone. Deployments differ in where they put identity, and agentgateway's own default chain misses some of them — Solo's reference Helm chart, for instance, issues one key per team carrying `metadata.user_id`, which is not in that chain. `coalesce` and `default` are built-in CEL functions, so unset fields fall through instead of erroring. On Kubernetes the same fields go in an `AgentgatewayPolicy`, which takes a list rather than a map: ```yaml spec: frontend: accessLog: attributes: add: - name: shmem_identity expression: coalesce(apiKey.user, jwt.sub, jwt.email, "") ``` ### Tagging traffic with a project A gateway knows who is calling, never which codebase — so the project tag has to come from the client, which does know. Every major agent runtime can attach a custom header when pointed at a gateway, and `request.headers["x-shmem-project"]` above picks it up. Claude Code reads `ANTHROPIC_CUSTOM_HEADERS`, and honors it from a project settings file — so the tag lives in the repo it describes, restoring the directory-to-project mapping that hooks get from `cwd`: ```json // .claude/settings.json, committed alongside the code { "env": { "ANTHROPIC_BASE_URL": "https://llm-gateway.example.com", "ANTHROPIC_CUSTOM_HEADERS": "X-Shmem-Project: acme-api" } } ``` opencode takes the same idea in its provider config: ```jsonc { "provider": { "gateway": { "options": { "baseURL": "https://llm-gateway.example.com/v1" }, "headers": { "X-Shmem-Project": "acme-api" } } } } ``` Clients routed through OpenRouter already send `HTTP-Referer` and `X-Title` app-attribution headers; `shmem_client` above captures the latter, which identifies the tool (`opencode`, `Continue`) rather than the project. Note that agentgateway reaches OpenRouter as an OpenAI-compatible backend, so `llm.provider` reports `openAI` — read `gw.endpoint` to tell them apart. Facts arrive untagged when no header is set, which is the intended behaviour: an untagged fact is honest, a guessed one is misfiled. Notes: - **Identity is the gateway's.** `shmem_identity` becomes the fact's caller and owner, `shmem_team` its group, and every other attribute is kept under a `gw.*` metadata key. Attach the auth policy to *every* route you want attributed — including the LLM route, which is easy to miss and is the one carrying the conversations. - **Projects are asserted, never inferred.** A gateway knows who is calling and where in the network, never which codebase. If a fact should carry a project, put it in API-key or JWT metadata and map it to `shmem_project`; otherwise facts are stored untagged. - **Re-sent turns collapse.** Every agent call re-sends the whole conversation, so messages are keyed on content and stored once, dated when first seen. - **shmem ignores its own MCP tools**, so memory reads and writes made through the same gateway are not re-recorded as facts. - Content only arrives if your CEL bundle exports it. The default tier captures models, tokens and tool names but no conversation text. --- # Source: https://shmem.secondmoment.ai/docs/latest/cli-import/ --- # shmem import Import conversation history or local files into shmem from these sources: | `--from` | What it imports | |----------|-----------------| | `claude-code` | JSONL transcripts from `~/.claude/projects/` | | `cursor` | Cursor IDE chat history from `~/Library/Application Support/Cursor/User/` | | `codex-cli` | OpenAI Codex CLI rollouts from `~/.codex/sessions/` (or `$CODEX_HOME`) | | `cline` | Cline VS Code extension + Cline CLI conversation history | | `chatgpt` | One-shot import from a ChatGPT export `.zip` (auto-detected under `~/Downloads/`) | | `github` | The auth'd user's PRs, issues, and review comments via the `gh` CLI | | `files` | One fact per paragraph from `.md` / `.txt` (or anything via `--include`) files and directories. Pipe-friendly — accepts paths via positional args or stdin. | | `snapshot` | A project's memory exported as NDJSON, one fact per line, keeping each fact's original date and metadata. Reads a file, or `-` for stdin. | | `agentgateway` | LLM conversations from an [agentgateway](https://agentgateway.dev) request-log database (`--db`) | Common flags: | Flag | Description | Default | Applies to | |------|-------------|---------|------------| | `-p, --project` | Target shmem project (creates if missing) | Current project (via `.shmem/project` walk-up), then `default` | all | | `--dry-run` | Show what would be imported without writing | — | all | | `--since YYYY-MM-DD` | Only import items after this date | — | `claude-code`, `cursor`, `codex-cli`, `cline`, `chatgpt`, `github`, `agentgateway` | ## `--from agentgateway` Backfills conversations an [agentgateway](https://agentgateway.dev) proxy has already recorded, so a team that runs one has memory on day zero instead of after a month of capture. ```bash shmem import --from agentgateway --db ./agw-logs.db --dry-run # preview shmem import --from agentgateway --db ./agw-logs.db --since 2026-08-10 shmem import --from agentgateway --db ./agw-logs.db --include-system ``` | Flag | Description | |------|-------------| | `--db` | Path to the agentgateway request-log SQLite file (required) | | `--limit` | Stop after this many rows (0 = all) | | `--include-system` | Also import system-role prompts, which repeat on every call | Requires the gateway to be persisting requests, with content capture on: ```yaml config: database: { url: /var/lib/agentgateway/logs.db } logging: database: { url: /var/lib/agentgateway/logs.db } frontendPolicies: accessLog: database: llm: full # without this, rows carry metadata but no conversation ``` Two limits worth knowing before you plan around this: - **Conversations only.** agentgateway writes this table for LLM (`ai` backend) traffic. MCP tool calls never reach it, so historical tool activity is not recoverable — only `shmem gateway serve` sees those, live. - **Postgres is not supported yet.** agentgateway treats a `postgres://` URL as Postgres and anything else as SQLite; shmem reads the SQLite form. Identity comes from the gateway's `agentgateway_user` and `agentgateway_group` columns, which are populated only when an auth policy (`apiKey`, `jwtAuth`, `basicAuth`) is attached to the route carrying the traffic. A route with no auth policy yields anonymous facts. ## `--from claude-code` ```bash shmem import --from claude-code # one shmem project per Claude project dir (default) shmem import --from claude-code --project mywork # all Claude history into one shmem project shmem import --from claude-code --dry-run # preview shmem import --from claude-code --since 2026-01-01 # only sessions after this date shmem import --from claude-code --claude-project "-Users-me-repos-myrepo" # filter ``` | Flag | Description | Default | |------|-------------|---------| | `--claude-project` | Filter to a specific Claude project directory name | — | Without `--project`, each Claude project directory becomes its own shmem project. With `--project`, all sessions land in one project. Parse-and-insert — no LLM calls, so it's fast. ## `--from cursor` ```bash shmem import --from cursor # one shmem project per Cursor workspace (default) shmem import --from cursor --project mywork # all Cursor history into one shmem project shmem import --from cursor --since 2026-01-01 # only sessions after this date shmem import --from cursor --dry-run # preview ``` Reads Cursor's local chat database under `~/Library/Application Support/Cursor/User/`. Without `--project`, each workspace folder becomes its own shmem project (named from the workspace path). With `--project`, all sessions land in one project. ## `--from codex-cli` ```bash shmem import --from codex-cli # all rollouts, routed per-cwd into shmem projects (default) shmem import --from codex-cli --project mywork # all rollouts into one shmem project shmem import --from codex-cli --since 2026-04-21 # only sessions after this date shmem import --from codex-cli --dry-run # preview ``` Walks `~/.codex/sessions/` (or `$CODEX_HOME/sessions/`) for rollout JSONL files. Without `--project`, each session is routed into a shmem project derived from the session's recorded `cwd`. With `--project`, all sessions land in one project. ## `--from chatgpt` ```bash shmem import --from chatgpt # auto-detect chat-data*.zip in ~/Downloads/ shmem import --from chatgpt ~/Downloads/chat-data.zip # explicit path shmem import --from chatgpt ~/Downloads/chat-data.zip --project mywork shmem import --from chatgpt --since 2026-01-01 shmem import --from chatgpt --dry-run ``` One-shot import (not realtime) of a ChatGPT export archive. Get the archive at [chat.openai.com/settings → Data Controls → Export](https://chat.openai.com/settings) — OpenAI emails you a download link to a `.zip` containing `conversations.json`. The importer reads that file and emits one fact per user / assistant text turn on the main thread of each conversation (forks abandoned via the in-app edit button are skipped via `current_node` walk). | What's imported | What's skipped (counted, not failed) | |---|---| | Text turns from `user` and `assistant` authors | `system` / `tool` author turns | | `content_type=text` content | `multimodal_text` (images), code interpreter output, `tether_quote`, etc. | Without `--project`, facts land in the current project (via the `.shmem/project` walk-up, then `default`); there's no per-conversation routing because ChatGPT exports carry no cwd / workspace hint. With `--project`, every fact gets that tag. Auto-detection scans `~/Downloads/` for `chat-data*.zip` (older OpenAI naming) and `data-*-batch-*.zip` (current naming, mid-2026); ambiguous matches fail with a list so you can pick one explicitly. ## `--from github` ```bash shmem import --from github # everything you authored, into the current project shmem import --from github --per-repo # one shmem project per GitHub repo shmem import --from github --org acme # restrict to a single org shmem import --from github --repo acme/api --repo acme/web # restrict to specific repos (repeatable) shmem import --from github --since 2026-01-01 # only items after this date shmem import --from github --dry-run # preview ``` | Flag | Description | Default | |------|-------------|---------| | `--per-repo` | Route each GitHub repo into its own shmem project, named `owner-repo` | `false` (everything into the current project) | | `--org` | Restrict to all repos in a single organization | — | | `--repo OWNER/REPO` | Restrict to specific repos (repeatable) | — | Pulls your own GitHub writing via the [`gh` CLI](https://cli.github.com/) — you must have `gh` installed and authenticated (`gh auth login`). If `gh` is missing or logged out, the import prints a note and exits without importing anything. **What it imports.** The search is scoped to `--author=@me`, so the corpus is the PRs and issues *you opened*, plus the bodies of your own comments and reviews on them. Two consequences worth knowing before you rely on it: - **Review work on other people's PRs is not imported.** A PR someone else opened, where you left a detailed review, never enters the corpus — the search never surfaces it. - **Only your side of a thread is kept.** Replies from other people are filtered out, so an issue you filed imports your question but not the maintainer's answer. Facts carry no diffs, patch content, or commit messages — titles and prose only. Each is tagged `imported_from=github` with the repo, item number, and URL in metadata, and timestamped with the item's GitHub creation time. Re-running is safe: imports dedupe on content, so unchanged items are skipped. Note that `--since` filters on when an item was *created*, not when you last touched it — a long-running issue opened before the cutoff is excluded even if you commented on it yesterday. ## `--from files` ```bash shmem import --from files ~/notes ~/docs # walk dirs into the current project shmem import --from files --project notes ~/notes # into a named project find ~/notes -name '*.md' | xargs shmem import --from files -p notes find ~/notes -name '*.md' | shmem import --from files -p notes # or via stdin (no positionals) shmem import --from files --include .md,.org ~/notes # custom extensions ``` | Flag | Description | Default | |------|-------------|---------| | `--include` | Comma-separated extensions for directory walks. Explicitly-named files are always ingested regardless. | `.md,.txt` | One fact per paragraph (paragraphs separated by blank lines). Paragraphs shorter than 10 characters are skipped. Each fact carries `source_file=` metadata. Timestamps come from each file's mtime so re-importing the same file dedupes correctly. If no positional args are given, `shmem import --from files` reads newline-separated paths from stdin until EOF — designed for `find ... | xargs ...` and `find ... | shmem import ...` workflows. Symlinks: a link inside a folder you import is followed only when its target is inside that folder too, so a linked notes vault imports whole while a link out to, say, `~/.aws/credentials` does not. A symlinked file passed directly (including from `find`) is skipped and listed; pass its target to import it. A symlinked folder passed directly is imported from its target. ## `--from snapshot` ```bash shmem import --from snapshot shmem-history.ndjson --project shmem-history # into a project of its own shmem import --from snapshot --dry-run shmem-history.ndjson # count, write nothing cat history.ndjson | shmem import --from snapshot -p history - # from stdin ``` A snapshot is a project's memory as a file, such as one downloaded from a public history page: NDJSON, one fact per line. Each line is a JSON object: | Field | Required | Meaning | |-------|----------|---------| | `content` | yes | The fact's text | | `timestamp` | no | RFC 3339 time or `YYYY-MM-DD`. Facts keep their own dates, so the history keeps its shape; a missing or unreadable time becomes now | | `source` | no | `user`, `llm`, or `tool` (default `tool`) | | `id` | no | The fact's id in the snapshot, kept as `snapshot_id` metadata | | `metadata` | no | Key/value pairs; string values are kept, others dropped. Keys that record the exporting store's own state (`via`, `replica`, `author_stamp`, and copies of the identity fields below) are dropped too | Rows saved from the `list_facts_since` MCP tool load as they are. Their ownership and placement fields (`owner_user`, `caller_user`, `caller_agent`, `project`, `dedup_key`) are ignored: you own what you import (facts are stamped with your `SHMEM_CALLER_USER`, like other imports), and it lands in `--project`, or your current project if you don't pass one. Pass `--project` to keep a memory you load apart from your own. Records whose `metadata.kind` is `share-event` are sharing bookkeeping and are skipped, as are lines that aren't a JSON object with `content`. Each fact gets `imported_from=snapshot` and an `import_key` derived from the record, and loading the same snapshot twice imports nothing new. --- # Source: https://shmem.secondmoment.ai/docs/latest/cli/ --- # CLI All commands below are invoked as `shmem ` unless noted. Run any command with `-h` for inline help. ## shmem install Set up shmem on this machine in one non-interactive step: create the memory store, wire every detected agent (Claude Code, Codex, Antigravity, OpenCode), import their past sessions (Claude Code, Codex, Cursor, Cline, OpenCode), and find an LLM to answer with. Never prompts; safe to re-run. The [install script](../get-started/#install) runs it for you. ```bash shmem install ``` | Flag | What it does | |------|--------------| | `--for ` | Wire only this agent: `claude-code`, `codex-cli`, `antigravity`, or `opencode`. Cursor, Cowork, nanoclaw and OpenClaw need manual wiring; the error links to the steps. | | `--provider ` | Skip LLM detection and use this provider (`anthropic`, `openai`, `gemini`, `openrouter`, `ollama`, `claude-cli`, `codex-cli`, `mock`). | | `--no-import` | Skip importing past sessions. | LLM detection order: an existing `SHMEM_QA_PROVIDER`; an API key in the environment (Anthropic, OpenAI, Gemini, OpenRouter); Claude Code's Bedrock or Vertex settings (`CLAUDE_CODE_USE_BEDROCK` / `CLAUDE_CODE_USE_VERTEX`); a signed-in Claude Code or Codex CLI, used headlessly (`claude-cli` / `codex-cli`); and only when none of those exists and no hosted remote is configured, a running Ollama with a model pulled, with a warning that local answers are slower and weaker. The choice is written to `~/.shmem/.env`. With none, install prints how to add one and exits 0 — capture works without an LLM. Agent-CLI providers inherit the parent command's network restrictions. When `CODEX_SANDBOX_NETWORK_DISABLED=1`, install warns that they may not answer in that Codex command sandbox. Calls still run, because Codex also sets the marker for allowlisted sandboxes that do reach the network, and a failure that looks like a cut-off network gets this explanation. Run `shmem ask` from a regular terminal outside the session, or configure an API provider in an environment with network access; adding a key does not bypass the sandbox. Merely running inside an agent session does not imply that networking is disabled. Agent config locations honor `CLAUDE_CONFIG_DIR` (Claude Code), `CODEX_HOME` (Codex), and `XDG_CONFIG_HOME` (OpenCode); the data root honors `SHMEM_ROOT`. ## shmem init Make the current directory a project: writes `.shmem/project`, so memories captured anywhere under it are tagged with that project and `shmem ask --here` scopes to it. Not needed to get started — `shmem install` already captures every session. ```bash cd your-project shmem init # project named after the directory shmem init my-app # or name it ``` It changes nothing else in the repo; hooks, the memory note and the MCP server are per-user, from `shmem install`, which `init` runs first on a machine where shmem isn't set up. Commit `.shmem/project` so teammates' sessions in the repo share the project. ## shmem login / shmem logout Sign this machine in to your shmem account, so its memory syncs with the account and every other machine signed in to it. ```bash shmem login # the server this machine syncs with, else SHMEM_LOGIN_SERVER, else hosted shmem login --remote https://shmem.example.com # another server shmem login --no-browser # print a link to open anywhere, then paste the code it shows shmem login --remote https://shmem.example.com/mcp --token sk-... # operator-issued token, no browser shmem logout ``` | Flag | What it does | |------|--------------| | `--remote ` | Sign in to this server instead. A URL without `/mcp` resolves to the address the server publishes for itself. | | `--no-browser` | Don't open a browser: print a link to open on any computer, then read the sign-in code its page shows. Automatic over SSH (`SSH_CONNECTION` set) and on Linux with no display. | | `--switch-account` | Sign in as a different account than this machine's, without asking. | | `--switch-server` | Move this machine to a different server than the one it syncs with, without asking. | | `--token ` | Use a token from the server's operator (its `keys.json`) instead of signing in. | | `--verbose` | Show the sync statistics behind the result lines. | `shmem login` opens your browser to sign in with the server's identity provider, and the browser hands the result back to shmem on a local loopback port. The machine is then signed in, saved as the default remote in `~/.shmem/remotes.json`: it presents short-lived access tokens and renews them with the provider's refresh token as it goes. The output is a few result lines: who you're signed in as, how many memories uploaded from this machine (on the first sign-in to an account), what arrived from your other machines, and where else to use the account. **Which projects sync.** The first time a machine syncs with an account, login lists the machine's projects with their memory counts and asks which sync: all of them, none, or the ones you pick. Memory saved outside a project is the `default` project, and past agent sessions `shmem install` imported count too. Enter means none. - A project that syncs uploads its memory and keeps syncing. - One that doesn't is local-only on this machine: its memory stays here, still searchable, and nothing in it uploads, now or later. - Projects you start using after login sync. `shmem admin project list` shows which is which, and `shmem admin project sync ` syncs a local-only project later. Writes still queued from a previous account or server aren't sent to the new account unless their project syncs. Signing back in to the account this machine synced as before signing out doesn't ask again. With no terminal to ask on (an agent or a script running login), none sync until someone chooses. Until then, `shmem status` and other commands say the choice is still to make, agents are reminded to ask, and running `shmem login` again on the signed-in machine asks it. `--sync all`, `--sync none`, or `--sync-project ` (repeatable) answers for scripts. Any line about access (such as an invite-only notice with a request-access link) or about the Claude app connector comes from the server, so another server shows its own or none. While a session works, running `shmem login` again prints the account, server and last sync instead of signing in again. **Which server.** With no `--remote`, login uses the server this machine already syncs with; on a machine that has never signed in, `SHMEM_LOGIN_SERVER` if set; otherwise hosted (`https://shmem.secondmoment.ai/mcp`). Signing in to a different server than the one this machine syncs with, or as a different account, asks first, since it moves syncing there; `--switch-server` and `--switch-account` answer yes. That account's first sync then asks which projects sync, as above. **New machines get everything.** The first sync downloads the last 30 days, so answers work within seconds, then the rest of the account's history in the background; `shmem status` shows `older memories: downloading` until it's done. **Without a browser on this machine** (SSH, headless), sign-in uses the server's callback page: open the printed link on any computer, sign in, and paste the code the page shows. The code works only on the machine that started the sign-in, once, within 10 minutes; the PKCE verifier never leaves the machine. A server without the callback page can't sign in a machine no browser can reach; sign in elsewhere, or use `--token`. **In Claude Code**, a signed-in machine turns off a claude.ai shmem connector (any connector whose name contains `shmem`) by adding a permissions deny rule for its tools, such as `mcp__claude_ai_shmem__*`, to `~/.claude/settings.json`: local shmem already covers the same account. `shmem logout` removes the rule. See [The Claude app](../claude-app/#on-a-computer-with-shmem-installed). The machine stays signed in until `shmem logout`, or until the provider ends the session: it expires, it is revoked, or the account is deactivated. Then shmem says `signed out of ` (in `shmem status`, after commands that would have synced, and once an hour to your agent through the prompt hook); memory keeps saving locally and syncs after the next `shmem login`. A server that refuses this machine's credentials is reported the same way. Sign-in needs a server with OIDC configured (`SHMEM_OAUTH_ISSUER`), reached over https (plain http only on a loopback host); the identity provider's endpoints must be https too. For a server without it, `--token` uses a token from its `keys.json`. `shmem logout` ends this machine's session at the identity provider (through the server, or by revoking the token, whichever the provider supports) and removes the remote. Memory already on the machine stays and keeps saving; it no longer syncs, and logout says how many recent memories hadn't uploaded yet (they upload if you sign in again as the same account). A token that wasn't issued by sign-in can't be revoked this way; the server's operator removes it from `keys.json`. ## `shmem remote add | list | remove | show | set-default | set-token` Manage remote shmem servers configured in `~/.shmem/remotes.json` (file mode 0600). To connect a machine to a server, use `shmem login`; these commands are for inspecting remotes and for advanced setups with more than one. The first remote added becomes the default; the sync layer uses it unless an explicit `` argument overrides on `push` / `pull`. ```bash shmem remote add origin https://shmem.example.com/mcp --token sk-... shmem remote list # marker * shows default shmem remote show origin # full details including token shmem remote set-default staging shmem remote remove origin # promotes the next remote to default echo "$KEY" | shmem remote set-token origin # replace the token in place ``` `set-token` replaces a remote's token, keeping its URL and default status; it reads the token from stdin when no token argument is given, which keeps it out of the process list. Apps that mint a short-lived key per session use it to install each new key (see [Embedding shmem](../embedded/)). On a remote signed in with `shmem login`, it ends that session. ## `shmem push [remote]` Manually push local writes to a remote. Default mode drains the pending-write queue (writes that haven't yet made it because the client was offline). With `--all`, uploads every local fact, idempotent by `dedup_key`. Projects that are local-only on this machine (`shmem admin project unsync`) are left out unless named with `--project`: ```bash shmem push # drain queue to default shmem push --stranded # list own facts that never reached the queue, confirm, push (--yes skips the prompt) shmem push --all # full upload of facts written here (never replicas) shmem push --all --project work # only one project's facts (repeatable); names a local-only project to push it anyway shmem push staging --all # explicit remote ``` ## `shmem pull [remote]` Pulls remote writes into the local DB. Default mode is delta-since-cursor, then a sweep of the projects shared with you; `--all` walks the entire remote dataset from time 0 (use after restoring from a backup or bootstrapping a fresh machine); it also applies every delete recorded in that walk, so it catches up on deletes made on your other machines. You rarely need it: CLI reads, a local `shmem-mcp`'s read tools and background ticker, and the prompt hook all run the same pull automatically (see [Sharing: when a machine syncs](/docs/sharing#when-a-machine-syncs)). If another sync is already running, `shmem pull` waits for it to finish. ```bash shmem pull # delta-since-cursor from default shmem pull --all # bootstrap a fresh machine ``` ## `shmem config show` One-shot diagnostic that prints every effective shmem setting with **provenance** (where each value came from). Useful when answers seem off and you need to see what shmem is actually using — provider, model, API key presence, caller identity, project route, DB path, remote sync state, cursor age, reachability. Pass `--json` for machine-readable output. ```bash shmem config show # human-readable, every dimension with source shmem config show --json # for monitoring / dashboards ``` Every value line shows the source — `~/.shmem/.env`, `shell env`, `auto-detect from API key`, `default`, or `cwd .shmem/project walk-up`. Provenance is the load-bearing piece: knowing the QA provider is "anthropic" isn't enough — knowing it came from auto-detect vs explicit .env is what lets you reason about config drift between machines. ## `shmem ignore [defaults | install]` Show and manage your `.shmemignore` rules. With no subcommand, syncs them with your account (when signed in) and lists the files that apply, with rule counts and where they sync. shmem's credential filters are built in and always apply after your own rules. ```bash shmem ignore # sync, then show your rules and the built-in ones shmem ignore defaults # print the built-in credential rules shmem ignore install --force # replace the global file with an empty one, ready to edit ``` See [Get Started](../shmemignore/) for the file format. See [Get Started](../get-started/) for the full walkthrough and the "[Agents that span multiple directories](../cross-repo/#how-captured-memories-are-tagged)" section for the `--global` flow. ### Per-directory hook routing `shmem hook user-message` / `response` / `tool-use` / `gemini-response` resolve the target project in this order on every invocation: 1. Walk up from the `cwd` field in the hook's JSON payload looking for a `.shmem/project` marker file. A marker counts only when it is a small regular file (a symlink to one is fine) holding a single project name, with no `/`, `\` or `..` path, and, in a directory other users can write such as `/tmp`, one you own. Any other is passed over with a warning, and the walk goes on up. 2. If none is found, use `SHMEM_DEFAULT_PROJECT` (set in `~/.shmem/.env` or your shell). 3. Then `SHMEM_PROJECT` (deprecated for the `shmem` CLI; still honored for one release with a one-shot warning. Continues to be the canonical config mechanism for `shmem-mcp`). 4. Otherwise, fall back to the `default` project. This means globally-installed hooks route correctly even across many directories in one session — create per-directory routing by running `shmem init` inside each project you want tracked separately. ### Duplicate hook registrations Claude Code merges hook configs from every settings level (`~/.claude/settings.json`, the project's `.claude/settings.json`, and `.claude/settings.local.json`) and runs **all** of them per event — so shmem hooks installed both globally and in a project would capture every fact twice. shmem dedupes this at runtime: only the **most specific** registration captures. When the registered commands differ, the less specific invocation detects the more specific one and exits; when they're identical, sibling invocations race for an atomic per-event claim marker (under `~/.shmem/hook-dedup/`) and only the first captures. Set `SHMEM_HOOK_DEDUP=off` to disable — e.g. if two registrations intentionally write to different databases via env wrappers. ## shmem ask Ask a question and get a grounded answer from memory. Runs the full question-answering pipeline. ```bash shmem ask "What auth approach did we choose?" ``` Needs an LLM (see `shmem install`). With none configured locally, `ask` answers through the default remote's QA when one is configured (honoring `--project` and `--meta`; `--mine`, `--shared` and `--private` need a local LLM), and otherwise fails with a note on how to add one. ``` On February 12 you chose JWT over sessions, because the API needed to be stateless [1]. Sources [1] Auth decision: JWT over sessions, API must stay stateless Feb 12 14:10 · api · github.com/acme/api 8f2c1a3b… ``` ### Sources The answer cites the facts it relies on with inline markers like `[1]` or `[2][3]`, numbered in order of first appearance, and the Sources block after it lists each one: - a short title: the fact's `title` metadata, else its first line, truncated; - when it was written, its project, and the repository it was captured in — or `from ` for a teammate's fact (one that reached you through a shared space, or, on a server, any fact another account owns); - its permalink on the dashboard when `shmem dashboard` is running for this store (`http://127.0.0.1:8706/#/fact/`), otherwise the first characters of its fact id. The dashboard holds your whole memory, so it answers only on `127.0.0.1`/`localhost` and only to a browser signed in to it. `shmem dashboard` prints a link with a token (`--open` opens it); the first visit signs that browser in until the dashboard stops, so the plain address and these permalinks work in it for that run. Open the printed link again after a restart. The token is kept in `~/.shmem/dashboard-token`, and scripts can send it as `Authorization: Bearer `; to change it, delete the file and restart the dashboard. Browsers share cookies across every port on `127.0.0.1`, so while you're signed in, don't open pages from other local servers you don't trust. Parts a fact doesn't have are left out. No Sources block is printed when the answer cites nothing, as when it comes from general knowledge. `--json` prints the answer, question type, fact count and a `citations` array (`n`, `fact_id`, `title`, `created`, `project`, `repo`, `from`, `url`) instead; through a remote that predates reporting it, `facts_consulted` is left out. An answer from a remote server's QA reads the server's structured result, so it prints the same way; a server too old to return one has its text printed as it came. The dashboard's Ask page (`shmem dashboard`) shows the same answer with each marker as a link and a Sources list under it; clicking either opens the fact in full — content, time, source, project, author, and all of its metadata. Every fact has a permalink, `#/fact/` on the dashboard's address, which opens it on its own page and survives a reload or a new tab; the markers and sources link to it, and `--json` and the dashboard's `/api/ask` give it as each citation's `url`. Answers from a remote server's QA carry no permalinks: the hosted server has no fact pages. ### Default scope When you run `shmem ask` from inside a project directory — one with a `.shmem/project` marker reachable by walking up from `cwd` — retrieval is automatically scoped to that project. If the project has zero matches, `shmem ask` auto-broadens to all projects and prints `(no facts in project= — broadened to all projects)` on stderr before answering. From a directory without a marker, ask searches every project. This matches the way `git`, `npm`, and most other CLI tools behave: operate on the local thing unless told otherwise. Override the auto-default with the flags below or with `SHMEM_DEFAULT_PROJECT=ALL` in your environment / `~/.shmem/.env`. ### Flags | Flag | Description | Default | |------|-------------|---------| | `-t, --tree` | Path to MemoryDB directory | Active project | | `-n, --max-facts` | Max facts to retrieve | `50` | | `--now` | Override current time for temporal reasoning (RFC3339 or `YYYY/MM/DD`) | — | | `-p, --project NAME` | Restrict to a specific project tag (explicit; no auto-broaden) | — | | `--here` | Same as the auto-default but explicit; disables auto-broaden when empty | `false` | | `--global` | Search every project (opt out of the auto-default current-project scope) | `false` | | `--mine` | Restrict to facts the calling user authored (uses `SHMEM_CALLER_USER`) | `false` | | `--shared` / `--private` | Restrict to shared-only or private-only facts | mixed | | `--meta KEY=VALUE` | Only consider facts whose metadata matches, e.g. `stamp_repo=github.com/acme/billing` (see [Metadata filters](../mcp-server/#metadata-filters)) | — | | `--json` | Print the answer and its citations as JSON | `false` | Requires an LLM provider for answer synthesis. Set `SHMEM_PROVIDER` (covers both roles), or `SHMEM_QA_PROVIDER` for synthesis alone. ## shmem query Search facts directly with multi-index keyword matching. Lower-level than `ask` — returns raw facts without LLM synthesis. Same auto-default and auto-broaden behavior as `shmem ask`. ```bash shmem query auth jwt # auto-scopes to current project; broadens if empty shmem query --global auth jwt # search every project explicitly shmem query -s user -p my-project database shmem query --since 7d "deployment" shmem query --meta branch=dev --meta thread=t1 --meta thread=t2 "deployment" shmem query --ids secret | shmem delete --stdin ``` | Flag | Description | Default | |------|-------------|---------| | `-s, --source` | Filter by source type (`user`, `llm`, `tool`) | All | | `-n, --limit` | Max results | `20` | | `-p, --project NAME` | Restrict to a specific project tag (explicit; no auto-broaden) | — | | `--here` | Same as the auto-default but explicit; disables auto-broaden when empty | `false` | | `--global` | Search every project (opt out of the auto-default current-project scope) | `false` | | `--mine` | Restrict to facts the calling user authored | `false` | | `--shared` / `--private` | Restrict to shared-only or private-only facts | mixed | | `--since` | Only include facts after this time (RFC3339 or relative: `1h`, `30m`, `7d`, `2w`) | — | | `--before` | Only include facts before this time | — | | `--meta KEY=VALUE` | Only include facts whose metadata matches, e.g. `stamp_branch=main` (see [Metadata filters](../mcp-server/#metadata-filters)) | — | | `--full` | Show full fact content | Truncated | | `--ids` | Output only fact IDs, one per line | `false` | ## shmem add Add a memory to the database. Usually invoked by hooks; call directly only when the user explicitly asks to remember something. Each `shmem add` should store one atomic fact — a single self-contained statement carrying its own names and keywords. Retrieval is keyword-based, so a paragraph that packs several facts together buries its entities where search can't rank them. To store many facts at once, use `--batch` with one fact per NDJSON line rather than concatenating them into one blob. ```bash shmem add "The deploy key is in 1Password under 'prod-deploy'" echo "User prefers dark mode" | shmem add -s user shmem add -s llm "Suggested using connection pooling for the DB layer" ``` | Flag | Description | Default | |------|-------------|---------| | `-t, --tree` | Path to MemoryDB directory | Active project | | `-s, --source` | Source type (`user`, `llm`, `tool`) | `user` | Caller identity is stamped from `SHMEM_CALLER_USER` and an agent label: `SHMEM_CALLER_AGENT` if set, otherwise the agent running the command (`claude-code` under Claude Code, `codex-cli` under Codex, `gemini-cli` under Gemini CLI, `pi` under Pi), otherwise `cli`. ## shmem whoami Show the two identities shmem tracks and whether they agree. ```bash shmem whoami ``` ``` author stamp: alice@laptop author agent: claude-code account: alice facts owned by "alice": 12043 facts owned by another identity: 6001 (not shareable) ``` Exits non-zero when the two disagree, so scripts can gate on it. See [Author stamp vs. account identity](../mcp-server/#author-stamp-vs-account-identity). ## shmem delete Delete facts by ID. Accepts IDs as arguments or from stdin. A fact in a shared space is first retracted from every space you can write to, so its readers drop their copies on their next sync. A fact still held by a space you can only read is kept, and the space's owner has to remove it. Retraction removes the fact itself, not what readers already learned from it. ```bash shmem delete abc123 def456 shmem query --ids secret | shmem delete --stdin shmem delete --project my-app abc123 ``` | Flag | Description | Default | |------|-------------|---------| | `-p, --project` | Project name | Current project | | `--stdin` | Read fact IDs from stdin (one per line) | `false` | ## shmem import Import existing history: agent transcripts, ChatGPT exports, GitHub, files. See [shmem import](../cli-import/). ## shmem gateway serve Capture traffic from an LLM gateway. See [shmem gateway serve](../cli-gateway/). ## shmem admin Status, models, projects, groups and other maintenance commands. See [shmem admin](../cli-admin/). ## shmem docs Open the shmem documentation in your browser. Serves the embedded docs site on localhost. ```bash shmem docs ``` ## Global flags Available on all commands: | Flag | Description | Default | |------|-------------|---------| | `--model` | LLM model name | Provider-specific | | `--ollama-url` | Ollama server URL | `http://localhost:11434` | | `-v, --verbose` | Enable verbose output | `false` | | `--version` | Print version | — | --- # Source: https://shmem.secondmoment.ai/docs/latest/compatibility/ --- # Compatibility shmem is pre-1.0 and moves quickly, but people run it in their shells, pin it in CI, and point hosted clients at it. This page says which surfaces we keep working, which we explicitly do not, and what happens when we have to break one. It is deliberately written in terms of **surfaces**, not inventories. A list of every tool and variable would go stale faster than the promise it documents — the current list lives in [reference](../reference/), which is maintained alongside the code. ## Stable We treat a change here as a break, and a break follows the procedure below. | Surface | Notes | |---|---| | **MCP tool names and parameters** — core memory, projects, and groups | Adding a tool or an optional parameter is free. Renaming or removing one needs a deprecation window. | | **Bearer auth scheme** — `Authorization: Bearer ` | The scheme is the contract. Individual tokens are not. | | **Documented environment variables** — those listed in [reference](../reference/) | They live in shell profiles, `.env` files, and CI configs. | | **CLI `--json` output** | This is an API that happens to be spelled as a flag. New fields are additive; changing what an existing field means is a break. | | **Files you edit by hand** — `~/.shmem/.env`, `.shmemignore`, and your database path | People keep these in dotfile repos. | Three tools carry more weight than the rest: **`add_memory`**, **`list_facts_since`**, and **`delete_memory`**. Hosted sync is built on the MCP tool surface rather than a separate wire protocol, so those three are how replication works. They are the strictest case on this page. ## Experimental **The sharing surface is new and still changing.** It may change without a deprecation window. It is off by default. This covers two things: - **Sharing** — the `shmem share` and `shmem unshare` verbs, the sharing tools (`share_facts`, `unshare_facts`, `share_status`, `share_log`, `share_show`, `scan_shares`, `discard_nomination`, `forget_nomination`, `distill_facts`, `set_sharing`, `get_share_rules`, `set_share_rules`, `share_updates`, and the internal `import_share_history`), the server's background scans, and the sharing views in the dashboard. - **The membership tools** — `add_membership`, `remove_membership`, `list_memberships_since`, and `get_facts`. These are part of the same model but are *not* gated by an account's sharing setting, so they are reachable even with sharing off. If you are automating against these, pin a version. ## Unstable by design Saying so plainly is the point — it is what keeps the stable set small enough to honour. | Surface | Instead | |---|---| | **CLI human-readable output** | Parse `--json`. Scraping the pretty output will break, and we will not treat that as a regression. | | **The SQLite schema** | Use the CLI or the MCP tools. We migrate the database as needed. | | **Internal state in `~/.shmem/`** — `pending/`, `.sync`, `.last_heartbeat`, `.update-check.json`, `remotes.json` | Deleting any of these should cost you at worst a re-sync. | | **Go packages under `internal/`** | The compiler already enforces this; it is listed because publishing the repo invites vendoring. | | **`SHMEM_TEST_*` environment variables** | These gate benchmarks and point tests at fixture trees. They are named so you can tell at a glance that they are not configuration. Nothing outside the test suite should set one. | ## How we break something When a stable surface has to change: 1. **Add the new thing alongside the old.** Both work. 2. **Warn on the old path** — on stderr for the CLI, in the tool description for MCP — naming the replacement and the version that removes it. 3. **Wait two minor releases.** 4. **Remove it**, with a changelog entry scannable by someone who skipped four versions. A security fix that cannot wait gets whatever window it has to, and the changelog says why. Naming the exception is how we stop it becoming the rule. ## If your client is too old You should get a clear error naming what changed and what to use instead — never a silent empty result. An empty answer where memory should be is the worst possible symptom for a compatibility problem, because it reads as data loss. If you ever see that, it is a bug worth reporting. --- # Source: https://shmem.secondmoment.ai/docs/latest/cross-repo/ --- # Projects across repos How shmem decides which project a captured memory belongs to, and how to work across several repositories. For the model itself, see [Projects](../projects/). ## How captured memories are tagged `shmem install` puts hooks at the user level (`~/.claude/settings.json`, `~/.codex/hooks.json`, `~/.gemini/settings.json`), so they fire for every session, regardless of which directory the agent is working in — including multi-directory agents like Cowork. Per-session routing works automatically: 1. The agent starts a session in some directory. The hook subprocess receives the agent's JSON payload, which includes the session's `cwd`. 2. `shmem hook` walks up from that `cwd` looking for a `.shmem/project` marker file. 3. If it finds one, memories are tagged with that project name. Otherwise memories are tagged with whatever `SHMEM_DEFAULT_PROJECT` resolves to, or `default` if unset. (All facts live in the same unified DB regardless — the project is just a tag for filtering, not a separate database.) To give particular repos their own tags: ```bash cd ~/projects/myapp && shmem init # opt myapp into its own project cd ~/projects/infra && shmem init # opt infra into its own project # any directory without `shmem init` falls back to `default` ``` Work in `~/projects/myapp` is then tagged `myapp`, work in `~/projects/infra` is tagged `infra`, everything else gets the default tag. The tag is what `shmem ask --project NAME` (or `--here`) filters by. ## Cross-repo setup (multiple projects) shmem stores everything in a single unified database; "project" is a tag column on each fact, not a separate database. See [Projects](../projects/) for the full model. The short version: - **Per-directory routing**: `shmem init` writes a `.shmem/project` marker so every `shmem` invocation from within that tree stamps writes with that project tag. The marker also drives `shmem ask --here`. - **Scope a query to a project**: `shmem ask --project frontend "..."` or `shmem query --project frontend "..."`. - **From within the project's directory**: `shmem ask --here "..."` is a zero-typing shortcut. - **Cross-project query (the default!)**: just `shmem ask "..."` — no flags. Searches across everything in the unified DB. - **MCP server config**: each `shmem-mcp` instance can be configured for a specific project tag via `SHMEM_PROJECT` in the client's `.mcp.json` `env` block. ### Managing projects ```bash shmem admin project list # see all projects (legacy view; lists projects.json registry) shmem admin project create my-app # register a project name shmem admin project delete old-app # remove a project from the registry ``` These admin commands operate on the legacy `projects.json` registry. In the unified DB world, the project tag column is what actually matters — but the admin commands still work for managing the project list shown in `shmem admin status` and the dashboard. ### Cross-project queries This is now the default: `shmem ask "..."` and `shmem query "..."` search the unified DB across every project tag. To narrow: ```bash shmem ask --here "what was I working on?" # current dir's project shmem ask --project frontend "auth changes" # specific tag shmem ask --mine "what did I decide last week?" # only your facts shmem ask --here --mine --private "internal notes" # composed ``` --- # Source: https://shmem.secondmoment.ai/docs/latest/embedded/ --- # Embedding shmem in your app If your product has its own agent, shmem can be its memory: each of your users gets a private shmem account that remembers them across sessions and can share what's relevant with their teammates. Your users never see shmem or sign in to it. Your backend creates their accounts and hands your agent a short-lived key for one user at a time. This guide is for the backend engineers wiring shmem into a custom agent harness. ## What you get When we set you up, you receive two things: - **A server URL**, such as `https://acme.shmem.secondmoment.ai`. It is your own shmem server: only your users have accounts on it. - **An app key.** It is a long-lived secret for your backend only. It can create users and mint their session keys, and nothing else: it can't read or write anyone's memory. Every credential you handle is an opaque bearer string. You don't sign tokens, run OAuth flows, or call an identity provider. ## The flow ``` your backend ──app key──► PUT /v1/embedded/users/{id} (first use) ──app key──► POST /v1/embedded/users/{id}/keys (each session) └─► session key ──► your agent ──► shmem MCP ``` ### 1. Provision a user, on first use ```bash curl -X PUT https://acme.shmem.secondmoment.ai/v1/embedded/users/u_8271 \ -H "Authorization: Bearer $SHMEM_APP_KEY" \ -d '{"name": "Dana Ruiz"}' ``` ```json {"app_user_id": "u_8271", "account": "u_8271@acme.embedded.secondmoment.ai", "name": "Dana Ruiz", "created": true} ``` `{id}` is your own ID for the user: 1–64 characters of letters, digits, `.`, `_` and `-`. The call is idempotent. It answers `201` when it creates the user and `200` when the user already exists, so you can make it at the start of every session if that's simpler than tracking who you've provisioned. The account is `@`, on a domain we assign when we set you up. It is the user's identity: invitations address it, and it never changes. A user ID that isn't lowercase letters, digits, `.`, `_` and `-` gets a hashed local part instead, so keep IDs lowercase if you want readable accounts. Nobody can sign in with an account, and shmem never sends it mail. The name is optional and is how people are shown: agents see "Dana Ruiz" when they recall a teammate's memories or answer questions about them, rather than the account. It can change: send a new one on any later call. Without a name, people are shown by account. ### 2. Start a session: mint a session key ```bash curl -X POST https://acme.shmem.secondmoment.ai/v1/embedded/users/u_8271/keys \ -H "Authorization: Bearer $SHMEM_APP_KEY" ``` ```json {"id": "api_key_01J…", "key": "sk_…", "expires_at": "2026-11-12T22:04:00Z"} ``` The key reads and writes this one user's memory, and expires after 12 hours. For a shorter lifetime, send `{"ttl_seconds": 3600}` (60 seconds to 12 hours). The key value is returned only once. Keep `id` if you want to end the session early. Mint a fresh key for each agent session rather than storing keys: there are no refresh tokens, and minting is cheap. ### 3. Give the key to your agent You can run shmem in either of two ways. The same session key works in both. **Remote MCP.** This is the simplest option, with no shmem process to run. Point your agent's MCP client at `/mcp` (streamable HTTP), with the session key as its bearer token: ```json { "mcpServers": { "shmem": { "type": "http", "url": "https://acme.shmem.secondmoment.ai/mcp", "headers": {"Authorization": "Bearer sk_…"} } } } ``` **Bundled local.** Run `shmem-mcp` over stdio on your agent's host, against a store directory per user that syncs to that user's account. This lowers recall latency and tolerates a flaky network. Bundle the `shmem` and `shmem-mcp` binaries, then for each session: ```bash export SHMEM_ROOT=/var/lib/myapp/shmem/u_8271 # The first session on this host: echo "$SESSION_KEY" | shmem remote add origin https://acme.shmem.secondmoment.ai/mcp --token - --no-push # Every later session: install the fresh key in place. echo "$SESSION_KEY" | shmem remote set-token origin # Then run the MCP server for the agent: shmem-mcp ``` A store directory is a cache of the user's account, not the account itself. You can delete it, or rebuild it on another host, and nothing is lost. Your backend can use a session key the same way when it reads or writes memory outside an agent session, for a bulk import, say. ### Saving conversations Embedded shmem has no automatic capture. Coding agents get it from hooks that shmem installs, but your harness has none, so nothing is remembered unless something writes it. Save each turn from your harness, not by asking the model to: after a turn, call the `add_memory_batch` tool with the user's message as a `user` fact and the reply as an `llm` fact. Then the agent only needs to recall, and memory doesn't depend on the model choosing to store something. Tell the agent its user's name, so anything it writes itself names people instead of saying "the user", which reads wrong once a teammate has it shared. ### 4. End access | To end | Call | Effect | |---|---|---| | One session | `DELETE /v1/embedded/users/{id}/keys/{key_id}` | That key stops working at once. Unrevoked keys expire on their own. | | A user's access | `DELETE /v1/embedded/users/{id}/access` | Every key the user holds stops working, and no new ones can be minted. Their account and memory stay. Provisioning them again restores the same memory. | Both answer `204` and take the app key. Deleting a user and their memory isn't supported yet; `DELETE /v1/embedded/users/{id}` is reserved for it. ## Errors Every endpoint answers errors as JSON, `{"error": "…"}`: | Status | Meaning | |---|---| | `400` | A malformed user ID or body | | `401` | A missing or invalid app key. On `/mcp`, a missing, expired or revoked session key: mint a new one. | | `404` | No such user (minting before provisioning), or no such key for that user | | `409` | A key was minted for a user whose access was removed | | `503` | Authentication is temporarily unavailable. Retry after the `Retry-After` interval; it isn't a reason to mint a new key. | ## Sharing between your users Each user's memory is private until they share it. Your users can share memories with each other through shmem's sharing tools, by groups and invitations, and their agents see what was shared with them. See [Sharing](../sharing/). An invitation names its recipient by their account, the `account` that provisioning returned, so tell your agent the names and accounts of the teammates its user works with. The `people` tool lists the names of everyone in the user's groups, and `members_of_group` with `names: true` names a group's members. Only your users have accounts on your server, so nothing can be shared outside your app. Within your app, though, your agent shares on its user's behalf when the model asks it to. A prompt injection, such as text in a document the agent reads, could ask it to invite another of your users or share memories with one. If that matters for your product, keep the sharing tools behind confirmation in your harness or filter them out of the tool list your agent sees. Whether your users share is decided when your server is set up. Sharing can be off for everyone; offered, so that each user turns it on for themselves through their agent (`set_sharing`); or on from the start for every user, who can still turn it off. With sharing on, the server reads the facts a user stores to nominate what may be worth sharing, which sends them to the server's LLM provider; nothing is shared without an explicit share or a share rule the user wrote. ## Handling keys safely - **Keep the app key on your backend.** Never put it in an agent's context, a client app, or logs. Anyone holding it can mint keys for any of your users. Ask us to rotate it if it leaks. - **Treat session keys as user credentials.** They are safe to place in an agent runtime that runs model-directed tool calls, which is what they're for. A leaked key exposes one user's memory until it expires or you revoke it. - **Expect 401s and mint again.** A key that expires mid-session gets a `401`. Mint a new key and reconnect. --- # Source: https://shmem.secondmoment.ai/docs/latest/environment/ --- # Environment variables Consumed by both `shmem` and `shmem-mcp`. ## Project and data | Variable | Description | Default | |----------|-------------|---------| | `SHMEM_DEFAULT_PROJECT` | Which project reads default to when no `.shmem/project` marker is found in cwd's walk-up. Set in `~/.shmem/.env` or your shell. The reserved value **`ALL`** means "do not auto-scope at all" and overrides a marker. It is uppercase because project names are lowercase-only, so `ALL` can never collide with a real project — unlike `global`, which is a perfectly valid project name. Replaces the deprecated `SHMEM_PROJECT` for the `shmem` CLI. | — | | `SHMEM_DEFAULT_SCOPE` | **Deprecated** — set `SHMEM_DEFAULT_PROJECT=ALL` instead, so one variable answers "which project do reads default to". Still honoured, with a one-shot warning; removed two minor releases after v0.3.7. | — | | `SHMEM_PROJECT` | **Deprecated for the `shmem` CLI** — prints a one-shot warning when consulted. Use `SHMEM_DEFAULT_PROJECT` (or a `.shmem/project` marker) instead. **Still the canonical config mechanism for `shmem-mcp`** — set per server instance in `.mcp.json`. | — | | `SHMEM_ROOT` | Root data directory | `~/.shmem` | | `CLAUDE_CONFIG_DIR` | Claude Code's config directory (Claude Code's own variable). `shmem install` writes hooks and the memory note there and imports transcripts from its `projects/`. | `~/.claude` | | `CODEX_HOME` | Codex's home directory (Codex's own variable). `shmem install` writes hooks there and imports its `sessions/`. | `~/.codex` | | `SHMEM_DB_PATH` | Explicit DB path (advanced, overrides project system) | — | | `SHMEM_TREE_PATH` | **Deprecated** — renamed to `SHMEM_DB_PATH`. Still honoured, with a one-shot warning; removed two minor releases after v0.3.7. The old name predates the removal of the MTree page-file engine in v0.2.28: there is no tree, and the value names a directory holding a SQLite database. | — | | `SHMEM_EMBED_MODEL` | Enable the opt-in dense-embedding index by naming an embedding model (e.g. `potion-retrieval-32M` for POTION, `nomic-embed-text` for Ollama, `text-embedding-3-small` for OpenAI). Vectors are persisted and embedded incrementally. Off by default — keyword + temporal indexes are the zero-config default. | — | | `SHMEM_EMBED_PROVIDER` | Provider for the embedding index: `potion` (in-process, no API key, model downloaded once on first use; recommended), `ollama`, or `openai`. Set this when your QA/LLM provider has no embeddings API (`anthropic`, `bedrock`, `gemini`, …) — without it the embedder falls back to `SHMEM_QA_PROVIDER` → `SHMEM_LLM_PROVIDER` and embeddings stay disabled on those providers. `shmem admin status` reports the embedding index state on its `Embeds:` line. | falls back to `SHMEM_QA_PROVIDER`, then `SHMEM_LLM_PROVIDER`, then `ollama` | **Project resolution order** (used by all CLI commands and hooks): 1. `.shmem/project` marker file (walk-up from cwd; per-directory routing wins) 2. `SHMEM_DEFAULT_PROJECT` 3. `SHMEM_PROJECT` (deprecated for CLI; honored for one release with warning) 4. `default` ## LLM provider | Variable | Description | Default | |----------|-------------|---------| | `SHMEM_PROVIDER` | Provider for **both** roles — QA synthesis and routing. The simplest way to configure shmem: one choice, both jobs. A role-specific variable below overrides it for that role. | auto-detect | | `SHMEM_MODEL` | Model for **both** roles. Overridden per role by `SHMEM_QA_MODEL` / `SHMEM_LLM_MODEL`. | provider default | | `SHMEM_LLM_PROVIDER` | Routing/summarization provider: `ollama`, `anthropic`, `bedrock`, `vertex`, `openai`, `gemini`, `openrouter`, `claude-cli`, `codex-cli`, or `mock` | `ollama` | | `SHMEM_LLM_MODEL` | Routing model | `qwen2.5:1.5b` (ollama), `claude-haiku-5-5` (anthropic), `gpt-5.6-luna` (openai), `gemini-3.8-flash` (gemini) | | `SHMEM_QA_PROVIDER` | Provider for `ask_memory` synthesis. `claude-cli` / `codex-cli` answer through a signed-in Claude Code (`claude -p`, Haiku unless `SHMEM_QA_MODEL` says otherwise) or Codex (`codex exec`) — no API key, but each answer uses the agent plan. If unset, falls back to `SHMEM_LLM_PROVIDER`, then auto-detects from available API keys (anthropic > openai > gemini > openrouter). With none, `ask` adopts what `shmem install` would pick (an agent CLI sign-in, then a configured remote's QA, then a running Ollama) or fails with setup instructions. `shmem install` writes this so the resolved value is visible at the `.env` layer rather than only at runtime. | auto-detect | | `SHMEM_QA_MODEL` | Override model for `ask_memory` synthesis. For `bedrock`, use a **cross-region inference-profile ID** (e.g. `us.anthropic.claude-haiku-5-5`, or the `eu.`/`jp.`/`au.`/`global.` prefix) — current Anthropic models on Bedrock reject their bare foundation-model ID on invoke. Leave unset to default to the Haiku 5.5 profile for your region; if your AWS account has no access to Haiku 5.5, shmem says so once and uses the Haiku 4.5 profile instead. For `vertex`, unset means Gemini (`gemini-3.8-flash`); set it to `claude` for shmem's default Claude, Haiku 5.5, served from the `global` location unless `SHMEM_VERTEX_LOCATION` says otherwise, which falls back the same way to Haiku 4.5 when your project or location doesn't serve it. `shmem install` writes `claude` when it finds Claude Code set up for Vertex. Falls back to `SHMEM_LLM_MODEL`, then to the provider's QA default — which for `openai` is `gpt-5.6-terra`, a tier above the `gpt-5.6-luna` routing default (synthesis reasons over up to 150K tokens of context; classification runs short structured prompts). | provider QA default | | `SHMEM_SCAN_PROVIDER` | Provider for share scans and distillation (the share-rules evaluation behind nominations, and on a server the background scans it runs for every account with sharing on). If unset, the QA provider. | QA provider | | `SHMEM_SCAN_MODEL` | Model for share scans and distillation, e.g. a cheaper model for a server's background scans. If unset, the QA model; when `SHMEM_SCAN_PROVIDER` names a different provider than QA, that provider's default instead. | QA model | | `SHMEM_REPLAY_WORKERS` | On a server: how many windows of one account's history replay (`shmem share scan --since`) run at once. | 8 | | `SHMEM_OLLAMA_URL` | Ollama server URL | `http://localhost:11434` | | `SHMEM_AWS_REGION` | AWS region for the `bedrock` provider. Falls back to the AWS chain (`AWS_REGION` / profile region) if unset. | — | | `SHMEM_AWS_AUTH_REFRESH` | Command run once before each Bedrock client build to refresh AWS credentials (e.g. an `aws sso login` wrapper). Runs per invocation — keep it fast and non-interactive. | — | | `SHMEM_VERTEX_PROJECT` | GCP project ID for the `vertex` provider (Gemini and Claude on Vertex AI). Falls back to `GOOGLE_CLOUD_PROJECT`. Required when the provider is `vertex`. | — | | `SHMEM_VERTEX_LOCATION` | Vertex region, e.g. `us-central1` (Gemini) or `us-east5` (Claude); `global` is accepted for models that support it. Falls back to `GOOGLE_CLOUD_LOCATION`. | `us-central1`; `global` when `SHMEM_QA_MODEL` / `SHMEM_LLM_MODEL` is `claude` | | `SHMEM_OPENAI_BASE_URL` | Base URL for OpenAI-compatible APIs (Together AI, Groq, Fireworks) | `https://api.openai.com/v1` | | `SHMEM_QA_MAX_FACTS` | Positive integer override for the per-call retrieval cap inside `ask_memory`. Wins over class-aware routing and over the caller-supplied `--max-facts`. Invalid values are ignored (with a stderr warning) and the caller's value is used. | unset (use caller arg or routing verdict) | | `SHMEM_QA_MAX_TOKENS` | Output-token limit for `ask_memory` answers. An answer that reaches it ends with an `[answer truncated …]` note. Lower it if a local OpenAI-compatible server rejects the request because prompt plus limit exceed its context; raise it for very long answers. Invalid values are ignored (with a stderr warning). | 8192 | | `SHMEM_NO_MODEL_PROBE` | Set to any non-empty value to disable the live model-list lookup. shmem otherwise asks the provider what it serves in order to name replacements when a configured model is dead, and to verify the model in `shmem admin status` / `shmem config show`. Set this in offline or egress-restricted environments. | unset (probing on) | | `SHMEM_VERBOSE` | Set to any non-empty value to surface the per-`ask_memory` routing decision (question type + chosen max_facts) on stderr. Useful for debugging "why didn't shmem cite anything for X?". | unset | | `SHMEM_QUIET` | Set to any non-empty value to silence **all** `shmem: warning [...]` diagnostics on stderr. These warnings are how shmem reports provider fallbacks, deprecated variables, and retrieval surprises — so quieting them trades noise for the chance of missing a real problem. Scripts parsing `--json` do not need it; warnings go to stderr, never stdout. | unset | ## API keys (put in `~/.shmem/.env`, not `.mcp.json`) | Variable | Description | |----------|-------------| | `ANTHROPIC_API_KEY` / `SHMEM_ANTHROPIC_KEY` | Anthropic key (second form avoids collisions with other tools) | | `OPENAI_API_KEY` / `SHMEM_OPENAI_API_KEY` | OpenAI key | | `GEMINI_API_KEY` / `SHMEM_GEMINI_API_KEY` | Google Gemini key | | `OPENROUTER_API_KEY` / `SHMEM_OPENROUTER_API_KEY` | OpenRouter key | | Amazon Bedrock (`bedrock`) | No shmem key — uses the standard AWS credential chain (env vars, shared profile, **SSO**, assumed role, IMDS). Run `aws sso login` and select the profile via `AWS_PROFILE`; or set `AWS_BEARER_TOKEN_BEDROCK`. Set the region with `SHMEM_AWS_REGION`/`AWS_REGION`. | | Google Vertex AI (`vertex`) | No shmem key — uses Google Application Default Credentials (`GOOGLE_APPLICATION_CREDENTIALS` service-account key, `gcloud auth application-default login`, or GCE/GKE workload identity). Set `SHMEM_VERTEX_PROJECT` and `SHMEM_VERTEX_LOCATION`. The model name selects the family: `gemini-*` or `claude-*`. | ## Caller identity and HTTP auth | Variable | Description | Default | |----------|-------------|---------| | `SHMEM_CALLER_USER` | Caller user identity (stamped on facts) | — | | `SHMEM_CALLER_AGENT` | Caller agent label. Set it per tool (an MCP server's `env` block, a hook's `--caller-agent`), not in `~/.shmem/.env`. When unset, the CLI uses the agent running it or `cli`, and the MCP server uses the client's name from the MCP handshake. | detected | | `SHMEM_API_KEY` | Deprecated: one shared bearer token for HTTP transports, every caller getting `SHMEM_CALLER_USER`'s identity. Use a one-entry `keys.json` | — | | `SHMEM_OAUTH_ISSUER` | OIDC issuer URL; enables per-user OAuth login on HTTP transports | — | | `SHMEM_SERVER_DOMAIN` | The server's public host (`shmem.example.com`, or `http://localhost:8705` for local testing); MCP is at `/mcp`. Required with an issuer | — | | `SHMEM_INSTALL_URL` | Where the server's empty-account answer tells people to install shmem | `https://shmem.secondmoment.ai/docs/latest/install/` | | `SHMEM_AUTH_ACCESS_NOTE` | One line of plain text `shmem login` shows under the sign-in link and in place of an identity-provider error, such as how to get access to this server. Unset shows nothing | — | | `SHMEM_LOGIN_SERVER` | Client side: the server `shmem login` signs in to on a machine that has never signed in, for installers that point a company's machines at its own server | hosted | | `SHMEM_OAUTH_ALLOWED_DOMAINS` | Comma-separated email domains allowed to sign in over OIDC; unset or `*` allows any verified email the issuer vouches for | — | | `SHMEM_AUTH_DISPLAY_NAME` | The server's name as `shmem login` and the sign-in code page show it | the server's host | | `SHMEM_AUTH_CONNECTOR_URL` | The Claude app connector address for this server's accounts, which `shmem login` offers after signing in | — | | `SHMEM_AUTH_CALLBACK_REGISTERED` | `1` when the provider's own CLI client lists `/auth/callback` as a redirect URI, so browserless sign-in can use the code page; without it (or the metadata document), a machine no browser can reach can't sign in. Not needed with the client metadata document, which lists it | off | ## Incognito mode Set `SHMEM_INCOGNITO=1` to suppress all hook writes for the duration of a session. Useful for benchmark runs, demos, or any time you want to use shmem tools without the conversation being captured. ```bash SHMEM_INCOGNITO=1 shmem ask "what was the last thing we worked on?" ``` When set, `shmem hook` subcommands return immediately without writing. `shmem ask`, `shmem query`, and MCP reads are unaffected — reads always work. Only writes are suppressed. ## Telemetry **shmem sends no usage data unless you turn it on.** It is off by default, and nothing below happens until you opt in. shmem asks once. The first `shmem ask` you run in a terminal that answers ends with the question (default no), and your agent asks too: once per machine, after an `ask_memory` answer, it is told to put the question to you and record your explicit answer with the `set_telemetry` tool. Whichever answer comes first is kept, and a no is remembered, so you aren't asked again. Nothing asks during install. ```bash shmem admin telemetry # show what's on shmem admin telemetry on # opt in — persistent, writes ~/.shmem/telemetry shmem admin telemetry off # opt out, and silence the update check too ``` | Variable | Description | Default | |----------|-------------|---------| | `SHMEM_TELEMETRY` | `on` enables usage reporting; `off` disables it *and* the update check | unset — usage reporting off, update check on | | `SHMEM_TELEMETRY_URL` | Collector URL. Point it at your own endpoint, or anywhere, to keep reports inside your network | `https://shmem.secondmoment.ai/v1/ping` | The environment variable takes precedence over the persistent setting. There are three states, not two, because the update check and the usage heartbeat disclose very different things: | Setting | Usage reporting | Update check | |---------|-----------------|--------------| | unset (default) | off | on | | `on` | on | on | | `declined` (a no to the question) | off | on | | `off` | off | off | Leaving it unset sends nothing about you or your store. Setting it to `off` additionally stops the [update check](#update-check), on the reading that someone who says "off" means no network calls at all. Reports go to `shmem.secondmoment.ai`, the same host shmem already syncs with. There is no third-party analytics vendor in the path, and no key baked into the binary — a build from source behaves exactly like the released one, which you can verify by reading `internal/telemetry` in the source. Usage reporting is also suppressed when a CI environment is detected (`CI`, `GITHUB_ACTIONS`, `GITLAB_CI`, `BUILDKITE`, `CIRCLECI`, `TRAVIS`, `TEAMCITY_VERSION`, or `JENKINS_URL` set to anything other than `false` or `0`). Ephemeral runners would otherwise register as new installs, since the anonymous ID derives from the machine's hostname. Once on, two kinds of event are sent: **Heartbeat** (at most once per ~20h, from either `shmem` or `shmem-mcp` — whichever you run): a hashed anonymous machine ID, shmem version, OS/arch, fact count, rolling 7-day activity counts (recalls / asks / inserts, distinct callers), active weeks, the configured QA provider/model, and a hashed project name (for cardinality only). The last-sent timestamp lives at `~/.shmem/.last_heartbeat`. **Activation milestones** (at most once each, ever): a hashed anonymous machine ID, shmem version, OS/arch, and which milestone was reached — `installed` (first run of any command), `configured` (`shmem install` finished), `imported` (an import first stored facts), and `first_read` (a successful `ask` or `query`). These record whether setup actually completed; the heartbeat alone cannot, because it only starts once `shmem-mcp` is running. Fired milestones are recorded in `~/.shmem/.activation`, which may be deleted safely. **What is never sent**: fact content, queries, answers, project names in the clear, API keys, or any personal identity. Sends are best-effort with a 3-second timeout and never block a command. ## Update check shmem checks at most once per ~20 hours whether a newer release exists, and prints a small notice on stderr when the running binary is behind. **The check sends no identifier of any kind** — no machine ID, no auth, no statistics — which is why it is on by default while the heartbeat above is not. It runs in a background goroutine after the command finishes, so it never adds latency. By default it asks GitHub for the latest release of the [tap repository](https://github.com/second-moment-ai/homebrew-tap/releases), reading the `releases/latest` redirect on github.com and falling back to the public Releases API only if that fails. The redirect draws on none of the API's 60-requests-an-hour allowance, which is per IP address and shared by everyone behind it. `shmem upgrade` looks it up the same way. If you have opted in to usage reporting, the heartbeat response carries the same answer, so an opted-in machine makes one network call a day rather than two. | Variable | Description | Default | |----------|-------------|---------| | `SHMEM_NO_UPDATE_CHECK` | Set to any value to disable the update-check nag, leaving everything else alone | unset | The check is also suppressed when: - `SHMEM_TELEMETRY=off` is set, or `shmem admin telemetry off` was run (master kill switch) - running under CI - the binary is a development build (`shmem --version` shows `dev`) - the command is `init`, `install`, `hook`, `docs`, `version`, `help`, or `upgrade` The same switches apply to `shmem-mcp` running over HTTP: its `/v1/ping` endpoint answers heartbeats with the latest release, which it looks up on the GitHub Releases API at most once an hour. With `SHMEM_NO_UPDATE_CHECK` set or telemetry off, the server makes no such lookup and answers without a version. When stderr is a terminal, a behind binary gets the full notice. When it is a pipe — which is every agent-mediated invocation — a single compact line is printed instead, at most once per 24 hours, so an agent driving shmem learns an upgrade exists without scripts drowning in repeats. State (last-check timestamp + cached latest version) lives at `~/.shmem/.update-check.json` and may be deleted safely at any time. When you upgrade, the next invocation refreshes the cache automatically. --- # Source: https://shmem.secondmoment.ai/docs/latest/get-started/ --- # Get Started shmem runs on your machine and stores memories locally — there is no account. Installing locally is the fastest way to feel what it does: one command wires in automatic capture *and* imports your existing agent history, so you can ask "what did I work on yesterday?" right away. Later, `shmem login` signs you in to an account, which puts the same memory on your other machines and in the Claude app, and lets you share it with teammates. (Already have an account? Jump to [signing in](../hosted-setup/).) ## Install > By installing and using shmem you agree to the [Self-Hosted Software Terms of Use](/docs/self-hosted-terms). > **Installed with Homebrew?** Homebrew is deprecated. Check `shmem --version`. On v0.2.25 or earlier, run `brew uninstall shmem` *before* the one-liner below, because those versions refuse to be replaced. On v0.2.26 or later, see [Migrating from Homebrew](#migrating-from-homebrew). **One-liner** (macOS, Linux, Windows/WSL; amd64 + arm64): ```bash curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh ``` It detects your OS and architecture, installs `shmem` and `shmem-mcp` to `~/.local/bin` (or `/usr/local/bin` with sudo if needed), then runs `shmem install`, which sets everything up without asking any questions: ``` Welcome to shmem, long-term memory for you and your agents. ✓ memory created at ~/.shmem ✓ Claude Code found: installed capture hooks, memory tools (MCP) and a recall note in CLAUDE.md ✓ Codex found: installed capture hooks, memory tools (MCP) and a recall note in AGENTS.md From now on, their sessions are saved to memory automatically. · importing past sessions Claude Code sessions (214) … 5210 memories (4s) Codex CLI rollouts (12) … 380 memories ✓ imported 226 past sessions ✓ answers via Anthropic (ANTHROPIC_API_KEY) Setup is done. Everything is on this machine; there is no account. shmem ask "what was I working on last week?" it already remembers your imported sessions shmem login to use this memory on your other machines or share it with teammates ``` What `shmem install` does, in order: 1. **Creates the memory store** at `~/.shmem` (or `$SHMEM_ROOT`). 2. **Wires every agent it detects** — Claude Code, Codex, Antigravity, OpenCode — with capture hooks (OpenCode: a capture plugin), shmem's memory tools as a user-level MCP server, and a short note telling the agent how to recall. Config locations honor each agent's own override: `CLAUDE_CONFIG_DIR`, `CODEX_HOME`, and `XDG_CONFIG_HOME` (OpenCode). 3. **Imports past sessions** from Claude Code, Codex, Cursor, Cline, and OpenCode. No LLM calls — it's parse-and-insert. A ChatGPT export or GitHub history it finds is pointed at, not imported (`shmem import --from chatgpt`, `shmem import --from github`). 4. **Finds an LLM to answer questions** — see [LLM provider options](../llm-providers/). You don't need to run it again after installing another agent. Claude Code, Codex, Antigravity or OpenCode installed afterwards is connected, and its past sessions imported (unless install ran with `--no-import`), the next time shmem runs: any `shmem` command, or within a day through another connected agent's hooks. An agent that was already present and left unwired (for example by `--for`) stays as you left it. If install found no LLM, one you set up later is picked up the next time you ask; to switch from one it did find, edit `SHMEM_QA_PROVIDER` in `~/.shmem/.env` or run `shmem install --provider `. History from Cursor or Cline installed later isn't imported automatically: `shmem import --from cursor` (or `cline`). Re-running `shmem install` is safe; it's idempotent. Flags: `--for ` wires one agent only (`claude-code`, `codex-cli`, `antigravity`, `opencode`), `--provider ` skips LLM detection, `--no-import` skips importing. To install the binaries without running setup, set `SHMEM_NO_SETUP=1`. **Manual tarball** (for version pinning or air-gapped installs). Tarballs are published to GitHub releases: ```bash # Replace OS/ARCH with one of: darwin_amd64, darwin_arm64, linux_amd64, linux_arm64, windows_amd64 # Replace X.Y.Z with the version from https://github.com/second-moment-ai/homebrew-tap/releases curl -fsSL "https://github.com/second-moment-ai/homebrew-tap/releases/download/vX.Y.Z/shmem_X.Y.Z_OS_ARCH.tar.gz" \ | tar xz -C /tmp sudo install -m 0755 /tmp/shmem /tmp/shmem-mcp /usr/local/bin/ shmem install ``` **Verify**: ```bash shmem --version shmem status --json # installed, configured_hosts, qa_provider, fact_count ``` ### Updating ```bash shmem upgrade # self-update to latest (no brew required) shmem upgrade --check # show what would be installed, don't act shmem upgrade --version v0.2.13 # pin a specific version ``` `shmem upgrade` fetches the latest release and replaces the running binaries in place. Works the same on every platform shmem supports. The once-per-day update-check nag points at this command directly. Agents already connected to shmem don't need a restart: on macOS and Linux, each running `shmem-mcp` switches to the new binary at its next request, keeping the agent's session. ### Migrating from Homebrew Homebrew support is deprecated. If you installed via `brew install second-moment-ai/tap/shmem`: ```bash shmem upgrade # replaces the brew-managed binary in place brew uninstall shmem # let brew stop tracking it ``` After that, `shmem upgrade` handles all future updates automatically. **On v0.2.25 or earlier**, `shmem upgrade` refuses to touch a brew-managed binary rather than replacing it, so the two commands above won't work. Check with `shmem --version`; if you're below v0.2.26, uninstall first and reinstall from the script: ```bash brew uninstall shmem curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh ``` > **AI agents:** if you landed here because a user asked you to install shmem, the [agent install guide at `/install/`](../install/) is structured specifically for you: run the one-liner above, relay its output, then verify with `shmem ask`. --- ## Quickstart ### Local (start here) Installing locally gives you the "it already knows my work" moment immediately — setup configures capture *and* imports your existing agent history in one step. 1. Install and set up (the [one-liner above](#install)): ```bash curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh ``` 2. Ask: ```bash shmem ask "what was I working on last week?" ``` New sessions in every wired agent are captured from here on. When you want this memory on another machine, or shared with teammates, the next step is `shmem login`. ### Sign in when you need to You've got shmem working locally. Sign in to a [hosted](../hosted/) account when you want to: 1. **Use one memory across machines** — laptop, desktop, cloud dev box, all in sync. 2. **Use it in the Claude app** — the [shmem connector](../claude-app/) answers from the same account. 3. **Share memory with your team** — teammates' agents draw on the same context. ```bash shmem login ``` It opens your browser to sign in, then asks which of this machine's projects sync with your account: all, none, or the ones you pick. The others stay on this machine only. Hosted access is invite-only for now: [request access](../signup/), then sign in with that email. See [Signing in](../hosted-setup/) for new machines, SSH, and other servers. ### Optional: per-repo projects with `shmem init` `shmem install` wires your agents at the user level, so every session is captured wherever it runs, and `shmem ask` searches all of your memory. Facts captured live are tagged with the `default` project; imported history is tagged with a project derived from where it happened (one per Claude Code project, Cursor workspace, or Codex working directory). If you want a repo to have its own project tag — to scope `shmem ask --here`, or to share one repo's memory — run `shmem init` inside it: ```bash shmem init # project named after the directory shmem init my-app # or name it ``` It writes `.shmem/project` and nothing else: no hooks, agent docs or MCP config in the repo, since `shmem install` already set those up for your user. Commit the file and teammates' sessions in the repo land in the same project. On a machine where shmem isn't set up yet, `init` runs `shmem install` first. **Scoping note**: shmem stores everything in a single unified database at `~/.shmem/db/`. Project is a *tag* on each fact, not a separate database. When you run `shmem ask "..."` from inside a project directory (one with a `.shmem/project` marker in the cwd walkup), it scopes to that project automatically, plus any shared spaces you've joined, what teammates wrote into projects you've shared, and memory saved with no project, such as what the Claude app saves; if that has no matches it auto-broadens to all projects and notes that on stderr. From a directory without a marker, `shmem ask` searches every project. Overrides: `--project NAME` (any tag, explicit), `--global` (search every project), `--mine` (only your facts), `SHMEM_DEFAULT_SCOPE=global` env var (restore the pre-default-project behavior across all calls). See [Projects](../projects/) for the full model. ### Verify ```bash shmem admin status shmem ask "What have I been working on recently?" ``` ## Manual setup If you're not using Claude Code, or prefer to configure by hand: 1. `~/.shmem/.env` — API key for your LLM provider 2. Hooks or MCP config, depending on your client — call `shmem hook user-message` / `shmem hook response` from `UserPromptSubmit` / `Stop` events, or register `shmem-mcp` as an MCP server 3. `CLAUDE.md` (or equivalent) — instructions teaching your agent when to use `ask_memory` and `recall_memory` See the [Reference](../reference/) page for the full CLI, MCP tool, environment variable, and transport details. ## Next steps - [Things to try](../try-it/) — prompts that show what memory changes - [LLM providers](../llm-providers/) — how shmem picks a model, local models, your own keys - [Projects](../projects/) and [projects across repos](../cross-repo/) — scoping memory per repository - [Filtering what gets captured](../shmemignore/) — keep secrets and noise out of memory - [Hosted shmem](../hosted/) and [signing in](../hosted-setup/) — one memory across machines and teammates - [Team setup (self-hosted)](../team-setup/) — run the server yourself - [Reference](../reference/) — CLI, MCP tools, transports, environment variables --- # Source: https://shmem.secondmoment.ai/docs/latest/hosted-setup/ --- # Signing in Signing in connects this machine to your shmem account. Memory stays on the machine, where it's still what answers; the account keeps a private copy, and every machine signed in to it stays in sync. With no LLM on the machine, `shmem ask` answers through the server's QA. ## Sign in ```bash shmem login ``` ``` Opening your browser to sign in to shmem.secondmoment.ai. If it didn't open: https://shmem.secondmoment.ai/auth/… No account yet? shmem.secondmoment.ai is invite-only for now. Request access: https://secondmoment.ai/shmem Waiting for you to finish in the browser… ✓ signed in as you@example.com This machine has 9,412 memories in 3 projects from before it synced with this account. Some may be past agent sessions shmem install imported. 1. default (memory saved outside a project) 8,950 2. acme-app 462 3. old-job 310 Choose which projects sync with your account on shmem.secondmoment.ai. A project that syncs uploads its memory and keeps syncing, so your other machines get it. One that doesn't stays on this machine only: nothing in it uploads, now or later. Projects you start using later sync. a all of them sync n none sync; keep them all on this machine p pick the projects that sync Sync? [a/N/p]: p Projects that sync (numbers or names, separated by commas): 1, 2 ✓ uploaded 9,412 memories from this machine · kept on this machine only: old-job (310 memories). To sync one later: shmem admin project sync · nothing from the last 30 days; looking for older memories in the background. shmem status shows when it's done Your memory now lives in your account as well as on this machine. It's private to you, and it stays in sync from here on. On another machine: install shmem, then shmem login. In the Claude app: add the connector https://shmem.secondmoment.ai/mcp ``` The lines about access and the Claude app come from the server, so a self-hosted server shows its own (or none). Check where you stand any time with `shmem status`: ``` Account: you@example.com on shmem.secondmoment.ai synced 2 min ago ``` Running `shmem login` again while signed in just says so; `shmem login --switch-account` signs in as someone else. Agents sign in the same way, through the `login` tool on shmem's local MCP server: ask yours to *"sign me in to shmem"*, and it relays the link and waits for you to finish. ## A new machine Install shmem, then sign in with the same email: ```bash curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh shmem login ``` ``` ✓ signed in as you@example.com ✓ downloaded 2,140 memories from the last 30 days, from your-laptop · downloading older memories in the background; shmem status shows when it's done Ready: shmem ask "what was I working on last week?" ``` The last 30 days arrive first, so `shmem ask` works within seconds; the rest of the account's history then downloads in the background, and `shmem status` shows `older memories: downloading` until it finishes. Or tell the new machine's agent: *"set up shmem, I already use it on my laptop"*. ## Signing in over SSH, or with no browser Over SSH (or with `--no-browser`, or on Linux with no display), shmem doesn't open a browser. It prints a link to open on any computer; after you sign in there, the page shows a sign-in code with a Copy button. Paste it back into the terminal: ``` $ shmem login (SSH session detected, so no browser is opened) Open this link in a browser on any computer to sign in to shmem.secondmoment.ai: https://shmem.secondmoment.ai/auth/… Then paste the sign-in code it shows you. Code: shm1.… ✓ signed in as you@example.com ``` The code works only on the machine that started the sign-in, once, for 10 minutes. An agent asks you for the code and passes it to the `login` tool. A server without that page (an older or minimal self-hosted one) can't sign in a machine no browser can reach: sign in on one that has a browser, or use a token from the server's operator (`shmem login --remote --token `). ## Other servers `shmem login` signs in to the server this machine already syncs with; on a machine that has never signed in, it uses `SHMEM_LOGIN_SERVER` if set (for installers that point a company's machines at its own server), and the hosted server otherwise. `--remote` picks any other: ```bash shmem login --remote https://memory.example.com ``` Moving a machine that already syncs with one server to another asks first, and then asks which projects sync there, as on a first sign-in; `--switch-server` answers yes. A server without sign-in needs a token from its operator: `shmem login --remote https://memory.example.com/mcp --token sk-...` (see [Reference](../cli/#shmem-login--shmem-logout)). ## Signing out, and deletes `shmem logout` signs this machine out. Its memory stays here and keeps saving; it just stops syncing, and anything not yet uploaded uploads if you sign in again. If the server ends the session (it expired, or your access was removed), shmem says `signed out of ` and keeps answering from this machine until you run `shmem login` again. Deleting a memory (`shmem delete`, or an agent's `delete_memory`) removes it from your account, and your other signed-in machines drop their copies on their next sync. ## Clients Every machine with shmem installed uses local shmem, signed in with `shmem login`: capture hooks save every turn, and the agents' shmem MCP server is the local one. Surfaces without a local install reach the account directly: | Client | How it reaches your account | Capture | |--------|------------------------------|---------| | Claude Code, Codex, Antigravity, OpenCode (shmem installed) | Local shmem, signed in with `shmem login` | Guaranteed (every turn, by hooks) | | Claude app (web, desktop, mobile), Cowork | The [shmem connector](../claude-app/) | Model-dependent: what the model saves | | Claude Code without shmem installed | `claude mcp add --transport http shmem https://shmem.secondmoment.ai/mcp` (OAuth) | Model-dependent | | ChatGPT | Developer Mode → add an MCP server with the URL | Model-dependent | On a machine where shmem is installed and signed in, a claude.ai shmem connector is turned off in Claude Code automatically, since local shmem covers the same account. See [The Claude app](../claude-app/#on-a-computer-with-shmem-installed). Without hooks, capture relies on the model saving what matters. The hosted server's instructions ask it to; for a client that ignores server instructions, add something like this to its system prompt: ``` When the user shares important decisions, preferences, or context that would be useful in future conversations, use add_memory — one self-contained fact per call, never several packed into one paragraph. Use ask_memory at the start of conversations to check for relevant context. ``` --- # Source: https://shmem.secondmoment.ai/docs/latest/hosted-terms/ --- # Second Moment AI — Terms of Use **Paid Hosted Service** Last updated on July 30, 2026

1. Acceptance of These Terms

These Terms of Use ("Terms") form a binding agreement between Second Moment AI, Inc. ("Second Moment," "we," "us," or "our") and the individual or entity that subscribes to or uses the Service ("you" or "Customer"). By clicking "I agree," submitting payment information, or accessing or using the Service, you agree to these Terms. If you use the Service on behalf of an organization, you represent and warrant that you are authorized to bind that organization, in which case "you" means that organization. These Terms incorporate by reference our privacy policy located at [https://shmem.secondmoment.ai/docs/privacy](/docs/privacy).

2. Definitions

**"Authorized User"** means an individual you authorize to use the Service under your account or workspace. **"Customer Data"** means all data you or your Authorized Users submit to or process through the Service, including the conversations you and your agents generate (your inputs), conversation metadata, and the outputs generated in response. **"Prohibited Content"** means content that is unlawful, infringing, deceptive, contains malicious code, or is otherwise objectionable as described in Section 5. **"Service"** means Second Moment's hosted, cloud-based external memory layer for AI agents, including any collaboration and team features or associated offline or mobile components made available to you on a subscription basis. **"Telemetry"** means technical data about your use and the performance of the Service.

3. Accounts, Teams & Workspace Ownership

(a) **Access.** Subject to these Terms and payment of applicable fees, Second Moment grants you a limited, non-exclusive, non-transferable right to access and use the Service for the internal business use of you and your Authorized Users during your subscription. (b) **Workspace Ownership.** A team or organization workspace, and the Customer Data within it, are owned and controlled by the Customer on whose behalf the workspace is established. If Customer is an individual, you may request that Second Moment assign your account(s) to an organization. If your account is assigned, subject to our verification procedures and the organization's acceptance of these Terms, the organization may claim administrative control of your account(s) and your Customer Data.

4. Your Data; Ownership

(a) **You Own Your Data.** As between the parties, you own and retain all right, title, and interest in and to your Customer Data. Second Moment claims no ownership of your Customer Data, takes no royalty in anything you create using the Service, and will not sell your Customer Data. (b) **Our Limited Use.** You grant Second Moment and our applicable contractors a non-exclusive, worldwide license to host, copy, use, process, display, and transmit your Customer Data to provide and support the Service. In addition, we may use your Customer Data to train, fine-tune, or improve our products and services except to the extent you expressly opt out under Section 7. (c) **We Own the Service.** As between the parties, Second Moment owns and retains all right, title, and interest in and to the Service and Telemetry.

5. Acceptable Use; Restrictions

(a) **Restrictions.** You will not (and will not permit any third party to): (i) allow anyone other than Authorized Users to access the Service; (ii) share access credentials; (iii) reverse engineer or attempt to derive the Service's source code; (iv) resell, sublicense, or host the Service for a third party; (v) use the Service in violation of applicable law; or (vi) introduce malicious code or interfere with the Service. (b) **Your Content.** You are solely responsible for the content you submit, and for ensuring you have all rights and consents necessary to submit it. You will not submit to the Service any content that: (i) you lack the right to submit; (ii) violates any applicable law or third-party right; (iii) constitutes Prohibited Content; or (iv) consists of special categories of personal data or other sensitive or regulated data (including health, financial account, government identifier, biometric, or children's data). Second Moment provides tools to help you manage and remove content but does not monitor, and is not responsible for, the content you choose to submit.

6. Security & Data Handling

Second Moment maintains commercially reasonable administrative, technical, and physical safeguards designed to protect Customer Data, including encryption of Customer Data. Access to Customer Data is restricted to authorized personnel on a need-to-know basis solely to provide and support the Service, and such access is logged.

7. AI Training — Opt-Out

Second Moment may use your Customer Data to develop, train, fine-tune, or improve artificial intelligence or machine learning models. This setting is ON by default. You authorize Second Moment to collect, retain, and use your Customer Data to develop and improve Second Moment's artificial intelligence or machine learning models for long-term-memory retrieval and related functionality. You may opt out of such use at any time by contacting us in writing; opt out applies going forward and does not require Second Moment to reverse any model training already performed. Second Moment owns all models, weights, and improvements it develops.

8. Your Data Controls

The Service provides tools that allow you to access, export, redact, and delete your Customer Data at any time, at no additional charge, in an open, machine-readable format that enables migration to another service.

9. Telemetry

The Service and any associated client software transmit Telemetry to us. We use Telemetry to understand aggregate product usage and health.

10. Fees; Payment

Paid features of the Service are billed according to the plan you select at sign-up. You authorize us and our payment processor to charge your payment method for all applicable fees and taxes. Except as required by law or expressly stated, fees are non-refundable. We may suspend the Service for non-payment. Fees may change for renewal terms on prior notice.

11. Term; Termination

These Terms apply for the duration of your subscription and any use of the Service. Either party may terminate for the other's uncured material breach on thirty (30) days' notice, and we may suspend or terminate for non-payment or for use that threatens the security or integrity of the Service. Upon termination, your right to access the Service ends and we may delete Customer Data. Sections 4, 5, 9, 12, 13, 14, and 15 survive termination.

12. Disclaimers

THE SERVICE IS PROVIDED "AS IS" AND "AS AVAILABLE" TO THE FULLEST EXTENT PERMITTED BY LAW. SECOND MOMENT DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT, AND DOES NOT WARRANT THAT THE SERVICE WILL BE ERROR-FREE OR UNINTERRUPTED.

13. Limitation of Liability

(a) TO THE FULLEST EXTENT PERMITTED BY LAW, SECOND MOMENT WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES. EXCEPT FOR UNCAPPED CLAIMS (BELOW), SECOND MOMENT'S TOTAL LIABILITY WILL NOT EXCEED THE GREATER OF (I) THE FEES YOU PAID FOR THE SERVICE IN THE TWELVE (12) MONTHS BEFORE THE EVENT GIVING RISE TO THE CLAIM OR (II) ONE HUNDRED U.S. DOLLARS (US$100). (b) **Uncapped Claims.** Nothing limits liability for liability that cannot be limited under applicable law, including willful misconduct or infringement of the other party's intellectual property rights.

14. Indemnification

(a) **By Second Moment.** Second Moment will defend you against third-party claims that the Service infringes such third party's patent, trademark, or copyright, and will indemnify you for amounts finally awarded or agreed in settlement, subject to customary exclusions (including combinations with non-Second Moment products and unauthorized modifications). (b) **By You.** You will defend and indemnify Second Moment against third-party claims arising from your Customer Data, your use of the Service in violation of these Terms, or your violation of applicable law or third-party rights.

15. Changes to These Terms; General

Second Moment may modify these Terms from time to time. If we make a material change, we will provide reasonable notice (for example, by email, in-product notice, or by posting the updated Terms with a new effective date). Changes are effective upon the stated effective date, and your continued use of the Service after that date constitutes acceptance of the updated Terms. We maintain prior versions and will identify the version in effect. If you do not agree to a change, your remedy is to stop using the Service. These Terms, together with any order or plan you accept, are the entire agreement between you and Second Moment regarding the Service. The Service is subject to U.S. export control laws. If any provision is unenforceable, the remainder remains in effect. You may not assign these Terms without our consent; we may assign in connection with a merger, acquisition, or sale of assets. In case of conflict, the order of precedence is: (i) your order or plan; and (ii) these Terms. These Terms are governed by the laws of California, without regard to conflict-of-laws rules, and the parties submit to the exclusive jurisdiction of the courts located in San Francisco, California. **BY DOWNLOADING, INSTALLING, ACCESSING, OR USING THE SERVICE, OR BY CLICKING "I AGREE," YOU ACKNOWLEDGE THAT YOU HAVE READ, UNDERSTOOD, AND AGREE TO BE BOUND BY THESE TERMS.** --- # Source: https://shmem.secondmoment.ai/docs/latest/hosted/ --- # Hosted shmem Hosted shmem is a shmem **account** on a server we operate. It's the same memory you run locally, kept in your account as well as on your machine, so it can follow you. You've probably already [installed shmem locally](../get-started/), and that's the right place to start: a local install sets up capture and imports your history, so your agent remembers your work immediately. Sign in when local isn't enough, specifically when you want to: 1. **Use one memory across machines.** Laptop, desktop, a cloud dev box: sign each one in, and they all stay in sync with your account. 2. **Use it in the Claude app.** The [shmem connector](../claude-app/) answers from the same account on claude.ai, Claude Desktop and mobile. 3. **Share memory with your team.** Share a project, and teammates' agents draw on the context your sessions captured, and vice versa. If none of those apply yet, stay local: there's no benefit to an account until you hit one of them. [**Request access →**](../signup/) ## Sign in On a machine with shmem installed: ```bash shmem login ``` It opens your browser to sign in, then asks which of this machine's projects sync with your account: all, none, or the ones you pick. The others stay on this machine only. On another machine, install shmem and run `shmem login` with the same email, and it catches up on what your other machines saved. Your agent can do it for you: tell it *"set up shmem, I already use it on my laptop"*. [Signing in](../hosted-setup/) has the details: new machines, signing in over SSH, other servers, and signing out. In the Claude app, add the connector `https://shmem.secondmoment.ai/mcp` and sign in with the same email. See [The Claude app](../claude-app/). ## What changes when you sign in | | Local (start here) | Signed in | |---|---|---| | Setup | One-line install (runs `shmem install`) | `shmem login` on each machine; the connector in the Claude app | | Where memory lives | Your machine (`~/.shmem`) | Your machine, plus your account on our server, isolated per user | | Other machines | — | Stay in sync with the account, full history included | | LLM for answers | Yours | Yours, or ours when the machine has none: we cover the synthesis cost | | Capture | Local hooks on your machine | The same hooks; what they save syncs | | Team sharing | — | Yes, per project ([Sharing](../sharing/)) | ### Claude.ai and Cowork Add shmem as a custom connector with the URL `https://shmem.secondmoment.ai/mcp`, and sign in when asked. There are no hooks here, so the agent records your session itself with `session_digest`, usually once in each turn that settles a decision. Cowork asks you to approve each call. Choose **Allow for this task** on the first prompt so the rest of the session records without asking again; **Allow once** brings the prompt back on every call. ## What we store, and where - **What:** the memories your machines upload and what the Claude app saves through the connector, plus the retrieval structures shmem builds over them. - **Where:** on our server, in a database **isolated per account**. Your memories are not visible to other users unless you share a project with them. - **LLM synthesis:** when an answer runs on our server (the connector's `ask_memory`, or a machine with no LLM of its own), we run the synthesis on our own key and cover the cost. Your stored memories are sent to the model to generate the answer and used for nothing else. To keep something out of memory, set `SHMEM_INCOGNITO=1` for that session, or exclude it with a [`.shmemignore`](../reference/) rule. ## Team sharing Sharing is per project and revocable: create a group, invite teammates by email, and share specific projects with the group. A project you haven't shared stays private to you. Your agent can do all of this through shmem's sharing tools, or you can use the `shmem group` and `shmem share` commands. See [Sharing](../sharing/). ## Managing and deleting your data - **Delete memories** with `shmem delete` (or your agent's `delete_memory` tool). A delete leaves your account and reaches your other signed-in machines on their next sync. - **Sign a machine out** with `shmem logout`. Its memory stays on that machine and stops syncing. - **Delete everything:** ask and we'll remove your account's database entirely. ## Pricing While the service is in its early period, access is approved manually and we cover the LLM synthesis cost — there's no per-user usage limit today. As it matures we'll introduce clearer plans; existing users will hear about any change well ahead of time. ## Running it yourself You can run the multi-user server on your own infrastructure. There's no license key and no separate build — team sharing, groups and project grants are in the same binary you already have, and self-hosting needs nothing from us. Machines sign in to it with `shmem login --remote https:///mcp`. What this hosted service sells is the operating, not the software: we run the server, keep it up, and cover the LLM synthesis cost. If you'd rather not do that yourself, email [hello@secondmoment.ai](mailto:hello@secondmoment.ai). ## Questions Email [hello@secondmoment.ai](mailto:hello@secondmoment.ai) — for access, larger-team needs, or anything unclear above. --- # Source: https://shmem.secondmoment.ai/docs/latest/how-it-works/ --- # How it Works ## Architecture overview ``` Agent (Claude Code, Cursor, etc.) │ ├── add_memory ──→ FactStore (SQLite, WAL mode) │ │ │ ├──→ KeywordIndex (SQLite FTS5, BM25 + porter) │ ├──→ TemporalIndex (time-sorted, recency) │ └──→ EmbeddingIndex (dense vectors, opt-in) │ ├── recall_memory ──→ Multi-index retrieval ──→ Ranked facts │ └── ask_memory ──→ Question-Answering Pipeline ├── Classify question type ├── Retrieve facts (multi-index) ├── Format context (timestamps, sessions) ├── Build type-specific prompt ├── Generate answer (LLM) └── Extract clean answer ``` ## Storage ### Facts Facts are the atomic unit of memory. Each fact is a piece of text with metadata: - **Content**: The actual text (a user message, agent response, or tool output) - **Source**: `user`, `llm`, or `tool` - **Timestamp**: When the fact was stored - **Caller**: Who stored it (user identity + agent name) - **Metadata**: String key/value pairs, including the agent's `session_id` and the provenance stamps below #### Provenance stamps Each captured fact records where it was captured, in metadata keys prefixed `stamp_`. Hooks and `shmem add` record what they can work out from the agent's working directory and environment; anything that can't be determined is left off. | Key | Value | |-----|-------| | `stamp_repo` | The git repository's origin as `host/owner/name` (`github.com/acme/billing`). SSH and HTTPS spellings normalize to the same value, credentials are never kept, and a linked worktree reports its main repository. A repository with no remote records its root directory (`~/src/notes`). Absent outside a repository. | | `stamp_branch` | The checked-out branch. Absent when HEAD is detached. | | `stamp_dir` | The agent's working directory, relative to home (`~/src/billing/svc`). | | `stamp_host` | The machine's short hostname. | | `stamp_cloud` | The hosted environment the agent runs in: `claude-code-cloud` (`CLAUDE_CODE_REMOTE=true`), `codespaces` (`CODESPACES=true`), or `github-actions` (`GITHUB_ACTIONS=true`). Absent elsewhere. | | `stamp_project_source` | How the fact's project was chosen: `marker` (a `.shmem/project` file), `env` (`SHMEM_DEFAULT_PROJECT`, or the deprecated `SHMEM_PROJECT`), or `fallback` (the default project). | | `stamp_app_project` | The Claude app project the agent reported working in, via the `app_project` input of `add_memory` or `session_digest`. | Git state is read from the repository's `.git` files, not by running `git`, so stamping never slows a hook. Other write paths stamp only what they can vouch for: - `shmem add --batch` stamps `stamp_host` and `stamp_cloud`, plus `stamp_project_source` for records that don't name a project. A batch is often a bulk or historical load, so the checkout it runs in says nothing about its records; repo, branch and dir come only from the records' own metadata, which always wins. - A local stdio MCP server stamps `stamp_host`, `stamp_cloud` and, when the call names no project, `stamp_project_source`. For the agents known to say where their session is rooted, it also stamps that root's `stamp_repo` and the `stamp_branch` checked out at the time of the call (or `stamp_dir` when the root isn't a repository), and the agent's `session_id`: | Agent | Session root | `session_id` | |-------|--------------|--------------| | Claude Code | `CLAUDE_PROJECT_DIR` | `CLAUDE_CODE_SESSION_ID` (the id when the server started) | | Codex | the server's working directory (the session's `-C` directory) | sent with each tool call | | Gemini CLI | the server's working directory (where Gemini was started) | — | Other clients get neither: their server's working directory says nothing reliable about where the agent works. A `session_id` the call already carries is kept. - A remote MCP server stamps only `stamp_app_project`. Stamps are ordinary metadata, so a [metadata filter](../mcp-server/#metadata-filters) narrows a read to them: `shmem ask "why did we cap retries?" --meta stamp_repo=github.com/acme/billing`. Stamps belong to the fact's owner. They sync to the owner's own server copy with the rest of the metadata, but are removed from every copy that reaches another account: a fact shared into someone else's space, a fact written directly into another user's project, and any fact a teammate reads from a shared space. A teammate can't filter a read of your project on `stamp_*` keys either. When you ask a question, the answering model sees your own facts' stamps as a short provenance line — `github.com/acme/billing (branch fix/retry-cap) · on laptop · app: Q4 pricing` — so it can say where work happened. A teammate's stamps are removed before the model sees anything, whether the answer runs on your machine or on a server, and their facts' citations show who they came from instead of a repository. Asking in another account's project, its facts reach the model with only the metadata their audience may see, as `get_facts` would show them to you. Facts are immutable — insert or delete only, never modified. They're stored in SQLite with WAL mode for concurrent reads. Atomicity matters for retrieval, not just storage. The keyword index ranks whole facts, so each fact needs to carry the names and keywords it should be found by. One self-contained statement per fact keeps every entity at the surface; a paragraph that packs several facts together ("Batch of facts: (1)… (2)… (3)…") buries them — BM25 sees one long, diluted document, the write succeeds, and reads quietly miss. Writers (integrations especially) should split multi-fact content into separate writes rather than storing it as one blob. ### Projects Projects provide namespace isolation. Each project gets its own SQLite database and index files. The default project lives at `~/.shmem/projects/default/`. Switch projects via a `.shmem/project` file at your repo root (written by `shmem init` and discovered by walking up from the current directory), `SHMEM_DEFAULT_PROJECT` for global mode, or the `shmem admin project` command. The legacy `SHMEM_PROJECT` env var is deprecated for the `shmem` CLI but still the canonical config mechanism for `shmem-mcp` server instances. ## Retrieval shmem uses a keyword index and a temporal index by default (plus an opt-in embedding index). Each captures a different signal: ### Keyword index A persisted SQLite FTS5 index with BM25 ranking and porter stemming. Fast, deterministic, and works well for specific terms. Because it's a SQLite index maintained by triggers, it's kept current at write time — no rebuild-from-scan when a process starts. - BM25 ranks matches by term rarity and frequency - porter stemming matches word variants (e.g. "running" ↔ "run") - User messages receive a configurable boost (they tend to carry more signal) ### Temporal index Time-sorted index for recency queries and context expansion. - Returns recent facts with recency scoring (most recent = highest score) - Supports range queries (facts between two timestamps) - Context expansion: given an anchor fact, retrieves surrounding facts within a time window (like `grep -C`) ### Embedding index (opt-in) **Off by default.** A fresh install runs keyword + temporal retrieval only — that's the intended zero-config setup (no embedding service, no per-fact embedding cost), not a broken one. This index is an optional extra. When enabled, it's a dense-vector similarity index that bridges the vocabulary gap keyword search can't — matching facts by meaning even when they share no words with the query. Backed by a pluggable embedder (in-process POTION, local Ollama, or a hosted API), enabled by setting `SHMEM_EMBED_MODEL`. If your QA/LLM provider has no embeddings API (`anthropic`, `bedrock`, `gemini`, …), also set `SHMEM_EMBED_PROVIDER` to route the embedder elsewhere. The recommended setup is `SHMEM_EMBED_PROVIDER=potion` with `SHMEM_EMBED_MODEL=potion-retrieval-32M`: a static embedder that runs in-process, with no API key, no daemon and no network at query time. Its model files (~123 MB resident) are downloaded from Hugging Face on first use and cached under the user cache directory (override with `GO_POTION_HOME`). `shmem admin status` reports the index's state on its `Embeds:` line. - Facts are embedded once; vectors are persisted in SQLite and only new facts are embedded on later runs (no re-embedding the whole corpus) - Queries are ranked by brute-force cosine similarity against the stored vectors; an approximate-nearest-neighbor index (e.g. `sqlite-vec`) is the next step if that becomes a bottleneck at scale - Its ranking is fused with the keyword index's by rank (reciprocal rank fusion), since BM25 and cosine scores aren't on one scale **Full-scan mode**: Below 10K facts, shmem scores all facts directly rather than using the capped index lookup. This is faster and more accurate for small datasets. ### Multi-index fusion When you query `recall_memory`, shmem runs the enabled indexes and merges results: 1. Keyword index returns BM25-ranked matches 2. Temporal index returns recency-scored facts 3. Embedding index (if enabled) returns similarity-ranked facts 4. Results are deduplicated and ranked by combined score 5. Token budget packing selects the highest-scoring facts that fit within the budget Multi-hop questions, which span several topics, are the hardest case: the facts that answer them often share no keywords with each other, so no single index ranks them all highly. ## Question-answering pipeline `ask_memory` goes beyond raw retrieval. It runs a full question-answering pipeline: ### 1. Question classification The question is classified into one of five types: | Type | Example | Strategy | |------|---------|----------| | **Temporal** | "When did we fix the auth bug?" | Chain-of-thought with date reasoning | | **Aggregative** | "How many times have we discussed caching?" | Additive counting across sessions | | **Knowledge-update** | "What's our current API rate limit?" | Most recent information wins | | **Preference** | "What testing framework do I prefer?" | Identify patterns in preferences | | **Default** | "What approach did we use for pagination?" | Direct answer from context | ### 2. Fact retrieval Multi-index retrieval finds the most relevant facts for the question. ### 3. Context formatting Facts are grouped by date and session, with timestamps: ``` === 2025/02/12 === --- Conversation at 17:50 (claude-code) --- [17:50] [user] Let's go with JWT for auth. [17:51] [llm] Good choice. Short-lived access tokens with refresh... === 2025/02/14 === --- Conversation at 09:15 (claude-code) --- [09:15] [user] What about rate limiting on the JWT endpoint? ``` Sessions are detected automatically: a gap of 30+ minutes between facts starts a new session. ### 4. Answer generation A type-specific prompt is built and sent to the LLM. Temporal questions get chain-of-thought reasoning. Aggregative questions are told to count across sessions. Knowledge-update questions focus on the most recent information. ### 5. Answer extraction The raw LLM response is parsed to extract a clean answer — stripping chain-of-thought reasoning, removing preambles, and cleaning up formatting. ## Performance Retrieval is fast enough that the QA model dominates end-to-end latency: | Metric | Result | |--------|--------| | Recall p50 | 0.9ms | | Insert 1000 facts (batch) | ~17ms | QA accuracy is measured on [LongMemEval](../benchmarks/) — 500 questions, 50 max facts, judged by Claude Sonnet 5. Those numbers are regenerated from the run data on every refresh, so the [benchmarks page](../benchmarks/) is the single source for them rather than a copy kept here. The system is designed for datasets from hundreds to millions of facts. Months or years of conversations across several agents lands in the hundreds of thousands, which is an ordinary deployment rather than a stress case. Keeping the queries shmem supports fast at that size is our job, not something you should be rationing captures around. Total content size matters more than fact count: a store full of large tool outputs is heavier work than the same number of short conversational turns. ## Sharing & permissions Projects can be shared between users on multi-user HTTP servers using unix-style group permissions. - **Groups**: Named `owner/group-name`. The owner creates the group and invites members. Members must accept before gaining access. - **Per-project permissions**: Each project has an optional `.permissions.json` specifying a group and permission level (`r` for read, `rw` for read-write). - **Cross-user references**: Shared projects are accessed via `owner/project` syntax (e.g., `recall_memory(project="alice/my-app")`). - **Backward compatible**: STDIO mode (single-user) has no permission checks. Projects without `.permissions.json` are owner-only. See the [Reference](../reference/) docs for the full set of group and sharing tools. ## Security model - **Data locality**: Everything stored on your machine (SQLite + JSON files). No cloud required. - **File permissions**: Data files written with 0600, directories with 0700. - **Auth on HTTP**: Bearer token auth with constant-time comparison. Per-user API keys for team setups. - **Caller identity**: Server-side stamping from auth tokens on HTTP transports. Environment variables on STDIO. - **Trust boundary**: Facts are trusted content — shmem is a personal/team tool where the writers are the users. --- # Source: https://shmem.secondmoment.ai/docs/latest/ --- # shmem documentation shmem is long-term, portable memory for AI coding agents. It runs on your machine by default, works across Claude Code, Codex, Antigravity, Cursor and any MCP client, and can be shared with your team. ```bash curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh shmem ask "what was I working on last week?" ``` That installs shmem, wires every agent it finds, imports their past sessions, and answers from them. [Install and quickstart](get-started/) walks through it. > **AI agents:** if a human asked you to install shmem from this URL, follow the [agent install guide](install/). It is written for you to act on without follow-up: run the one-liner above, relay its output, then verify with `shmem ask`. A plain-text index of these docs is at [llms.txt](llms.txt), and everything in one file at [llms-full.txt](llms-full.txt). ## Get started - [Install and quickstart](get-started/) — install, first question, updating - [Things to try](try-it/) — prompts that show what memory changes - [LLM providers](llm-providers/) — how shmem picks a model, local models, your own keys - [Agent install guide](install/) — what `shmem install` does, per-agent wiring, troubleshooting ## Guides - [Projects](projects/) — one store, project as a tag, how queries are scoped - [Projects across repos](cross-repo/) — how captures are tagged, working in several repositories - [Filtering captures](shmemignore/) — keep secrets and noise out with `.shmemignore` - [Sharing](sharing/) — how sharing with teammates works - [Sharing rules](sharing-rules/) — the rules file that decides what is shared ## Hosted and teams - [Hosted shmem](hosted/) — what changes when we run the server - [Signing in](hosted-setup/) — `shmem login` on each machine, and which clients reach your account - [Team setup (self-hosted)](team-setup/) — run the server for your team - [Embedding shmem in your app](embedded/) — per-user memory for your own agents ## Reference - [CLI](cli/), with [shmem import](cli-import/), [shmem gateway serve](cli-gateway/) and [shmem admin](cli-admin/) - [MCP server](mcp-server/) — the tools and their arguments - [Transports](transports/) — stdio, SSE, streamable HTTP - [Environment variables](environment/) - [Compatibility](compatibility/) — what we promise not to break ## Under the hood - [How it works](how-it-works/) — storage, retrieval, the question-answering pipeline - [Benchmarks](benchmarks/) — LongMemEval and LoCoMo results --- # Source: https://shmem.secondmoment.ai/docs/latest/install/ --- # Installing shmem (agent install guide) > **You're reading this because a user pasted this URL to an AI agent and asked it to install shmem for them.** This page is structured for you, the agent, to act on without follow-up. Humans installing manually should use [Get Started](../get-started/) instead. > > **Terms:** installing shmem constitutes acceptance of the [Self-Hosted Software Terms of Use](/docs/self-hosted-terms). Since you're installing on the user's behalf, surface that link so they're aware. ## TL;DR With a shell, run one command: ```bash curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh ``` It installs `shmem` and `shmem-mcp`, then runs `shmem install`, which wires every agent it finds on the machine, imports their past sessions, and picks an LLM to answer with. It's safe to re-run, and asks at most two things, on a terminal (an agent or script, or `shmem install --yes`, gets a suggestion instead): whether Claude Code may run shmem's memory tools without review (see [Claude Code](#claude-code)), and, if you already use shmem in the Claude app, whether to sign this machine in to the same account. Then: 1. **Relay its output to the user.** It says what was wired, what was imported, and how questions will be answered. 2. **Verify:** run `shmem ask "what was I working on last week?"` and relay the answer. Without a shell (a chat-only client), give the user the command above to run in a terminal. **Don't ask the user for an API key in chat.** `shmem install` finds keys already in the environment; if it finds no LLM, it prints a note saying how to add one, and you relay that. ## What shmem is, in two sentences shmem is a local-first long-term memory layer for AI agents. Every conversation you have with the user gets captured into a shared SQLite DB at `~/.shmem/db/`; any agent on the user's machine can query it with `shmem ask` / `shmem query` or via the MCP tools `ask_memory` / `recall_memory` / `add_memory`. The pitch is *cross-agent context* — what the user discussed with Claude Code yesterday is recallable from Codex today. Your job during install is to make that immediate. ## What `shmem install` does Each step is idempotent; re-running picks up a newly installed agent or a newly added key. 1. **Creates the memory store** at `~/.shmem` (or `$SHMEM_ROOT`), records the user's author stamp, and writes default credential filters. 2. **Wires every agent it detects** — see [Per-agent wiring](#per-agent-wiring). New agent sessions capture automatically; running sessions pick it up when restarted. 3. **Imports past agent sessions** from Claude Code, Codex, Cursor, Cline, and OpenCode, with a progress line per source. Imports are local parse-and-insert: no network, no LLM calls. A ChatGPT export or GitHub history it finds is only pointed at (`shmem import --from chatgpt` / `--from github`), since importing those is the user's choice. 4. **Finds an LLM for answering questions**, in this order: 1. an existing `SHMEM_QA_PROVIDER` setting 2. an API key in the environment: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `OPENROUTER_API_KEY` 3. Claude Code's own Bedrock or Vertex settings (`CLAUDE_CODE_USE_BEDROCK` / `CLAUDE_CODE_USE_VERTEX`) 4. a signed-in Claude Code or Codex CLI, used headlessly (`claude -p` / `codex exec`). Install says so: each answer uses the user's plan and takes a few seconds, and an API key is faster. 5. only when none of those exists and the machine doesn't sync with a hosted server: a running Ollama with a model pulled. Install warns that local answers are slower and noticeably worse; relay that line. With none of these, install prints a note saying how to add a key, an agent sign-in, or a local model, and still exits 0: capture works without an LLM, only answers wait. Flags, for when you need them: ```bash shmem install --for codex-cli # wire one agent only: claude-code | codex-cli | antigravity | opencode shmem install --provider anthropic # skip LLM detection shmem install --no-import # skip importing past sessions shmem install --allow-memory-tools # Claude Code: let auto mode run the memory tools (=no removes the rules) ``` Install honors `SHMEM_ROOT` for its data, `CLAUDE_CONFIG_DIR` for Claude Code's config directory, `CODEX_HOME` for Codex's, and `XDG_CONFIG_HOME` for OpenCode's. A custom `SHMEM_ROOT` is written into each agent's hooks and memory tools as a default, so agents use it without the variable set in their environment. A session that sets its own `SHMEM_ROOT` overrides it for both. ### Already installed? Run the one-liner anyway, or just `shmem install` — it re-wires idempotently and only imports sessions it hasn't seen. To check state without changing anything: `shmem status --json` reports `installed`, `configured_hosts`, `qa_provider`, and `fact_count`. ## Answering without an LLM `shmem ask` (and the `ask_memory` MCP tool) always returns a synthesized answer or a reason, never raw facts. With no local LLM, ask uses the hosted server's QA when a remote is configured; otherwise it fails with the same note install printed. Relay that note to the user rather than working around it. ## Per-agent wiring ### Claude Code Merges `UserPromptSubmit` / `PostToolUse` / `Stop` hooks into `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`), each tagged `--caller-agent claude-code`, registers the `shmem-mcp` server at user scope (through `claude mcp add-json --scope user` when `claude` is on `PATH`, otherwise in `~/.claude.json`), and adds a short memory section to the user-level `CLAUDE.md` so Claude reaches for `ask_memory` / `recall_memory`. A `shmem` server entry that doesn't run `shmem-mcp` (a hosted URL, say) is left as it is. **Auto mode and the allow rule.** In Claude Code's auto permission mode, a safety classifier reviews every tool call that no `permissions.allow` rule covers. It judges calls one at a time, so it can refuse one memory save among several alike, even one the user asked for. Install asks once, on a terminal, whether to allow shmem's memory tools. A yes adds `permissions.allow` rules to `~/.claude/settings.json` for reading and adding memory (`mcp__shmem__ask_memory`, `recall_memory`, `add_memory` and the other read tools, and `Bash(shmem ask:*)`, `Bash(shmem query:*)`, `Bash(shmem add:*)` for the shell fallback). Deleting memory and the sharing, group and project tools stay under review, since they remove facts or publish them to other people. shmem records the rules it wrote: `shmem install --allow-memory-tools=no` removes those and no others, and a rule you remove yourself stays removed. Run by an agent, install can't ask, and prints a note instead. Relay it: ask the user whether to allow the memory tools, and on a yes run `shmem install --allow-memory-tools`. To allow them by hand, add `"mcp__shmem"` (every tool of the server) or the individual tool names to `permissions.allow`. ### Codex CLI Writes the same three hooks to `~/.codex/hooks.json` (or `$CODEX_HOME/hooks.json`), sets `[features] hooks = true` in `config.toml` (Codex only runs hooks with this flag), registers `shmem-mcp` under `[mcp_servers.shmem]` there, and appends the memory section to `AGENTS.md`. ### Antigravity Covers the `agy` CLI and the Antigravity app and IDE, which share `~/.gemini/config/`. Adds a `shmem` entry to `~/.gemini/config/hooks.json` with one `Stop` hook. Antigravity has no prompt-submit or after-agent event, so at the end of each turn the hook reads the conversation transcript Antigravity points it at and saves both the prompt and the reply. Install also registers `shmem-mcp` under `mcpServers` in `~/.gemini/config/mcp_config.json` and appends the memory section to `~/.gemini/AGENTS.md`, a global rules file every Antigravity surface loads. `--for agy` works as an alias. ### OpenCode Registers the `shmem-mcp` server and the `shmem-opencode` capture plugin in `~/.config/opencode/opencode.json`. OpenCode installs the plugin from npm on next startup. Writes the memory primer to `~/.config/opencode/shmem.md` and lists it under `instructions` in the same file, so OpenCode tells the agent when to call `ask_memory` (without it, the plugin would capture every turn but the agent would have no nudge to read memory back). shmem rewrites that file on every install, so put your own instructions elsewhere. It is an instructions entry rather than a section in a global `AGENTS.md` because OpenCode 1.x stops reading `~/.claude/CLAUDE.md` once a global `AGENTS.md` exists. ### Cowork Cowork sessions run in a sandboxed ARM64 Linux environment. The working architecture uses the shmem CLI binary directly — not an MCP server daemon. 1. **Install the shmem binary** in the sandbox: ```bash # Inside a Cowork session ARCH=linux_arm64 VERSION=$(curl -s https://api.github.com/repos/second-moment-ai/homebrew-tap/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name"[[:space:]]*:[[:space:]]*"v\([^"]*\)".*/\1/') curl -fsSL "https://github.com/second-moment-ai/homebrew-tap/releases/download/v${VERSION}/shmem_${VERSION}_${ARCH}.tar.gz" \ | tar -xz -C ~/.local/bin shmem ``` 2. **`~/.shmem` is FUSE-mounted** — Cowork bridges `~/.shmem` to the Mac's real `~/.shmem/`. The Mac-side shmem process handles remote sync; the sandbox does not push directly. 3. **Set caller identity per invocation** so sandbox writes are attributable: ```bash export SHMEM_CALLER_USER=alice@cowork-sandbox export SHMEM_CALLER_AGENT=cowork shmem ask "what were we working on?" ``` 4. **Hooks are not wired** — auto-capture does not work in the Cowork sandbox (hook isolation). Memory operations are explicit CLI calls (`shmem ask`, `shmem add`, `shmem query`). **Known limitation:** `shmem push` fails from the sandbox because FUSE cannot service SQLite's schema-init transaction (`disk I/O error 2570`). This is benign — the Mac side handles the push. ### Cursor No automated wiring yet. Tell the user: *"Cursor doesn't have a public hooks API I can configure automatically. To wire shmem in, open Cursor Settings → MCP and add a new server with this command: `shmem-mcp`. After that, Cursor's agent will be able to call `ask_memory` / `recall_memory` / `add_memory`."* (`shmem install` still imports past Cursor chats.) ### nanoclaw / OpenClaw / other self-hosted agent harnesses These are container-based. Add `shmem-mcp` to the agent group's MCP config — specifics depend on the harness, so ask the user to point you at their fork's structure. There are two topologies. **Prefer the second.** **A. shmem inside the container.** Install the matching Linux release in the container image (do *not* mount a macOS host binary in — it will fail with `exec format error`), and mount `~/.shmem/db/` read-write so the agent can read and write. **B. shmem on the host, reached over HTTP.** Run one `shmem-mcp --transport streamable-http` on the host and point every container at it. No binary in the image, no mount, no architecture matching, and one long-running server amortizes the per-process index build instead of paying it every invocation. If you take B, three things bite in practice: - **Use `host.docker.internal:8705`, not the Docker bridge IP.** Harnesses increasingly reject plain-HTTP MCP URLs except for `localhost` and `host.docker.internal`, and a stored `http://172.17.0.1:8705/mcp` gets dropped at container spawn — usually with the MCP server silently removed rather than an error the user sees. - **Add it to `NO_PROXY`.** Any proxy that injects an `Authorization` header on outbound requests will overwrite shmem's bearer token, producing a `401 invalid token` that looks exactly like a bad key. - **Both failures look identical to the agent** — "no memory tools" or an empty result. Verify from inside the container before believing either: ```bash curl -sS -X POST http://host.docker.internal:8705/mcp \ -H "Authorization: Bearer " \ -H 'Content-Type: application/json' \ -H 'Accept: application/json, text/event-stream' \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"probe","version":"1"}}}' ``` A `200` with an `initialize` result means the path is good. `401` means something is rewriting the header — retry with `--noproxy '*'` to confirm it's the proxy. Keep the container's `shmem-mcp` and the host's `shmem` on the same release. ### Anything else `shmem install --for ` names the hosts it can wire and errors for others. If the host speaks MCP, register `shmem-mcp` (stdio) as a server in its config. If it doesn't, tell the user shmem doesn't auto-wire it yet and offer to file an integration request. ## Installing the binary another way The install script detects OS and architecture, downloads the latest release from the public `homebrew-tap` repo, and installs to `~/.local/bin` when that's on `$PATH` (otherwise `/usr/local/bin`, with sudo). Overrides: `SHMEM_INSTALL_DIR=...`, `SHMEM_NO_SUDO=1`, `SHMEM_VERSION=vX.Y.Z`, and `SHMEM_NO_SETUP=1` to install the binaries without running `shmem install`. **Manual tarball (any platform, including Windows):** download `shmem___.tar.gz` from `https://github.com/second-moment-ai/homebrew-tap/releases` (`darwin_amd64`, `darwin_arm64`, `linux_amd64`, `linux_arm64`, `windows_amd64`), put `shmem` and `shmem-mcp` on `$PATH`, and run `shmem install`. Stripped containers sometimes lack `curl`/`wget` or `tar`; install them first (`apt-get install -y curl`, `apk add curl`, `dnf install -y curl`). ## Signing in: only when the user asks Memory stays on this machine until the user signs in to a shmem account; then it syncs with the account, their other machines, and the Claude app. **Offer sign-in only when the user asks for it or agrees to it.** Install's output ends by mentioning `shmem login`; relay that, and don't run it unprompted. The exception is when install says the user already has an account (it saw a shmem connector in the Claude app): then ask whether to sign this machine in. **Use shmem's MCP `login` tool first.** Install registers shmem's local MCP server, and its `login` tool runs the sign-in: 1. Call `login`. It starts sign-in, opens the browser where there is one, and waits up to 45 seconds. Usually the user finishes in time and it returns the result lines (`✓ signed in as …`, what uploaded or arrived): relay them. 2. If it returns the link instead (the user hasn't finished, or no browser opened), show the user the link, then call `login` again to keep waiting. 3. **Over SSH or with no browser**, the first call returns the link at once. Ask the user to open it on any computer and paste back the code the page shows, then call `login` with `code` set to it. 4. If the tool returns a question (switching to another account), put it to the user and call again with `switch_account` set to their answer: `true` for yes, `false` for no. 5. On a first sign-in to an account, the result lists this machine's projects and asks which sync with the account. None sync until the user answers: put the list and the question to them, and don't pick for them. Then call `login` with `sync` set to `all` or `none`, or `sync_projects` set to the projects they chose. The others stay on this machine only, now and later. The upload and catch-up keep running in the background after the tool returns, so the agent session can end. **Shell fallback.** If the MCP tools aren't available yet (an install that just registered the server may need the agent session restarted before they appear), run `shmem login` in the background, or with the longest timeout your shell tool allows: it waits up to 10 minutes for the browser. Relay the link it prints right away, then relay its result lines when it finishes. With no terminal to ask on, a first sign-in syncs none of the machine's projects and lists them. Ask the user which should sync, then run `shmem login --sync-project ` (repeatable), or `shmem login --sync all`; the signed-in machine takes the answer without signing in again. Over SSH, `shmem login` reads the code from the terminal, which a backgrounded command can't do; ask the user to run `shmem login` in their own terminal, or restart the session so the `login` tool is available. **The new-machine recipe.** When the user says something like *"set up shmem, I already use it on my laptop"*: run the install one-liner, relay its output, then sign in with the `login` tool (or the fallback) as above. The user already asked, so don't ask again. Sign-in downloads the last 30 days right away and older memories in the background. Then verify with `ask_memory` (or `shmem ask "what was I working on last week?"`) and relay the answer: it should know what they did on the other machine. Other servers: the `login` tool signs in only to this machine's own server. For a self-hosted or company server, ask the user to run `shmem login --remote ` in their own terminal. If the server has no sign-in, its operator issues a token: `shmem login --remote --token `, which the user runs themselves. Don't ask for tokens in chat. ## Troubleshooting ### `shmem: command not found` after install The binary went somewhere not on `$PATH` — the script says so and prints the `export PATH=...` line to add. Setup still ran; hooks use the absolute path. If neither `~/.local/bin/shmem` nor `/usr/local/bin/shmem` exists, retry with tracing: `curl -fsSL https://shmem.secondmoment.ai/docs/install.sh | sh -x`, and look for the first non-zero exit. ### An agent wasn't detected Install detects an agent by its config directory or its binary on `$PATH`. If the agent was installed after shmem, re-run `shmem install`. To force one: `shmem install --for `. ### Hooks not firing (Cowork specifically) Cowork isolates `~/.claude/settings.json` per session, so the hooks shmem writes don't get picked up. Tell the user to use the MCP tools (`ask_memory` / `add_memory`) explicitly instead of expecting auto-capture. ### `~/.codex/config.toml` got reformatted Codex's hook install round-trips `config.toml` through a TOML library, which strips comments and may reorder sections. Values are preserved. If the user had hand-written comments they care about, tell them they're gone and suggest their dotfiles backups. ### Captures show the wrong `caller_agent` Re-run `shmem install`, which bakes `--caller-agent ` into each hook command, and remove any `SHMEM_CALLER_AGENT=` line from `~/.shmem/.env`: the label belongs to each tool, not the machine. ### Anything else Check `~/.shmem/.env` for the config that's loaded and `shmem admin status` for what shmem thinks its state is. If you can't recover, tell the user what you tried, what you saw, and the `shmem admin status` output, and stop. Don't pretend it worked. ## What this guide does NOT cover - **Hosted accounts and the Claude app.** See [Hosted](../hosted/) and [The Claude app](../claude-app/). - **Per-repo projects.** `shmem init` inside a repo gives it its own project tag (it writes `.shmem/project` and nothing else); it isn't part of getting started. See [Projects](../projects/). - **Removing shmem** (`rm -rf ~/.local/bin/shmem ~/.local/bin/shmem-mcp ~/.shmem/`). If the user changes their mind, point them at this; don't auto-uninstall. --- # Source: https://shmem.secondmoment.ai/docs/latest/llm-providers/ --- # LLM providers shmem needs an LLM for QA synthesis (generating grounded answers). Capture works without one; only `shmem ask` needs it. ## How `shmem install` picks one It takes the first of these it finds, records it in `~/.shmem/.env`, and says which on its `✓ answers via …` line: 1. an existing `SHMEM_QA_PROVIDER` setting 2. an API key in your environment: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `OPENROUTER_API_KEY` (or their `SHMEM_`-prefixed forms) 3. Claude Code's own cloud settings: `CLAUDE_CODE_USE_BEDROCK=1` → Bedrock, `CLAUDE_CODE_USE_VERTEX=1` with `ANTHROPIC_VERTEX_PROJECT_ID` → Claude on Vertex AI 4. a signed-in Claude Code or Codex CLI, used headlessly — see `claude-cli` / `codex-cli` below 5. only when none of the above exists and this machine doesn't sync with a hosted server: a running Ollama with a model pulled (shmem's default `qwen2.5:1.5b` if present, otherwise the first non-embedding model). Install warns that local answers are slower and weaker — see `ollama` below If none is found, install prints a note instead, and `shmem ask` shows the same note until you add one. You don't need to run install again afterwards: when nothing is configured, `shmem ask` (and the `ask_memory` MCP tool) runs the same search and saves what it finds to `~/.shmem/.env`. ``` shmem needs an LLM to answer questions, and found none on this machine. Memories are saved either way; answers start working once you add one: - an API key: add ANTHROPIC_API_KEY=... (or OPENAI_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY) to ~/.shmem/.env - or sign in to Claude Code or Codex, and shmem will answer through it - or, to keep everything on this machine, a local model: install Ollama and run `ollama pull qwen2.5:1.5b`. On most laptops its answers are slow and noticeably worse than the options above. shmem picks it up the next time you ask. ``` With no API key or agent sign-in but a [hosted remote](../hosted-setup/) configured, `shmem ask` (and the `ask_memory` MCP tool) answers through the hosted server's QA instead of a local Ollama. To choose explicitly: `shmem install --provider `, or set `SHMEM_QA_PROVIDER` in `~/.shmem/.env`. ## Provider details **anthropic** — Best answer quality (94% on LongMemEval with Sonnet 4). Get a key at [console.anthropic.com](https://console.anthropic.com) and add `ANTHROPIC_API_KEY=sk-ant-...` to `~/.shmem/.env`. **openai** — OpenAI API, or any OpenAI-compatible service (Together AI, Groq, Fireworks). Set `SHMEM_OPENAI_BASE_URL` for non-OpenAI hosts: ```bash # OpenAI directly SHMEM_QA_PROVIDER=openai SHMEM_QA_MODEL=gpt-5.6-terra # Together AI (open-weight models) SHMEM_QA_PROVIDER=openai SHMEM_OPENAI_BASE_URL=https://api.together.xyz/v1 \ OPENAI_API_KEY=$TOGETHER_API_KEY SHMEM_QA_MODEL=meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 ``` **gemini** — Google Gemini API. Requires an API key from [aistudio.google.com](https://aistudio.google.com). **claude-cli** / **codex-cli** — No API key needed: shmem asks your signed-in Claude Code (`claude -p`, Haiku by default) or Codex (`codex exec`) headlessly, with the agent's hooks, MCP servers and tools turned off so the question isn't itself captured. Each answer uses your agent plan and takes a few seconds; an API key is faster. `shmem install` picks one only when no API key is set, and says so. These providers need network access from the command running shmem. Inside a Codex command sandbox that marks its network as off (`CODEX_SANDBOX_NETWORK_DISABLED=1`), shmem still tries the agent, since an allowlisted sandbox can reach it; if the call fails the way a cut-off network does, `shmem ask` says so. Run the question from a regular terminal outside that session, or add an API key to `~/.shmem/.env` and run `shmem install --provider openai` (or `anthropic`, `gemini`, `openrouter`) in an environment with network access. An API key does not bypass sandbox network restrictions. Installation warns that answers may fail when it selects or keeps an agent-CLI provider in that sandbox. **ollama** — Free, fully private, runs on your hardware, at a cost in quality: the models a typical laptop can run answer slowly and noticeably worse than the cloud options above, so choose it when keeping everything on the machine matters more. A GPU with room for a larger model narrows the gap. Requires [Ollama](https://ollama.ai) — install from [ollama.ai/download](https://ollama.ai/download) or `curl -fsSL https://ollama.com/install.sh | sh` on Linux: ```bash ollama pull qwen2.5:1.5b ``` With the daemon running, `shmem install --provider ollama` configures it (or plain `shmem install`, when nothing else is available). **mock** — No LLM at all. `recall_memory` / `shmem query` still work for keyword search, but `ask` will not synthesize answers. --- # Source: https://shmem.secondmoment.ai/docs/latest/mcp-server/ --- # MCP server `shmem-mcp` exposes the same memory system to MCP clients. Sixteen tools split into core operations, project management, and multi-user group/sharing primitives. ## recall_memory Use when you need raw facts from past conversations — e.g. scanning recent entries, finding specific decisions, or building context for a task. Returns timestamped facts ranked by relevance. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `query` | string | yes | Natural language search query | | `max_facts` | int | no | Maximum facts to return | | `token_budget` | int | no | Maximum tokens to return; uses greedy packing (default: 8000) | | `max_fact_tokens` | int | no | Maximum tokens per fact before truncation (default: 500) | | `since` | string | no | Only include facts after this time (RFC3339 or relative: `1h`, `30m`, `7d`, `2w`) | | `before` | string | no | Only include facts before this time (RFC3339 or relative) | | `caller_user` | string | no | Filter by user (e.g. "alice@macbook") | | `caller_agent` | string | no | Filter by agent (e.g. "claude-code") | | `project` | string | no | Project name or cross-user reference like "alice/my-app". When omitted, uses the effective-project default (see below). | | `metadata` | object | no | Only include facts whose metadata matches, e.g. `{"branch": "dev", "thread": ["t1", "t2"]}` (see [Metadata filters](#metadata-filters)) | **Effective project defaulting** (matches `shmem ask` / `shmem query`): when `project` is omitted, `shmem-mcp` resolves the effective project in this order — `.shmem/project` marker walking up from the server's cwd → `SHMEM_DEFAULT_PROJECT` env → none. If retrieval scoped to the resolved project returns zero facts, it auto-broadens to all projects and prepends `(no facts in project= — broadened to all projects)` to the response so the calling agent can surface that to its user. Set `SHMEM_DEFAULT_PROJECT=ALL` in the server's env to disable the auto-default entirely. Any project scope, explicit or resolved, also includes your account-wide memory: your own memories with no project, such as what the Claude app saves (see [Projects](../projects/)). Reading another user's project never includes theirs. Uses multi-index retrieval (keyword BM25 + temporal recency, plus an opt-in dense-embedding index). ## ask_memory Use when the user asks about past work, decisions, or conversations. Retrieves relevant facts and generates a grounded answer. Preferred over `recall_memory` for most questions. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `question` | string | yes | Natural language question | | `now` | string | no | Override current time for temporal reasoning (RFC3339 or `YYYY/MM/DD`) | | `caller_user` | string | no | Filter context by user | | `caller_agent` | string | no | Filter context by agent | | `project` | string | no | Project name or cross-user reference. When omitted, uses the effective-project default — same shape as `recall_memory`. | | `metadata` | object | no | Only draw the answer from facts whose metadata matches — same shape as `recall_memory`. | The pipeline classifies the question type, extracts time filters, retrieves via multi-index search, formats context with timestamps and session grouping, runs a type-specific prompt, and returns a clean answer. The answer cites the facts it relies on with inline markers like `[1]`, and the text result ends with a Sources list giving each cited fact's title, date, project, repository (or the teammate it came from) and full fact id, so an agent can preview one with `share_show` (client code can fetch it with `get_facts`). The structured result carries the same as `{"answer", "citations": [{"n", "fact_id", "title", "created", "project", "repo", "from"}]}`. No Sources list is added when nothing is cited. With no LLM configured on a local server, `ask_memory` answers through the default remote's QA when one is configured, and otherwise returns an error with setup instructions — never unsynthesized facts. ## Metadata filters Facts can carry metadata: string key/value pairs set when they are written (the `metadata` field of `add_memory` and `add_memory_batch`), such as a branch or thread id. Only keys named under `shared.` (such as `shared.branch`) go with a fact shared to another account; the rest stay with the writer (see [Sharing](../sharing/)). `recall_memory`, `ask_memory`, `list_facts_since`, `shmem query` and `shmem ask` can restrict a read to facts whose metadata matches: - Each key's value is one string, or a list of strings of which any may match. On the command line, repeat `--meta` with the same key for "any of". - Different keys must all match. A fact that lacks a key does not match it. - Keys you leave out don't constrain anything, so `{"branch": "dev"}` reads every thread on that branch. [Provenance stamps](../how-it-works/#provenance-stamps) work as filter keys, which narrows a read to where facts were captured: ```bash shmem ask "why did we cap retries?" --meta stamp_repo=github.com/acme/billing shmem query "migration" --meta stamp_branch=fix/retries shmem query "flaky test" --meta stamp_cloud=claude-code-cloud ``` The MCP equivalent is `{"stamp_repo": "github.com/acme/billing"}` in the `metadata` argument of `recall_memory`, `ask_memory` or `list_facts_since`. Stamps are private to their owner, so these filters match your own facts only: facts you received from a teammate carry no stamps, and in another user's project a filter on a `stamp_*` key matches nothing. The filter is applied inside each index, before results are ranked and cut, so a narrow filter returns the best matching facts rather than whatever matching facts happened to make the overall top results. It is a filter the caller chooses, not an access control: a caller that omits it reads everything its permissions allow. In another account's project a filter can only use keys readers there can see (see [Sharing](../sharing/)); a filter on any other key matches nothing, so it can't reveal values kept private. Auto-broaden also applies: a question that returns zero facts under the auto-default project triggers a second pipeline run against all projects, with the broaden note prepended to the answer. ## list_facts_since Returns the facts written after a timestamp, oldest first, as structured content for client code: a time-ordered feed rather than a search. Hosted sync pulls other machines' writes with it. To answer a question, use `ask_memory` or `recall_memory`. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `since` | string | yes | RFC3339 timestamp; returns facts strictly after it | | `limit` | int | no | Maximum facts per page (default 1000, max 5000) | | `project` | string | no | Only facts in this project; empty means all of the caller's projects | | `metadata` | object | no | Only facts whose metadata matches — same shape as `recall_memory` (see [Metadata filters](#metadata-filters)) | The response holds `facts`, `has_more`, and `next_since`. Pass `next_since` as the next call's `since` to read the following page. Filters apply before `limit`, so each page and its cursor cover matching facts only. On an authenticated server, an account that holds no memory at all gets, from `ask_memory` and `recall_memory`: "This shmem account has no memory yet. Memory comes from your coding agents: install shmem on your computer (``) and sign in with this same email." The install URL is `SHMEM_INSTALL_URL`, or the published install guide. ## add_memory Preserve information across sessions. Usually saved automatically by hooks; call directly only when the user explicitly asks to remember something. Facts are atomic: store one self-contained statement per call, with the names and keywords it should be found by. Retrieval is keyword-based (BM25), so an entity buried mid-paragraph in a multi-fact blob becomes unfindable — the write succeeds, but reads quietly miss. Never concatenate several facts into one write; split them into separate calls, or use `add_memory_batch` with one fact per entry. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `content` | string | yes | One atomic fact — a single self-contained statement (max 1MB) | | `source` | string | no | Origin: "user", "llm", or "tool" (default: "user") | | `project` | string | no | Project name or cross-user reference | | `app_project` | string | no | The Claude app project the conversation belongs to, when the agent is working inside one; recorded as `stamp_app_project` | Caller identity is stamped automatically from the auth token (HTTP) or environment variables (stdio), along with the [provenance stamps](../how-it-works/#provenance-stamps) the server can vouch for. Content is filtered through `.shmemignore` rules before storage. ## delete_memory Use when the user asks to forget something or correct stored information. Find fact IDs with `recall_memory` first. For a local agent, a fact in a shared space is first retracted from every space you can write to, so its readers drop their copies on their next sync. A fact still held by a space you can only read is kept, and the space's owner has to remove it. Retraction removes the fact itself, not what readers already learned from it. On an authenticated hosted server, the server retracts the fact from every shared project of yours that holds it, and a grantee's delete retracts it from the one space their grant reaches. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `fact_ids` | string[] | yes | List of fact IDs to delete | | `project` | string | no | Project name | ## get_stats Fact count, index sizes, storage details, operation counts. No parameters. ## list_sources Breakdown by source type (user, llm, tool). No parameters. ## list_projects Available projects with fact counts, descriptions, and a marker for the current project. No parameters. ## current_project The active project name and path for this session. No parameters. ## login Signs this machine in to a shmem account: the agent's way to run `shmem login`. **Local (stdio) server only**; the hosted server doesn't list it, since a connector signs in through its own OAuth. Call it only when the user asks to sign in or agrees to it. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `server` | string | no | This machine's server; any other server needs `shmem login --remote ` typed by the user | | `code` | string | no | The sign-in code the user pasted back, when signing in without a browser on this machine (SSH) | | `switch_account` | bool | no | The user's answer to switching accounts: `true` to switch, `false` to stay (ends the new sign-in) | The first call starts sign-in, opens the browser where there is one, and waits up to 45 seconds: it returns the result lines, or the link to show the user before calling again. Over SSH it returns the link at once; ask the user for the code the page shows and call again with `code`. A question the user must answer (switching account, or which of the machine's projects sync at a first sign-in) comes back as text to ask, never as a default yes. None of the machine's projects sync until the user answers. With no arguments on a machine already signed in, it says who you're signed in as. The upload of the projects the user chose and the catch-up run in the background, so they finish even if the agent session ends. ## whoami The account identity your token authenticates as on this server. No parameters. This is the canonical identity that owns your facts and that every share is authorized against. It is not necessarily the same string as your local `SHMEM_CALLER_USER` author stamp — see [Author stamp vs. account identity](#author-stamp-vs-account-identity). ## Group & sharing tools (multi-user HTTP only) These tools are available on multi-user HTTP servers (authenticated via bearer tokens). They enable unix-style project sharing: create groups, invite collaborators, grant read or read-write access to projects. A local `shmem-mcp` relays the group and project-grant tools, `create_group` through `list_shared_projects`, to your remote, so they work from an agent's local server once you've run `shmem login`. It relays `create_project` too, and keeps a local copy of the project; with no remote, `create_project` creates the project locally. | Tool | Purpose | |------|---------| | `create_group` | Create a new group (you become the owner; created as `/name`) | | `delete_group` | Delete a group you own | | `invite_to_group` | Invite a user to a group you own | | `accept_invitation` | Accept a pending invitation | | `list_groups` | List groups you own, belong to, and pending invitations | | `members_of_group` | List members of a group you own or belong to; `names: true` returns JSON with display names | | `people` | Display names of you and the people in your groups (JSON) | | `share_project` | Grant a group `r` or `rw` access to one of your projects | | `unshare_project` | Revoke group access from a project; its readers drop their copies on their next sync | | `list_shared_projects` | List projects others have shared with you | | `create_project` | Register a project tag in your data root (config dir for per-tag `.shmemignore`), e.g. before sharing it | | `delete_project` | Permanently delete every fact tagged with the project from your data (irreversible). A deleted fact that is also in another of your shared projects is retracted from it first | | `rename_project` | Rename a project tag — UPDATEs every matching fact in your data | | `project_info` | Show fact count and sharing info for one of your projects | | `get_share_rules` | Read your share rules as text, with a version for editing | | `set_share_rules` | Replace your share rules; refused if they changed since the version you read | | `get_ignore_rules` | Read your account's `.shmemignore` files (global and per project), each with a version. Hosted servers, for accounts with their own data root | | `set_ignore_rules` | Replace one of your account's `.shmemignore` files; refused if it changed since the version you read. Hosted servers, for accounts with their own data root | | `share_updates` | What your share scans produced since you last checked: auto-shares to announce and new nominations to offer. Each is returned once | | `discard_nomination` | Turn a nomination down for good: recorded privately, and the same facts are never nominated again | | `forget_nomination` | Clear nominations without deciding on them (`nomination_ids`, or `all`, with `include_discarded` to clear discards too; `dry_run` to count first). Nothing is shared or unshared, and a later scan that reads those facts may nominate them again. See [Clearing nominations](../sharing/#clearing-nominations) | | `set_sharing` | Turn sharing on or off for your account, when the server's operator offers it (`SHMEM_SHARING=on` on the server). With it on, the agent sharing tools (`share_facts`, `scan_shares` and the rest) work on your account's sharing workspace on the server; with it off, `share_status`, `share_log`, `share_show`, `discard_nomination`, `forget_nomination` and `unshare_facts` still do, so what was shared can be reviewed and pulled back. With `if_unset`, it sets nothing if the account already has a setting; the CLI uses this to carry over the setting from a machine where sharing was on | | `set_telemetry` | Local server only. Record your answer to whether shmem may send anonymous usage statistics from this machine; your agent asks you once, after an `ask_memory` answer, and calls it only with your explicit answer. See [Telemetry](../environment/#telemetry) | Read access allows `recall_memory`, `ask_memory`, `get_stats`, `list_sources`. Read-write additionally allows `add_memory` and `delete_memory`. **Cross-user project references**: once a project is shared with you, access it by prefixing the owner's username: ``` recall_memory(query="auth decisions", project="alice/my-app") ``` The server resolves `alice/my-app` to Alice's project directory, checks your group membership and permissions, then executes against her project. ## Author stamp vs. account identity shmem tracks two identities per fact, and they answer different questions. | Field | Question | Where it comes from | Typical value | |-------|----------|---------------------|---------------| | `caller_user` | Who wrote this? | `SHMEM_CALLER_USER` on the writing machine | `alice@laptop` | | `owner_user` | Whose is it? | the account your token authenticates as | `alice` | The author stamp is commonly **device-qualified**, because knowing which machine produced a fact is useful provenance. The account identity is the one the server can verify, so it is what authorization — including every share — is checked against. On a single machine with no remote the two are the same: shmem applies a "writer is owner" default. Once you add a hosted remote whose account name is spelled differently, they diverge, and two things follow: - **Shares still work.** The author is canonicalized to your account on push, and the original stamp is preserved in the shared copy under an `author_stamp` metadata key. Nothing is re-attributed — it names the same person by the identity the server knows. This applies **only to facts this machine authored**: a fact someone else wrote (a replica pulled from a shared project) is pushed with its author untouched, so re-sharing it can never restate its authorship as yours. - **Local owner filters will disagree.** `--mine` matches on `owner_user`, so facts still owned by the device-qualified spelling won't match your account. Fix that with [`shmem admin migrate-owner-identity`](../cli-admin/#shmem-admin-migrate-owner-identity), which rewrites `owner_user` and leaves authorship alone. Run [`shmem whoami`](../cli/#shmem-whoami) to see both identities and whether they agree. Note that the two cannot be reconciled automatically: an account identity may itself contain `@` (an email address), so there is no safe rule for splitting a device suffix off a name. --- # Source: https://shmem.secondmoment.ai/docs/latest/privacy/ --- # Privacy Policy Effective date: July 30, 2026 At Second Moment AI, we take your privacy seriously. Please read this Privacy Policy to learn how we treat your personal data. **By using or accessing our Services in any manner, you acknowledge that you accept the practices and policies outlined below, and you hereby consent that we will collect, use and share your information as described in this Privacy Policy.** Remember that your use of Second Moment AI'S Services is at all times subject to our Terms of Use, for [self-hosted](/docs/self-hosted-terms) and [hosted software](/docs/hosted-terms), each of which incorporate this Privacy Policy. Any terms we use in this Policy without defining them have the definitions given to them in the Terms of Use. You may print a copy of this Privacy Policy by here. As we continually work to improve our Services, we may need to change this Privacy Policy from time to time. Upon such changes, we will alert you to material changes by placing a notice on the Second Moment AI website, by sending you an email and/or by some other means. Please note that if you've opted not to receive legal notice emails from us (or you haven't provided us with your email address), those legal notices will still govern your use of the Services, and you are still responsible for reading and understanding them. If you use the Services after any changes to the Privacy Policy have been posted, that means you agree to all of the changes.

What this Privacy Policy Covers

This Privacy Policy covers how we treat Personal Data that we gather when you access or use our Services. "Personal Data" means any information that identifies or relates to a particular individual and also includes information referred to as "personally identifiable information" or "personal information" under applicable data privacy laws, rules or regulations. This Privacy Policy does not cover the practices of companies we don't own or control or people we don't manage.

Personal Data

Categories of Personal Data We Collect

This chart details the categories of Personal Data that we collect and have collected over the past 12 months: | Category of Personal Data (and Examples) | Categories of Third Parties With Whom We Disclose this Personal Data | | ----- | ----- | | **Profile or Contact Data** such as first and last name, email, username, phone number, company name, and unique identifiers. | Service Providers; Business Partners; Advertising Partners | | **Web Analytics** such as web page interactions, referring webpage/source through which you accessed the Services, non-identifiable request IDs, statistics associated with the interaction between device or browser and the Services, and browsing or search history. | Service Providers; Business Partners; Advertising Partners | | **Device/IP Data** such as IP address, device ID, domain server, mobile related data, and type of device/ operating system/ browser used to access the Services. | Service Providers; Business Partners; Advertising Partners | | **Professional or Employment-Related Data** such as job title and company name. | Service Providers; Business Partners; Advertising Partners | | **Payment Data** such as payment card type, last 4 digits of payment card, billing address, billing phone number, and billing email. | Service Providers | | **Commercial Data** such as purchase history. | Service Providers; Business Partners; Advertising Partners | | **Geolocation Data** such as IP address-based location information. | Service Providers; Business Partners; Advertising Partners | | **Other Identifying Information that You Voluntarily Choose to Provide** such as emails, letters, texts, or other communications you send us. | Service Providers; Business Partners; Advertising Partners | | **Resume and Application Related Information** when you submit your resume and other materials to apply for a job with us. | Service Providers — specifically our payment processing partner, currently Stripe, Inc. |

Our Commercial or Business Purposes for Collecting Personal Data

- **Providing, Customizing and Improving the Services** - Creating and managing your account or other user profiles. - Processing orders or other transactions; billing. - Providing you with the products, services or information you request. - Meeting or fulfilling the reason you provided the information to us. - Providing support and assistance for the Services. - Improving the Services, including testing, research, internal analytics and product development. - Personalizing the Services, website content and communications based on your preferences. - Doing fraud protection, security and debugging. - **Marketing the Services** - Marketing and selling the Services. - Showing you advertisements, including interest-based, online behavioral or targeted advertising. - **Corresponding with You** - Responding to correspondence that we receive from you, contacting you when necessary or requested, and sending you information about Second Moment AI or the Services. - Sending emails and other communications according to your preferences.

Other Permitted Purposes for Processing Personal Data

In addition, each of the above referenced categories of Personal Data may be collected, used, and disclosed with the government, including law enforcement, or other parties to meet certain legal requirements and enforcing legal terms including: fulfilling our legal obligations under applicable law, regulation, court order or other legal process, such as preventing, detecting and investigating security incidents and potentially illegal or prohibited activities; protecting the rights, property or safety of you, Second Moment AI or another party; enforcing any agreements with you; responding to claims that any posting or other content violates third-party rights; and resolving disputes. We will not collect additional categories of Personal Data or use the Personal Data we collected for materially different, unrelated or incompatible purposes without providing you notice or obtaining your consent.

Categories of Sources of Personal Data

We collect Personal Data about you from the following categories of sources: - **You** - When you provide such information directly to us. - When you create an account or use our interactive tools and Services. - When you voluntarily provide information in free-form text boxes through the Services or through responses to surveys or questionnaires. - When you send us an email or otherwise contact us. - When you use the Services, such information is collected automatically. - Through Cookies (defined in the "Tracking Tools, Advertising and Opt-Out" section below). - If you download and install certain applications and software we make available, we may receive and collect information transmitted from your computing device for the purpose of providing you the relevant Services, such as information regarding when you are logged on and available to receive updates or alert notices. - **Third Parties** - Vendors - We may use analytics providers to analyze how you interact and engage with the Services, or third parties may help us provide you with customer support. - Third-Party Credentials - If you provide your third-party account credentials, such as your social network account credentials, to us or otherwise sign in to the Services through a third-party site or service, some content and/or information in those accounts may be transmitted into your account with us. - **Public Records** - From public social media posts or other sources.

How We Disclose Your Personal Data

We disclose your Personal Data to the categories of service providers and other parties listed in this section. Depending on state laws that may be applicable to you, some of these disclosures may constitute a "sale" of your Personal Data. For more information, please refer to the state-specific sections below. - **Service Providers.** These parties help us provide the Services or perform business functions on our behalf. They include: - Hosting, technology and communication providers. - Security and fraud prevention consultants. - Support and customer service vendors. - Product fulfillment and delivery providers. - Analytics providers for web traffic or usage of our Services. - Payment processors. - Our payment processing partner Stripe, Inc. ("Stripe") collects your voluntarily-provided payment card information necessary to process your payment. - Please see Stripe's terms of service and privacy policy for information on its use and storage of your Personal Data. - **Advertising Partners.** These parties help us market our services and provide you with other offers that may be of interest to you. They include: - Google We may disclose any Personal Data that we collect with third parties in conjunction with any of the activities set forth under "Other Permitted Purposes for Processing Personal Data" section above.

Business Transfers

All of your Personal Data that we collect may be transferred to a third party if we undergo a merger, acquisition, bankruptcy or other transaction in which that third party assumes control of our business (in whole or in part).

Data that is Not Personal Data

We may create aggregated, de-identified or anonymized data from the Personal Data we collect, including by removing information that makes the data personally identifiable to a particular user. We may use such aggregated, de-identified or anonymized data and disclose it with third parties for our lawful business purposes, including to analyze, build and improve the Services and promote our business, provided that we will not disclose such data in a manner that could identify you.

Location of the Services

We process Personal Data in the United States. If you access the Services from outside the United States, your data will be processed outside of your country. We will take steps to handle your Personal Data subject to appropriate safeguards, as the laws regarding processing of Personal Data may be less stringent than the laws where you are based.

Tracking Tools, Advertising, and Opt-Out

The Services use cookies and similar technologies such as pixel tags, web beacons, clear GIFs and JavaScript (collectively, "Cookies") to enable our servers to recognize your web browser, tell us how and when you visit and use our Services, analyze trends, learn about our user base and operate and improve our Services. Cookies are small pieces of data– usually text files – placed on your computer, tablet, phone or similar device when you use that device to access our Services. We may also supplement the information we collect from you with information received from third parties, including third parties that have placed their own Cookies on your device(s). Please note that because of our use of Cookies, the Services do not support "Do Not Track" requests sent from a browser at this time. We use the following types of Cookies: - **Essential Cookies.** Essential Cookies are required for providing you with features or services that you have requested. For example, certain Cookies enable you to log into secure areas of our Services. Disabling these Cookies may make certain features and services unavailable. - **Performance/Analytical Cookies.** Performance/Analytical Cookies allow us to understand how visitors use our Services. They do this by collecting information about the number of visitors to the Services, what pages visitors view on our Services and how long visitors are viewing pages on the Services. Performance/Analytical Cookies also help us measure the performance of our advertising campaigns in order to help us improve our campaigns and the Services' content for those who engage with our advertising. For example, Google LLC ("Google") uses cookies in connection with its Google Analytics services. Google's ability to use and disclose information collected by Google Analytics about your visits to the Services is subject to the Google Analytics Terms of Use and the Google Privacy Policy. You have the option to opt-out of Google's use of Cookies by visiting the Google advertising opt-out page at www.google.com/privacy_ads.html or the Google Analytics Opt-out Browser Add-on at https://tools.google.com/dlpage/gaoptout/. You can decide whether or not to accept Cookies through your internet browser's settings. Most browsers have an option for turning off the Cookie feature, which will prevent your browser from accepting new Cookies, as well as (depending on the sophistication of your browser software) allow you to decide on acceptance of each new Cookie in a variety of ways. You can also delete all Cookies that are already on your device. If you do this, however, you may have to manually adjust some preferences every time you visit our website and some of the Services and functionalities may not work. To find out more information about Cookies generally, including information about how to manage and delete Cookies, please visit [http://www.allaboutcookies.org/](http://www.allaboutcookies.org/) or [https://ico.org.uk/for-the-public/online/cookies/](https://ico.org.uk/for-the-public/online/cookies/) if you are located in the European Union.

Data Security

We seek to protect your Personal Data from unauthorized access, use and disclosure using appropriate physical, technical, organizational and administrative security measures based on the type of Personal Data and how we are processing that data. You should also help protect your data by appropriately selecting and protecting your password and/or other sign-on mechanism; limiting access to your computer or device and browser; and signing off after you have finished accessing your account. Although we work to protect the security of your account and other data that we hold in our records, please be aware that no method of transmitting data over the internet or storing data is completely secure.

Data Retention

We retain Personal Data about you for as long as necessary to provide you with our Services or to perform our business or commercial purposes for collecting your Personal Data. When establishing a retention period for specific categories of data, we consider who we collected the data from, our need for the Personal Data, why we collected the Personal Data, and the sensitivity of the Personal Data. In some cases we retain Personal Data for longer, if doing so is necessary to comply with our legal obligations, resolve disputes or collect fees owed, or is otherwise permitted or required by applicable law, rule or regulation. We may further retain information in an anonymous or aggregated form where that information would not identify you personally. For example: - We retain your profile information and credentials for as long as you have an account with us. - We retain your payment data for as long as we need to process your purchase or subscription. - We retain your device/IP data for as long as we need it to ensure that our systems are working appropriately, effectively and efficiently.

Personal Data of Children

As noted in the Terms of Use, we do not knowingly collect or solicit Personal Data from minors under 13 years of age; if you are a minor under the age of 13, please do not attempt to register for or otherwise use the Services or send us any Personal Data. If we learn we have collected Personal Data from a minor under 13 years of age, we will delete that information as quickly as possible. If you believe that a minor under 13 years of age may have provided Personal Data to us, please contact us at privacy@secondmoment.ai.

Privacy Rights

Depending on where you access the Services from you may have certain rights with regard to our processing of your Personal Data. For example, under certain circumstances you may have the right to: - to find out what Personal Data we hold about you; - to be provided with a copy of your Personal Data; - to request the correction or deletion of your Personal Data; - to request that we restrict the processing of your Personal Data; - to object to the further processing of your Personal Data; - to withdraw your consent; and - to request that your provided Personal Data be moved to a third party. You may also have the right to raise a complaint with your local data protection authority. Our contact details are available in the "Contact Information" section below. Please note that we may also process Personal Data of our customers' end users or other Personal Data on behalf of our customers. If we are processing your Personal Data as a service provider, you should contact the entity that collected your Personal Data in the first instance to address your rights with respect to such data.

United States

Under California Civil Code Sections 1798.83-1798.84, California residents are entitled to contact us to prevent disclosure of Personal Data to third parties for such third parties' direct marketing purposes; in order to submit such a request, please contact us at privacy@secondmoment.ai. Your browser may offer you a "Do Not Track" option, which allows you to signal to operators of websites and web applications and services that you do not wish such operators to track certain of your online activities over time and across different websites. Our Services do not support Do Not Track requests at this time. To find out more about "Do Not Track," you can visit [www.allaboutdnt.com](http://www.allaboutdnt.com). If you are a resident of Nevada, you have the right to opt-out of the sale of certain Personal Data to third parties. Please note that we do not currently sell your Personal Data as sales are defined in Nevada Revised Statutes Chapter 603A.

Contact Information

If you have any questions or comments about this Privacy Policy, the ways in which we collect and use your Personal Data or your choices and rights regarding such collection and use, please do not hesitate to contact us at: Second Moment AI, Inc.
privacy@secondmoment.ai
Address: 2961 Southwood Dr, Alameda, CA 94501 --- # Source: https://shmem.secondmoment.ai/docs/latest/projects/ --- # Projects A **project** in shmem is a *tag* on each fact — a string column that organizes memories into logical groups. Every fact you capture has a project tag, and queries can filter by it. All facts live in a single unified database at `~/.shmem/db/facts/shmem.db` regardless of project. The project tag is what `shmem ask --project NAME` (or `--here`) filters by. This is a change from earlier shmem versions, where each project was its own SQLite database directory. The unified model means: - Queries from inside a project directory scope to that project automatically, plus the shared spaces you've joined and what teammates wrote into projects you've shared, and auto-broaden to all projects only if that finds no matches — locality without thinking. Pass `--global` (or set `SHMEM_DEFAULT_SCOPE=global`) to opt out. - Cross-project work — a question that started in one repo and continued in another — works without any extra effort once the auto-broaden fires (or always, with `--global`). - Single-player and multiplayer share the same data model - Backups, exports, and disaster recovery operate on one file Installs predating v0.1.33 kept a separate database per project. That layout is no longer readable and the in-place migration has been removed; if shmem reports an empty store while `~/.shmem/projects/` still has data, start fresh or open an issue to recover it. ## Should I use projects, or just `default`? **Use projects for the repos you'll want to scope or share.** `shmem install` captures every session without any per-repo setup — live sessions land in `default`, imported history is tagged by where it happened, and `shmem ask` searches all of it. Run `shmem init` in a repo when you want it to have its own tag. Projects are shmem's unit of organization and sharing, and they line up with how other agent tools already scope work to a directory — so tagging by repo matches the boundary you're already thinking in. Sharing is per-project: when you grant a teammate access, the project is what you grant. A single undifferentiated store gives you nothing to hand over. `default` is the fallback, not a recommendation. Sessions in directories you haven't run `shmem init` in land there, and that's fine — nothing is lost, and you can always retag later with `shmem admin project rename --from OLD --to NEW`. But you give up the ability to scope a question to one codebase, and you give up sharing granularity. You're not choosing isolation. Because everything lives in one database and queries auto-broaden when a project has no matches, tagging costs you nothing in recall — a question that spans two repos still finds both. ## Should I import my existing history? **Yes — import everything.** `shmem install` imports your agents' past sessions automatically; `shmem import --auto` picks up anything added later. shmem is more useful the more of your past work it can see, and an empty store is the single biggest reason a new install feels useless. Retrieval is ranked rather than exhaustive, so additional history competes for the top slots rather than crowding anything out. Imports are additive and idempotent, so you can start with one source and add the rest later without duplicating anything. ## Where does my data go? For *writes*, shmem picks the project tag in this order: 1. A `.shmem/project` marker file found by walking up from the current directory (written by `shmem init`). Per-directory routing always wins over global config. 2. `SHMEM_DEFAULT_PROJECT` env var (or set in `~/.shmem/.env`) — the "global mode" key for users who want one tag everywhere. 3. `SHMEM_PROJECT` env var — **deprecated for the `shmem` CLI** (prints a one-shot warning when consulted). Still the canonical config mechanism for `shmem-mcp` server instances configured via `.mcp.json`. 4. The fallback name `default`. For *reads*, the default is "no scope" — every project's facts are searched together. To narrow: | Flag | Effect | |---|---| | `--here` | Walk up from cwd for a `.shmem/project` marker; scope to that tag alone, without the shared spaces the implicit scope adds. | | `--project NAME` | Restrict to a specific tag. | | `--mine` | Only facts you (`SHMEM_CALLER_USER`) authored. | | `--shared` / `--private` | Restrict to one scope. | These compose: `shmem ask --here --mine --private "what was I thinking?"` is the cwd's project, only your facts, only private. **Memory with no project is account-wide.** Your own memories in `default` (sessions captured outside any project, and what the [Claude app](../claude-app/) saves through the connector, which arrives on your machines with no project) belong to no one project, so every project scope includes them: `--here`, `--project NAME`, the implicit cwd scope, and the MCP tools' project scope alike. `--project default` still lists only them. Two things never come in this way: another person's memories, and, for a teammate reading a project you shared, your account-wide memory. `shmem query --ids`, whose output feeds `shmem delete --stdin`, keeps to the project alone. `shmem admin status` prints the resolved write tag, the unified DB path, and a hint if legacy per-project DBs are detected on disk. ## Why a unified DB? The trade-offs the old per-project model optimized for (signal-to-noise, predictable retrieval cost, portability) still apply, but they're now solved by other mechanisms: - **Signal-to-noise** is solved by retrieval ranking (keyword IDF + temporal + optional semantic) and the explicit `--project` / `--here` filters when you do want narrow scope. - **Cross-project work** — the most common pain point of the old model — works trivially: a question that started in one repo and continued in another is now one query. - **Privacy** moves to a per-fact `scope` column (private vs shared) instead of a per-project boundary. Your personal memories never mix into team views by accident. - **Portability** — one file at `~/.shmem/db/facts/shmem.db`. Back it up, sync it, replicate it. - **Performance** — the keyword index is a persisted SQLite FTS5 index (maintained at write time); the temporal index is in-memory and fast. The optional dense-embedding index is opt-in via `SHMEM_EMBED_MODEL`. ## First-run expectations A fresh install starts with an empty unified DB; `~/.shmem/db/` is created on the first write. The quickest way to get useful data in is one of the import sources: ```bash shmem import --from claude-code # all your Claude Code transcripts shmem import --from cursor # Cursor IDE chat history shmem import --from codex-cli # OpenAI Codex CLI rollouts shmem import --from github --per-repo # PRs and issues you authored, via gh ``` The transcript sources tag facts with a project name derived from the source's structure (Claude Code project directory, Cursor workspace, Codex session path). `--from github` does **not** — it writes into your current project unless you pass `--per-repo` (one project per repo, named `owner-repo`) or `--project `. After import, `shmem ask "..."` defaults to your current project (with auto-broaden to all projects on empty), and `shmem ask --global` searches everything explicitly. Import is a pure parse-and-insert with no LLM calls, which is why it's fast even for thousands of facts. LLM calls only happen at query time (`ask_memory`). ## Facts One **fact** is one message — one user turn, one assistant turn, or one tool call. Fact counts grow quickly (a single busy Claude Code session produces hundreds), and that's intentional: keyword retrieval stays fast at these sizes, and the finer granularity gives the QA pipeline better context to synthesize from. Facts are immutable in content once stored. You can delete them (`shmem delete`) but not edit them. The `scope` column (private vs shared) is mutable so facts can be promoted from private to shared without rewriting content. ## Sharing Sharing in the unified model operates at the **fact** level via the `scope` column (`private` vs `shared`), with optional `shared_with` group. Project-level promotion rules — "share my `customers` project with team alice/team" — translate to "for every fact tagged `customers`, set scope to shared." The promotion mechanics are tracked under M2 of the unified-memory plan and not yet implemented. For the current group + permissions model, see the [Reference](../reference/). ## Related CLI commands | Command | What it does | |---------|--------------| | `shmem admin status` | Show the unified DB path, the resolved write tag, and any legacy DB hints. | | `shmem admin project list` | List project tags from the legacy `projects.json` registry (still useful for the dashboard's project drill-down). | | `shmem ask --here "..."` | Query the project tagged for the current directory. | | `shmem ask --project NAME "..."` | Query a specific tag. | | `shmem query --mine "..."` | Filter to facts you authored. | --- # Source: https://shmem.secondmoment.ai/docs/latest/reference/ --- # Reference The `shmem` and `shmem-mcp` binaries expose the same memory system through two interfaces: a shell-callable CLI (for Claude Code, Codex, Antigravity, scripts) and an MCP server (for Claude Desktop, Cursor, hosted teams). The pages below cover both, then the transports and environment variables that configure them. For which of these surfaces we promise not to break — and what happens when we have to — see [compatibility](../compatibility/). ## Pages - [CLI](../cli/) — every `shmem` command and flag - [shmem import](../cli-import/) — bring in existing history - [shmem gateway serve](../cli-gateway/) — capture from an LLM gateway - [shmem admin](../cli-admin/) — status, models, projects, groups - [MCP server](../mcp-server/) — the `shmem-mcp` tools and their arguments - [Transports](../transports/) — stdio, SSE and streamable HTTP - [Environment variables](../environment/) — everything `shmem` and `shmem-mcp` read - [Compatibility](../compatibility/) — what we promise not to break --- # Source: https://shmem.secondmoment.ai/docs/latest/self-hosted-terms/ --- # Second Moment AI — Terms of Use **Free Self-Hosted Software** Last updated on July 30, 2026

1. Acceptance of These Terms

These Terms of Use ("Terms") form a binding agreement between Second Moment AI, Inc. ("Second Moment," "we," "us," or "our") and the individual or entity that downloads, installs, or uses the Software ("you" or "Customer"). By downloading, installing, or using the Software, or by clicking "I agree," you agree to these Terms. If you do not agree, do not download, install, or use the Software. If you use the Software on behalf of an organization, you represent and warrant that you are authorized to bind that organization to these Terms, in which case "you" means that organization. Your access to and use of the Software, which is provided at no charge, is offered in consideration of your agreement to these Terms and the mutual promises in them. These Terms incorporate by reference our privacy policy located at [https://shmem.secondmoment.ai/docs/privacy](/docs/privacy).

2. Definitions

**"Customer Data"** means all data you create, submit, or process using the Software, including the conversations you and your agents generate (your inputs), conversation metadata, and the outputs generated in response, all of which remain on your Customer Systems. **"Customer Systems"** means the devices, hardware, operating systems, and infrastructure that you own or control and on which you install and run the Software. **"Documentation"** means the user and technical materials we make available describing the Software and its use. **"Prohibited Content"** means content that is unlawful, infringing, deceptive, or that contains malicious code, or that is otherwise objectionable as described in Section 4. **"Software"** means Second Moment's proprietary software providing an external memory layer for AI agents, in the form of a package, image, or installer made available for you to install and run on your Customer Systems, together with any updates we make available. **"Telemetry"** means the limited technical data described in Section 6 that the Software may transmit to us regarding installation, performance, activity, version, and configuration. **"Third-Party Model Provider"** means any local or third-party artificial-intelligence model or service that you configure the Software to use, including any model you run locally or any provider for which you supply your own credentials.

3. License to the Software

(a) **License Grant.** Subject to these Terms, Second Moment grants you a limited, non-exclusive, non-transferable, non-sublicensable, revocable license to install and run the Software on your Customer Systems for your own internal use, free of charge, for so long as these Terms remain in effect. You may make a reasonable number of back-up copies, provided you keep all proprietary notices intact. (b) **Reservation.** The Software is licensed, not sold. As between the parties, Second Moment and its licensors own all right, title, and interest in and to the Software, Documentation, and all intellectual property therein. No rights are granted except as expressly stated.

4. Acceptable Use; Restrictions

(a) **Restrictions.** You will not (and will not permit any third party to): (i) use the Software other than on your Customer Systems as permitted here; (ii) circumvent, disable, or tamper with any license, entitlement, or metering mechanism; (iii) reverse engineer, decompile, or disassemble the Software, or attempt to derive its source code (except to the limited extent applicable law permits notwithstanding this restriction); (iv) modify, adapt, or create derivative works of the Software, or remove any proprietary notices; (v) sell, resell, rent, lease, sublicense, distribute, or host the Software for any third party; (vi) use the Software in violation of any applicable law; or (vii) introduce any malicious code into the Software. (b) **Your Content.** You are solely responsible for the content you submit, and for ensuring you have all rights and consents necessary to submit it. You will not submit to the Service any content that: (i) you lack the right to submit; (ii) violates any applicable law or third-party right; (iii) constitutes Prohibited Content; or (iv) consists of special categories of personal data or other sensitive or regulated data (including health, financial account, government identifier, biometric, or children's data) that you are not authorized to process. Second Moment provides tools to help you manage and remove content but does not monitor, and is not responsible for, the content you choose to submit.

5. Your Data; Ownership; No Access

(a) **You Own Your Data.** As between the parties, you own and retain all right, title, and interest in and to your Customer Data, including your inputs and the agent outputs. Second Moment claims no ownership of, and acquires no license to, your Customer Data, takes no royalty in anything you create with the Software, and will not sell your Customer Data. (b) **We Do Not Access Your Data.** Because the Software runs entirely on your Customer Systems, your Customer Data stays with you. Except for the Telemetry described in Section 6, Second Moment does not receive, access, host, store, transmit, or otherwise process your Customer Data, and does not use it to train, fine-tune, or improve any model. With respect to your Customer Data, Second Moment is neither a "controller" nor a "processor" (nor a "business" nor a "service provider") under applicable data-protection laws, and no data processing agreement applies to these Terms. You are solely responsible for the security of your Customer Systems and for backing up your Customer Data.

6. Telemetry

The Software transmits Telemetry only if you enable it, and does not do so by default. If you enable it, the Software transmits Telemetry to us on a periodic basis (approximately once per day), directly to infrastructure we operate. This Telemetry is limited to the Software's installation, performance, activity, version, and configuration characteristics and is designed to exclude personal data — we do not collect the content of your Customer Data. We use Telemetry to understand aggregate product usage and health. You may enable or disable Telemetry at any time, as described in the Software's documentation. Separately, and regardless of the Telemetry setting, the Software checks approximately once per day whether a newer version has been released. That check transmits no identifier, no account information, and no data about you or your installation.

7. Third-Party Model Providers

You may configure the Software to use a Third-Party Model Provider (for example, a model you run locally or a provider for which you supply your own API key). Any such model or provider is selected and controlled by you, and your use of it is governed by your own agreement with that provider. Second Moment does not control, endorse, or assume any responsibility or liability for any Third-Party Model Provider or for data you send to it.

8. Fees; Conversion to the Hosted Service

The Software is provided free of charge for your internal use. If you later choose to enable collaboration or otherwise use Second Moment's [hosted service](/docs/hosted-terms), additional and separate terms (including, as applicable, paid subscription terms) will apply, and any migration of your locally stored Customer Data to our hosted environment will occur only with your consent.

9. Term; Termination

These Terms apply while you have the Software installed or in use. You may stop using and uninstall the Software at any time. We may suspend or terminate your license if you materially breach these Terms. Upon termination, all licenses end and you will cease using and uninstall the Software and delete all copies. For clarity, because we do not hold your Customer Data, we have no deletion obligation with respect to it. Sections 4, 5, 10, 11, 12, and 13 survive termination.

10. Disclaimers

THE SOFTWARE IS PROVIDED "AS IS" AND "AS AVAILABLE" TO THE FULLEST EXTENT PERMITTED BY LAW. SECOND MOMENT DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. WE DO NOT WARRANT THAT THE SOFTWARE WILL BE ERROR-FREE, UNINTERRUPTED, OR MEET YOUR REQUIREMENTS.

11. Limitation of Liability

TO THE FULLEST EXTENT PERMITTED BY LAW, SECOND MOMENT WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR FOR ANY LOST DATA, PROFITS, OR BUSINESS. SECOND MOMENT'S TOTAL LIABILITY ARISING OUT OF OR RELATED TO THESE TERMS OR THE SOFTWARE WILL NOT EXCEED THE GREATER OF (I) THE AMOUNTS YOU PAID US IN THE TWELVE (12) MONTHS BEFORE THE EVENT GIVING RISE TO THE CLAIM (WHICH, FOR THE FREE SOFTWARE, MAY BE ZERO) OR (II) ONE HUNDRED U.S. DOLLARS (US$100). THIS SECTION DOES NOT LIMIT LIABILITY THAT CANNOT BE LIMITED UNDER APPLICABLE LAW.

12. Indemnification

You will defend, indemnify, and hold harmless Second Moment and its affiliates and their respective officers, directors, employees, and agents from and against any third-party claim, and any related losses, damages, costs, and expenses (including reasonable attorneys' fees), arising out of or related to: (i) your Customer Data or your use of the Software; (ii) your violation of Section 4; or (iii) your violation of applicable law or any third-party right.

13. Changes to These Terms

Second Moment may modify these Terms from time to time. If we make a material change, we will provide reasonable notice (for example, by email, in-product notice, or by posting the updated Terms with a new effective date). Changes are effective upon the stated effective date, and your continued use of the Software after that date constitutes acceptance of the updated Terms. We maintain prior versions and will identify the version in effect. If you do not agree to a change, your remedy is to stop using the Software.

14. General

These Terms are the entire agreement between you and Second Moment regarding the Software and supersede any prior understanding on the subject. The Software is subject to U.S. export control laws; you will not use or export it in violation of those laws, including to embargoed countries or restricted parties. The Software may include third-party open-source components, which may be identified in a notices file; your use of those components is subject to their respective licenses. If any provision is unenforceable, the remainder will remain in effect. You may not assign these Terms; we may assign them in connection with a merger, acquisition, or sale of assets. These Terms are governed by the laws of California, without regard to conflict-of-laws rules, and the parties submit to the exclusive jurisdiction of the courts located in San Francisco, California. **BY DOWNLOADING, INSTALLING, ACCESSING, OR USING THE SOFTWARE, OR BY CLICKING "I AGREE," YOU ACKNOWLEDGE THAT YOU HAVE READ, UNDERSTOOD, AND AGREE TO BE BOUND BY THESE TERMS.** --- # Source: https://shmem.secondmoment.ai/docs/latest/sharing-rules/ --- # Sharing rules The rules engine watches your captured facts and **nominates** share-worthy moments — or, where you've explicitly said so, shares them automatically. This page is the complete specification of the rules file, `share-rules.yml`. It is written to be sufficient for an agent to set up or modify a user's rules correctly; the system overview lives at [sharing](../sharing/). ## Where the rules live The rules live on your shmem server, in your account, which is where they run: `shmem share rules` shows them and `shmem share rules --edit` edits them, and an agent reads and changes them with the `get_share_rules` and `set_share_rules` tools. Both refuse a write based on rules that changed in the meantime, so two edits can't clobber each other. `~/.shmem/share-rules.yml` is kept as a copy of the server's. The first sharing command after you add a remote moves this machine's rules to the server, if you changed them from the starter rules and the server's are still the starter rules, along with the nominations you discarded, so what you turned down stays turned down. If you have your own rules on both, the server's apply: the command says so and keeps this machine's version in `share-rules.yml.local`. Pending nominations don't move; the server makes its own. ## How the scan works The server's scan (run after your writes arrive, by agents via `scan_shares`, or by hand with `shmem share scan`) gathers your new captures since the last scan, evaluates them against your rules, and produces **nominations**. Each one ships in the first of three forms that works: 1. **Raw**: the span of existing facts, shared as-is, except that each tool call ships as its call line, its output left out (unless the rule sets `tool-output: keep`). Text the agent wrote through a call stays: a commit message, a PR or issue body or comment passed in a heredoc, and a Markdown or text file written with Write. A span that would ship only bare call lines isn't nominated. This is the default whenever nothing in the span breaks a `never` rule and the span is under 8,000 characters. 2. **Redacted**: when some parts can't go but the rest can, the span itself with just those parts replaced: a name or figure by a placeholder such as `[client]`, `[amount]`, or `[person]`, a whole sentence or paragraph that holds something a `never` rule covers, or is noise (an offer to do more, a tool-output dump), by `[omitted]`. Everything else, explanations and proposed fixes included, ships as written. It ships fact by fact, so readers still see who said what and when: a fact the redaction changed ships as a new fact with its redacted text, in its place and under its speaker, and a fact with nothing shareable left ships as `[omitted]`. A span over the raw limit is trimmed the same way, leaving its noise out until it fits. Your original facts are never edited. shmem checks each fact's redaction on its own: whitespace aside, it must be the original text with short parts swapped for placeholders and whole sentences or lines left out. A fact that fails is asked for once more, told what was wrong; if it fails again, that fact alone is narrated, in its place and under its speaker, and the rest of the span ships as redacted. Only when the span as a whole keeps less than 30% of its text (and under 2,000 characters) is the whole moment narrated instead. 3. **Narrated**: when too little would be left, a record of what happened in reported speech, one line per step, labeled `User` or `Agent` (`User asked…`, `Agent ran…`, `User decided…`), with the protected content left out. Tool calls appear only as the action in an Agent step; routine reads and listings are left out. Each line ships as its own fact in the place of the step it reports: under its speaker, at that step's time, in its session. Every line is marked `narrated`, so readers know it paraphrases rather than quotes, and `ask` shows it as such (`Dan [narrated]: User asked…`). The first line leads with the record's headline (`# Importer rows`), so everyone who reads the space sees the moment by that title. The headline is part of the shipped text: the share filters and the share check read it like any other line. A moment that matches rules aimed at different targets is nominated once per target, and each target gets the parts its rule covers. One model call labels every sentence of the span with the rules it belongs to (a sentence both audiences need, such as a shared cause, belongs to both; thanks and scheduling belong to neither and go to everyone) and with the `never` rules it breaks, including each target's own. Each target's copy is then built from those labels, fact by fact like a redaction: sentences that only concern another target become `[omitted]` (a fact that is all another target's ships as just `[omitted]`), and a kept sentence that breaks one of the target's `never` rules gets the word-level redaction above. A target whose copy keeps almost nothing, or whose redaction fails, gets a narrated record that leaves the other target's part out. If nothing needs leaving out for a target, it gets the moment as it would alone. A nomination remembers the other targets' rules, so when a later moment merges into it, the merged span is labeled again and the target still gets only its own parts. In every form, paths leave your machine's details behind: a home directory ships as `~`, and an agent's scratch or temp directory as ``. So do links to your own agent sessions, routines and artifacts (`claude.ai/code/session_…`, `claude.ai/code/routines/…`, `claude.ai/artifact/…`): a `Claude-Session:` trailer on a commit message, or a line that is only such a link, is left out, and a link inside a sentence ships as `[url]`. Your own copy of the fact keeps them. A subagent's hand-back ships as its label and the report it carried, without the wrapping an agent harness puts around it. A fact you share by id ships as written. A nomination is titled for what ships. The scan writes a headline from the span as it read it; when the shipped text says less (a redaction cut parts, or a raw span's tool output is left out), the headline is written again from the shipped text, so it never states a finding the note doesn't hold. A span that ships as the scan read it keeps the scan's headline, at no extra model call. A nomination whose rule name is not one of your rules (a model sometimes answers with something else, such as another nomination's headline, or with nothing) is staged under no rule and with no target, never shared without review, whatever a project's `mode` says. Its note and a scan warning give the name the model answered; pick a target when you approve it. It is kept apart from nominations your rules aim: it never merges with one, and it is the first to go when an answer names more moments than the scan takes. Nominations share nothing — they wait in `shmem share` for a decision. Only rules you explicitly set to `mode: share` share without review, and those are loud: a receipt in the scan output, a line in status, an entry in the log. A history replay (`shmem share scan --since …`) is the exception: it only nominates, so what a `mode: share` rule matches in older memory is staged for your review unless you start the replay with `--auto-share`. Before a `mode: share` rule ships anything, a second model call checks what would ship against the target's `never` rules. If it finds a problem, the nomination is redrafted once, with the objection added to what the draft must leave out. A raw or redacted span is redacted (again), record by record; if that can't be done or is still flagged, or the nomination was narrated, it is redrafted as a narrated record. If the redraft is still flagged, or leaves nothing to share, or the check can't run, the nomination is **held**: it stays in `shmem share` as a draft, with a note saying what was flagged and, when the check thinks another rule fits better, a suggested target. Nothing is moved to another target on its own. A target `never` rule titled `-only` (say `team-only` on a public target) means "anything that rule covers"; the drafter is given that rule's criteria, so the omission is concrete. A nominated span starts with the request that set the work going. The evaluator includes your message in the span and judges it against `never` like everything else. If its pick still begins at the agent's first step, the nearest earlier message from you in the same session is added, unless another nomination or share already holds it. That message is first checked on its own against `never`, and left out if it breaks one, can't be checked, or is longer than a raw share holds (8,000 characters). One request starts at most one moment, so two pieces of work you asked for in one message stay separate nominations. The scan and the share check read everything you and your agents wrote in a span, up to that 8,000-character limit, so nothing that ships goes unread. Tool output, which ships as its call line unless a rule keeps it, is read only in part. A raw or narrated draft isn't checked, since you review it. A redacted draft goes through the share check first: the redaction may have missed something it was told to hide, or put back a tool call's line it had dropped (a call line is kept so a reader can follow what was done). If the check flags it, the draft gets one redraft, and if that is flagged too it is held with a note saying why. Deduplication is built in: a span you discarded never re-nominates (unless you [forget](/docs/sharing#clearing-nominations) the discard); overlapping nominations for the same target merge, and a merged nomination ships in the stricter of the two forms (raw, then redacted, then narrated), leaving out what either had to; already-shared content is skipped. ## The file ```yaml # share-rules.yml settings: status-window: 7d # the window status counts recent shares in default-target: team-memories # target when no --to / target: is given rules: # global rules, evaluated on every scan - title: milestones # unique name; nominations cite it criteria: something was merged, deployed, released, or a milestone completed mode: draft # nominate for review (the default) - title: gotchas criteria: bugs or gotchas that cost real time to figure out mode: draft - title: benchmarks criteria: benchmark results and the decisions they drove mode: share # share WITHOUT review — loudly target: perf-notes # where this rule shares to - title: perf-findings criteria: performance regressions and their root causes mode: draft target: perf-notes # a DRAFT rule's target pre-aims its # nominations: approving one shares # there, no --to needed never: # GLOBAL: what must never be shared - title: credentials criteria: secrets, tokens, API keys, passwords, or connection strings - title: personal criteria: personal details about individuals, or personnel/HR matters projects: # per-project configuration - project: shmem-perf mode: share # auto-share nominations from this project target: team-memories rules: # evaluated only against this project's facts - title: flamegraphs criteria: profiling results worth keeping mode: share never: # TARGET-scoped: applies to everything - title: off-topic # shared INTO this project, from any criteria: anything unrelated to performance work # source, # merged with the global never rules ``` ## Field reference ### `settings` | Key | Meaning | Default | |---|---|---| | `status-window` | The window `shmem share` counts recent shares in, and the `--since` its `share log` hint uses (`48h`, `7d`, `2w`) | `7d` | | `default-target` | Target when neither `--to` nor a rule/project `target:` applies | `team-memories` | ### `rules` (and `projects[].rules`) | Key | Meaning | |---|---| | `title` | Unique name. Nominations and log entries cite it. | | `criteria` | Natural language: what the rule matches. The evaluator reads this verbatim. | | `mode` | `draft` (default): nominate for review. `share`: share immediately — loudly, revocably (a history replay stages its matches for review instead, unless started with `--auto-share`). A project's rules route only that project's facts: a moment of facts in no project is routed by global rules alone, and a moment whose facts come from more than one project (counting facts in no project) is always staged as a draft for you to aim. Write `mode: draft` explicitly; an explicit draft *pins* review even when a project-level `mode: share` would otherwise apply. | | `target` | Where the rule's matches go. On a `share` rule: where it shares. On a `draft` rule: pre-aims the nomination — approving it shares there without `--to`. | | `tool-output` | What a nomination keeps of each tool call. `collapse` (default): the call line alone (`[Bash] go test ./...`), with `[output omitted]` where its output was. `keep`: the output too, for a rule whose shares are about what a tool printed, such as bug reports quoting a command's exact output. Facts you share by id always ship as written. | ### `never` (global) and `projects[].never` | Key | Meaning | |---|---| | `title` | A name for the exclusion. | | `criteria` | Natural language: content that must not be shared. | **Scoping semantics — this distinction matters:** - **Global `never:`** is content-sensitivity policy. It applies to every scan, every nomination, every distillation, regardless of target. - **`projects[].never:`** protects a **target**: it applies to *everything shared INTO that project*, no matter which project the facts came from. Use it to keep a focused space on-topic ("nothing unrelated to performance") without touching global policy. Never rules act at two points: the evaluator skips matching moments (or marks them to be redacted or narrated so the protected content is left out), and the merged never-criteria for the destination ride into every redaction and narration prompt as **strict omissions**. They are a belt, not suspenders — the deterministic `.shmemignore` filters (redact / substitute / drop) still run at the share boundary, fail-closed. A **manual single-fact share bypasses never-rule screening** by design: naming a fact id is a deliberate act, and the system doesn't second-guess it. The `.shmemignore` filters still apply. ### `projects` | Key | Meaning | |---|---| | `project` | The project name this entry configures. | | `mode` | `share`: nominations arising from this project's facts auto-share. | | `target` | Where those auto-shares go (default: `settings.default-target`). | | `rules` | Extra rules evaluated only against this project's facts. | | `never` | Target-scoped exclusions (see above). | ## Resolution order For each nomination, the effective mode and target resolve as: 1. **The matched rule's own `mode`/`target`** — an explicit `mode: draft` pins review even under a project `mode: share`; an explicit `mode: share` shares to the rule's `target` (or the default target). 2. **The source project's `mode`/`target`** — an unmarked rule matching facts from a `mode: share` project auto-shares to that project's target. 3. **Draft to nowhere** — nominate, let the user aim at share time. An explicit `--to` on the share command beats everything. ## Target validation A foreign target (`owner/name`) is checked against the remote's shared-project listing at every surface that touches it *before* share time: the scan drops an unknown aim (the nomination stages **unaimed** for review, with the reason as its note — a `share`-mode rule falls back to draft rather than auto-sharing into a wall), `shmem share rules` warns after an `--edit` (and after a plain show), and `shmem share` marks a pending nomination whose aim no longer resolves. Wherever the listing offers an unambiguous near-match — the common case being a bare username where the server knows the full account identity — the message suggests it: `did you mean "dan@example.com/shmem-team"?`. The client never rewrites a target on its own; the server stays the authority, so when no remote is reachable the target is treated as unverifiable, not invalid. A target whose owner is your own account is not foreign: `you@example.com/team-memories`, or `you/team-memories` by the part before the `@`, is the same target as the bare `team-memories`, in rules, in `--to`, and when unsharing. It is read as the bare name everywhere, so one moment is never nominated or shared twice under two spellings. Note that a nomination keeps the target aimed at scan time: fixing a rule does **not** re-aim already-staged nominations — share those with an explicit `--to`. ## Default rules Your rules are the whole standard: shmem adds none of its own. The first scan writes a starter file whose `milestones`, `decisions`, `dead-ends`, and `gotchas` rules are explicit drafts you can edit or delete. A file with no rules nominates nothing. A project's `mode: share` applies to the unmarked rules that match its facts, so a sharing project needs at least one rule without a `mode` (global, or in the project's own `rules:`). The defaults framework, if you're writing rules for someone: prefer **completion-anchored** criteria (things that *finished*), **high value to a teammate, low sensitivity**, and **precision over recall** — an over-eager scanner trains people to bulk-discard, which is worse than missing a nomination. ## Verifying a setup ```console $ shmem share rules # print the active file (--edit to open it) $ shmem share scan # run the pipeline over what arrived since the last scan $ shmem share scan --since all # replay older memory under the current rules: nominates only $ shmem share scan --since all --auto-share # ...and let mode: share rules share what it finds $ shmem share forget --all # after changing rules: clear what awaits review, then replay $ shmem share # nominations waiting; footer shows # "Rules: N draft · N share · N never." ``` --- # Source: https://shmem.secondmoment.ai/docs/latest/sharing/ --- # Sharing shmem's sharing model lets a team exchange *facts* — the unit of memory — without ever giving up control of their private stores. This page is the system overview: the data model, what each verb does, and the invariants every surface (CLI, agent tools, dashboard) maintains. The rules engine that automates nomination has its own page: [sharing rules](../sharing-rules/). ## The model in one paragraph A **project is a set of facts**. Membership in that set is a row in a `memberships` relation — `(fact_id, project, actor, timestamp)` — not a column on the fact. **Sharing a fact adds a membership; unsharing removes it.** A fact keeps **one id across every database it reaches**: there are no copies, no origin pointers, no forks. Your private capture stream is simply the facts with *no* memberships (the "default" project — absence means default). Capturing into a marked directory is a share-to-self: the hook writes the fact and its membership in one step. ## Identity and replication (the invariant) Every fact has exactly one id, minted where it was authored, carried verbatim through every replication. A database holds **at most one row per fact, ever**. What replicates between machines is: 1. **Membership rows** — the authoritative record of what belongs to a space, cursored on *membership* time (sharing an old fact creates a new membership; fact-time cursors would miss it). 2. **Fact bytes** — fetched only when a membership references a fact the local database lacks, stored under the fact's own id with its original author preserved. Its [provenance stamps](../how-it-works/#provenance-stamps) (repository, branch, directory, machine) stay with the owner and are never part of a shared copy. Foreign facts are **refcounted by membership**: when the last membership that brought a teammate's fact to your machine is retracted, the bytes are deleted too. Your own facts are never deleted by membership changes — unsharing returns them to your private default project. ## Spaces, targets, and audiences A **target** is where a share goes: - A **bare name** (`team-memories`) is a project in your own root. It becomes an *audience-bearing space* when you grant a group access: `shmem project share team-memories -g dan/demo-team -p r`. The grant IS the standing share — captures and shares into a granted project are visible to the group as they land. `r` grants read; `rw` also lets members share into and retract from the project. - An **owner-qualified ref** (`dan/team-wiki`) is a project in another user's root that you hold a write grant on — a *co-writable space*. Shares into it go over the wire to the owner's root, gated server-side. Who can *read* a space is always the project's grants, managed separately from the act of sharing into it. ## The verbs | Verb | What it does | |---|---| | `shmem share [--to ]` | Adds memberships placing the facts in the target. A span of ids shares together and is remembered as a span. | | `shmem share --since 2h [--about topic]` | Distills a window of your captures into ONE new fact, a step-by-step record of what happened in reported speech (`User asked…`, `Agent ran…`; provenance stays private), and shares that. | | `shmem share --edit` | Opens $EDITOR; the saved revision is minted as a new fact and that is what ships. | | `shmem share --amend ` | Retract-and-replace: unshares the fact from every space it's in, opens $EDITOR, mints the revision, shares it to the same spaces. | | `shmem share show ` | Live visibility: which audience-bearing spaces hold the fact, joined with each project's grants. Computed from memberships, never replayed from history. | | `shmem unshare ` | Removes the membership. Retracts the whole span by default (`--only` for one fact); `--from` picks a space, `--everywhere` retracts from all. Warns when other granted spaces still hold the fact. | | `shmem share log [--since 7d]` | The audience-visible history: share/unshare events across every space you can see. `--since` narrows it to a window. | | `shmem share discard ` | Turns a nomination down for good. The no is recorded privately, and those facts are never nominated again. | | `shmem share forget ...` / `--all` | Clears nominations without deciding on them, as if they had never been proposed: a later scan that reads those facts may nominate them again. For starting over after a rule change (`--all`), or undoing a discard (name it, or `--all --discarded`). Asks first unless `--yes`. See [Clearing nominations](#clearing-nominations). | | `shmem share enable` / `disable` | Turns sharing on or off for your account on the server. Off, nothing new is nominated or shared; status, log, show, discard, forget and unshare still work on what sharing already did. | | `shmem share` (bare) | Status: one block per space you share into (who can read it, the rules aimed at it, its never rules, and how much has been shared, by whom and recently), then the nominations awaiting review. Same as `shmem share status`. | ## Events carry no content Every share and unshare also places a small **event fact** (`kind=share-event`) into the space. Events carry **ids, counts, and the actor only — never content snippets**. The log renders titles by joining each event to the *live* fact; when the fact has been retracted, the log shows `(retracted)`. That closes the redaction hole: pulling a fact back leaves no residue of its content in the history the audience can see. When you share into, or unshare from, someone else's project, the event goes into their space and a copy into your own account, so the act shows in your `share log` too, named by the space's `owner/name`. Your **private ledger** (`shares.db`, in your account on the server and never replicated) keeps snippets, provenance, and your discard and forget decisions. A shared fact carries only the metadata that says what it is: the space log's ids and counts, a title, and an imported record's own fields (repository, number, type, url, state, author, labels, reviewers), plus any key whose name starts with `shared.`. How you captured it stays with you: session and import bookkeeping, capture stamps (`stamp_*`), what a distilled fact was made from, the share filters' redaction mark, local markers, and any other key you set. The same allowlist applies to a fact written straight into someone else's project and to what a reader in another account sees. To give your audience a key of your own, name it under `shared.`: a fact written with `{"shared.branch": "release-2"}` carries it to every account it is shared with, and readers there can filter on it. A bare `branch` stays with you. Unshare events double as **tombstones**: when a syncing client pulls an unshare event, it removes its local membership and refcount-deletes foreign orphans. Retraction propagates at sync speed; bytes a machine never re-syncs are, honestly, already theirs. Deleting your own fact works the same way across your machines, shared or not: the server records the delete as an id-only event (`event=delete`) in your own memory, and each of your other machines deletes its copy when it next pulls. Events are bookkeeping, not memories: `ask`, `query`, and `recall_memory` never return them. ### When a machine syncs A machine with a hosted remote pulls its own new facts and sweeps the spaces shared with it — new facts in, unshared and deleted ones out — at each of these points: - **CLI reads**: `shmem ask`, `shmem query`, and the dashboard pull before answering (up to 10 seconds; on timeout or error the read answers from local data). - **Local MCP reads**: a local `shmem-mcp` (the one an agent host runs over STDIO) pulls before `ask_memory`, `recall_memory`, `get_facts`, and `list_facts_since`, with the same 10-second budget, and also syncs in the background every sweep interval while it runs. - **Prompts**: each captured user message starts a detached `shmem pull --background` when a sweep is due, so the prompt never waits on the network. - **`shmem pull`**: on demand. The shared-space sweep runs at most once per `SHMEM_SWEEP_INTERVAL` (default 2 minutes), and only one sync runs at a time on a machine: a read that finds another sync in progress answers from local data, and an explicit `shmem pull` waits for it. The hosted server itself never syncs from anywhere. ## Where a share came from What a share was made from is the sharer's alone. A distilled share records its source facts (`distilled_from`), and a copy that share filters redacted is tied to its original in the ledger; neither travels with the share, so readers see the shared fact and who shared it, never its sources. The sharer sees them. On the dashboard's Sharing tab, each shared fact and nomination has a **sources** list, shaped like the Sources under an `ask` answer: a fact shared as written is its own source, a distilled one lists the facts it was written from, a redacted copy names its original. Clicking a source opens it in full, and every fact id on the tab links to the fact's page (`#/fact/`), which for a distilled fact lists its sources too. Sources are your own facts, so they reach each of your machines through the normal sync, and deletes do too: a source deleted since the share reads "source no longer available", and one this machine hasn't pulled yet reads "not on this machine yet". The dashboard never fetches a source on its own. A teammate's share says who shared it, and nothing more. `share_show` reports the same for agents: `derived` (kind, source ids, and any deleted since) for your own fact, `shared_by` for anyone else's. ## Reading back what you shared The dashboard's **History** tab (`shmem dashboard`, `#/history`) reads one space back at a time: one moment per share, holding only the facts still in the space, dated by when those facts were written rather than when they were shared. A timeline counts moments per week; below it the moments are grouped by week, newest or oldest first, with a search box and each moment's full text on expand. A moment is titled by its headline when it has one (your own nomination shares, and narrated shares for every reader), else by its first line that isn't a tool call. Your own moments have an **Unshare** button, which asks before it retracts and goes through the same `unshare_facts` every other surface uses. This is the place to read what a history replay run with `--auto-share` (`shmem share scan --since all --auto-share`) placed, and pull back what shouldn't be there. Like the other sharing views, it needs a shmem server. ## Deleting a shared fact Deleting a fact that sits in a shared space retracts it first. `shmem delete`, `shmem admin project delete`, the local dashboard's delete and prune, and a local agent's `delete_memory` all unshare the fact from every space you can **write** to, then delete it. Each unshare writes the usual tombstone, so readers drop their copies on their next sync. - A space you can only **read** is left alone. If such a space still holds the fact, it is retracted from your writable spaces but kept, and the delete says so: deleting it locally would be undone by the next sync of that space. Ask the space's owner to remove it. - Authorship doesn't matter, write access does: you can delete a teammate's fact out of a space you have `rw` on, and you cannot pull your own fact out of a space you can only read. - With a hosted server, the server does the retracting from your own projects, because that is where their grants live. Its `delete_memory` and `delete_project` write the tombstone into every shared project of yours that holds the fact before deleting it, so a project shared from another machine, or by an agent talking to the server directly, is covered too. - As a backstop, a sync re-reads a shared space in full when you hold more of its facts than the server says it has, and drops the local copies the space no longer holds. This clears facts deleted before the server wrote tombstones. Against an older server that doesn't report the count, the full re-read runs every few hours instead. - In hosted mode `shmem delete` deletes on the server first. If the server can't be reached or refuses, the delete fails and nothing is deleted, so you can simply retry. ## Losing access to a space When you lose read access to a space, because its owner deleted it, revoked the grant, or removed you from the group, your next sync drops what it brought in. Every local membership in that space goes, and a teammate's fact left with no membership is deleted. Your own facts leave the space but stay in your store. If access comes back, the space is pulled again from the start. Sync usually runs in the background, so shmem records each space it drops. For 30 days afterwards, `shmem admin status` and the `get_stats` tool name the space and how many facts left with it: ``` Notice: alice/notes is no longer shared with you; sync removed 20000 of its facts from this store on 2026-10-26. ``` The drop only happens on a complete answer from the server. If the server is unreachable, or could not read some projects while building the list, nothing is dropped that sync. ## Concurrency: loud, first-writer-wins The server arbitrates concurrent cross-user writes under its write lock with one rule: *the membership row either exists or it doesn't*. - A second writer sharing the same fact into the same space is rejected: `already in project` — pull and re-check. - A second writer retracting an already-retracted fact is rejected: `not in project (already retracted?)`. Nothing forks silently; the loser of a race finds out immediately. ## Trust model Sharing is built for **trusted groups**. Anyone with `rw` on a space can share into it and retract *any* fact from it — including yours. The counterweight is attribution: every membership row and every event is stamped with the actor's identity. The accountability mechanism is the record, not a permission wall. Unsharing removes the fact from the space you control. It does **not** chase copies a reader may have re-shared onward into spaces you cannot see. Nobody acts across an access boundary, and that includes a fact's author: reaching into a space you have no access to would make authorship a second, unaccountable permission. Instead, `unshare` warns you which visible spaces still hold the fact, and `--everywhere` retracts from all of them. ## Safety layers (defense in depth) 1. **Never rules** (natural language, in `share-rules.yml`): what must not be shared. Global rules are content-sensitivity policy; per-project `never:` rules protect a *target* — they apply to everything shared INTO that project. The scan skips matching moments, or ships a version that leaves the protected content out: the span with those parts replaced by placeholders, or, when that won't do, a narrated record; never criteria ride into both as strict omissions. A manual single-fact share deliberately bypasses this screening — you named the fact; the system doesn't second-guess you. 2. **Deterministic share filters** (`.shmemignore`: redact / substitute / drop) run at the boundary on every share, fail closed: the rules of the project each fact came from, then the project it's shared into, then your global rules and shmem's built-in credential rules. A redact/substitute hit mints the cleaned content as a new private fact and ships that — every shared fact is byte-identical to a fact in your store. A drop hit blocks the share loudly. 3. **The ledger**: every act — shares, unshares, grants, discards, forgets — in an append-only private record. ## Turning sharing on Sharing needs a shmem server: it is how what you share reaches anyone else. With no remote, the sharing verbs and tools say so and nothing scans. Connect one with `shmem login`; the hosted one, or your own, which is the same `shmem-mcp`. Your sharing workspace lives on the server, in your account: your share rules, your nominations, and your private ledger. Every client you use reaches the same one. The CLI's verbs call the server's sharing tools, a local `shmem-mcp` relays its sharing tools to your remote, and an MCP-only client (one with no `shmem` binary, such as a claude.ai connector) calls them directly. Sharing is **off** until you turn it on for your account: ```bash shmem share enable # or ask your agent to turn sharing on (set_sharing) shmem share disable # stops the scans and the verbs; nothing shared is retracted ``` With it on, the server runs your share rules over the facts you store, which sends those facts to the server's LLM provider. It only ever NOMINATES: nothing is shared without an explicit share or a share-mode rule you wrote. The server's operator offers sharing by setting `SHMEM_SHARING=on` on the server. An operator that decides for its users, such as an app built on shmem, also sets `SHMEM_ACCOUNT_SHARING=on`, and accounts start with sharing on; turning it off still holds. If sharing was on for your machine (`SHMEM_SHARING=on` in its environment) before sharing moved to the server, the first sharing command or hook run against the server moves your share rules and history there and turns sharing on for your account, so your rules keep running; it says so once. A setting you already chose on the server stands. The server scans after your writes reach it, once a scan is due (enough new facts and the cooldown passed, or an hour for a few facts). It reads facts by when it received them, so what a client captured offline and pushed later is still scanned; a backlog older than a week, such as a new client's first push, is not. A scan reads as many facts as one evaluation holds; when more are waiting, the next scan starts right away, without waiting out the cooldown. What a scan nominates or auto-shares reaches your agent with your next message (through the hooks), in the next tool response for an MCP-only client, or from `share_updates`. `SHMEM_SCAN=off` silences that delivery on your machine. `shmem share scan` asks for a scan now. Scans only read what arrives, so memory written before you turned sharing on, or before you changed your rules, is never evaluated on its own. `shmem share scan --since 2026-03-01` (or `--since all`) replays it: the server cuts that history into stretches and works through several at once in the background, one working session per evaluation, under your current rules, leaving the scans of new memory to carry on as usual. Anything already shared, nominated or discarded is skipped as it would be for new facts. `shmem share` shows how far the replay has got, and which mode it runs in. A replay only nominates. What a `mode: share` rule matches in older memory is staged for your review, aimed at the rule's target, as a draft rule's would be: a replay reads weeks of work in minutes, and shares placed at that rate reach a space's readers before you have looked at one. To have those rules share what the replay finds, as they do for new memory, ask for it by name: `shmem share scan --since all --auto-share` (for an agent, `scan_shares` with `auto_share`). A replay started that way says so when it starts and in `shmem share`. ### Clearing nominations There are two ways to take a nomination off your review list, and they mean different things: - **`shmem share discard `** is "no, never". The decision is recorded, and no scan nominates those facts again. - **`shmem share forget ...`** is "clear it; it may come back". Nothing about the nomination is kept, so a later scan that reads those facts judges them afresh under your rules as they are then. Forget is for iterating on rules. A replay skips whatever is already nominated, so after changing a rule, the nominations the old rule produced would otherwise stay as they are: ```console $ shmem share forget --all # clear everything awaiting review $ shmem share scan --since 2026-03-01 # replay under the current rules ``` `--all` takes only what awaits review. Add `--discarded` to clear your discards too, so those facts can be nominated again; to undo one discard, name it. Forgetting on its own proposes nothing: scans read only memory that arrived since the last one, so a forgotten moment returns when a replay (`shmem share scan --since ...`) covers it. Run `forget --all` once a replay has finished, since one still running goes on nominating. Forget shares and unshares nothing, and a nomination you already shared can't be forgotten (`shmem unshare` pulls a share back). Your own facts are untouched. The redacted stand-ins or narrated lines a scan wrote for a forgotten nomination exist only to be shared by it, so they are deleted with it, unless a share placed them somewhere or another nomination still names them; the next nomination of that moment writes its own. Each forget is recorded in your private ledger (`shmem share log --all`). For a server's operator: scans run on the server's QA model unless `SHMEM_SCAN_PROVIDER` / `SHMEM_SCAN_MODEL` say otherwise, at most `SHMEM_SCAN_WORKERS` (default 2) run at once, and `SHMEM_SCAN=off` on the server turns them off. A history replay runs `SHMEM_REPLAY_WORKERS` (default 8) windows at once for the account that asked for it. ## For agents The MCP server exposes the same flows, so an agent never needs the shell: `scan_shares` and `distill_facts` are always safe (nothing is shared); `share_status` shows what's waiting, `share_log` is the shared history, and `share_show ` digs into where one fact is visible right now; `share_facts` requires the user's explicit agreement in conversation (or a share-mode rule); `unshare_facts` pulls things back. The conversation is the editor: user refinements arrive as `share_facts`' `edited_content`, which mints the fact that ships. Re-sharing with changes is `unshare_facts` followed by `share_facts` with `edited_content`. See [sharing rules](../sharing-rules/) for the rules file agents may be asked to configure. --- # Source: https://shmem.secondmoment.ai/docs/latest/shmemignore/ --- # Filtering what gets captured (.shmemignore) Hooks capture entire conversations, which may include API keys, passwords, or other sensitive data. shmem filters content through `.shmemignore` rules before it's stored. Credentials are the most important use, but not the only one — `.shmemignore` is also how you keep repetitive noise out of the store in the first place. See [capture hygiene](#capture-hygiene) below. **Credential filters are built in.** shmem redacts common credential shapes on every capture and every share, whatever your files say: Anthropic, OpenAI (modern + classic), OpenRouter, Google/Gemini, AWS access key IDs (long-term and temporary), GitHub tokens (classic and fine-grained), Slack tokens, private key blocks (PEM, OpenSSH, PGP), shmem bearer tokens, and a fallback for other providers' `sk-