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 <host>/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.

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.

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, 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, 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.