mem0-scope
Views or changes the default memory scope (project, session, or global) used when saving and searching memories. Use when the user wants to control whether memories are scoped to this repo, this run, or shared across all their projects.
- License 许可
- Apache-2.0
- 最近更新
- 2026-08-12
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- mem0-scope
- description
- Views or changes the default memory scope (project, session, or global) used when saving and searching memories. Use when the user wants to control whether memories are scoped to this repo, this run, or shared across all their projects.
03 SKILL.md 正文
Mem0 Scope
View or change the default memory scope — the scope the memory tools use when
no explicit scope is given. The setting persists in ~/.mem0/settings.json
(default_scope) and the plugin reads it fresh on each memory operation, so a
change takes effect immediately in the current session.
The three scopes:
project(default) — this repo only. Filters byuser_id+app_id.session— this run only. Addsrun_id(the current session) so memories are isolated to this conversation.global— across ALL your projects. Reads useapp_id="*"; writes dropapp_idso the memory is user-wide.
Execution
Step 1: Determine intent
Look at the user's message for a target scope word: project, session, or
global (also accept "repo"→project, "run"→session, "all"/"everywhere"→global).
- No target word present → View mode (Step 2).
- A target word present → Change mode (Step 3).
Step 2: View mode — show the current scope
-
Read the current default scope from settings:
_S="$HOME/.mem0/settings.json" [ -f "$_S" ] && grep -o '"default_scope"[[:space:]]*:[[:space:]]*"[a-z]*"' "$_S" | grep -o '[a-z]*"$' | tr -d '"' || echo "project"If the command prints nothing, the scope is
project(the default). -
(Optional) Show how many memories live in the current scope by calling
get_memorieswithscope="<current>",page_size=1, and reading thecount(or result length) from the response. -
Display using the identity the plugin exported (do NOT re-shell git):
Mem0 memory scope Current default scope: <current> project - this repo only (user + app_id) <marker if active> session - this run only (adds run_id) <marker if active> global - all your projects (app_id = *) <marker if active> User: ${MEM0_USER_ID} Project: ${MEM0_APP_ID} Session: ${MEM0_SESSION_ID} To change: /mem0-scope session (or project / global)Put
[active]next to the current scope. If you fetched a count in step 2, add aMemories in scope: <N>line.
Step 3: Change mode — set a new scope
-
Validate the target is one of
project,session,global. If not, show the three options and stop. -
Read the existing settings so you preserve every other key. Use the Read tool on
~/.mem0/settings.json(it may not exist yet — treat a missing file as{}). -
Write the file back with the Write tool, keeping ALL existing keys and only setting
"default_scope"to the target. Pretty-print with 2-space indent and a trailing newline. Do not dropglobal_search,dream,auto_save, or any other field that was present.Example resulting file (when other keys already existed):
{ "auto_save": true, "search_limit": 10, "default_scope": "global" } -
Confirm:
Default memory scope changed: <old> -> <new> <one line describing the effect — see below> Applies immediately to memory tools in this session. To revert: /mem0-scope <old>Effect lines:
- project → "New memories and searches are limited to this repo."
- session → "New memories and searches are limited to this run (this conversation)."
- global → "New memories and searches span all your projects. delete_all_memories still needs an explicit scope=global to delete user-wide."
Notes
- This only changes the default. Any memory tool call can still pass an
explicit
scopeto override it for that one call. delete_all_memoriesdeliberately ignores the default scope: deleting user-wide always requires an explicitscope="global", so changing the default can never turn a routine cleanup into a cross-project wipe.globalscope (this user, all their projects) is distinct from the separateglobal_searchsetting (all users). Leaveglobal_searchuntouched here.
Output formatting
IMPORTANT: Do NOT use markdown in your output. OpenCode TUI renders text verbatim — markdown like bold, ## headers, and | table | syntax appears as raw characters. Use plain text with indentation for structure. Use dashes for lists. Use spaces to align columns instead of markdown tables.
04 同仓库更多 Skills
mem0
Mem0 Platform SDK for adding persistent memory to AI applications. TRIGGER when: user mentions "mem0", "MemoryClient", "memory layer", "remember user preferences", "persistent context", "personalization", or needs to add long-term memory to chatbots, agents, or AI apps. Covers Python SDK (mem0ai), TypeScript SDK (mem0ai), and framework integrations (LangChain, CrewAI, OpenAI Agents SDK, Pipecat, LlamaIndex, AutoGen, LangGraph). Also covers the open-source self-hosted Memory class. This is the DEFAULT mem0 skill for ambiguous queries. DO NOT TRIGGER when: user asks about CLI commands, terminal usage, or shell scripts (use mem0-cli), or Vercel AI SDK / @mem0/vercel-ai-provider / createMem0 (use mem0-vercel-ai-sdk).
mem0-vercel-ai-sdk
Mem0 provider for Vercel AI SDK (@mem0/vercel-ai-provider). TRIGGER when: user mentions "vercel ai sdk", "@mem0/vercel-ai-provider", "createMem0", "retrieveMemories", "addMemories", "getMemories", "searchMemories", "mem0 vercel", "AI SDK provider", "AI SDK memory", or is using generateText/streamText with mem0. Also triggers for Next.js apps needing memory-augmented AI. DO NOT TRIGGER when: user asks about direct Python/TS SDK calls without Vercel (use mem0 skill), or CLI terminal commands (use mem0-cli skill).
mem0-test-integration
Verify a Mem0 integration produced by /mem0-integrate. Runs in the same workspace on the same branch (loose coupling) — installs dependencies, runs the repo's native test suite, then exercises a real end-to-end smoke flow against the user's API key. Produces a scorecard. TRIGGER when: user has just run /mem0-integrate and says "verify", "test the integration", "run /mem0-test-integration", or when a .mem0-integration/ directory exists and tests have not been run yet on the current branch. DO NOT TRIGGER when: the user wants to run general project tests (defer to the repo's native test command), or when no prior /mem0-integrate run exists in the current branch (ask them to run /mem0-integrate first). This skill ONLY catches compile and runtime bugs by design. Logical integration errors — wrong data stored, wrong time retrieved, wrong user scoping — are on the human reviewer.
mem0-oss-to-platform
Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local `Memory` class) to the mem0 Platform / hosted / managed SDK (the `MemoryClient` class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g. "migrate my mem0 setup to the platform", "switch from self-hosted mem0 to MemoryClient", "use my mem0 API key instead of a local Qdrant", "move mem0 to the cloud/hosted/managed service", or "replace my local mem0 vector store + embedder config with the platform". Applies to Python (`from mem0 import Memory` → `from mem0 import MemoryClient`) and TypeScript/JavaScript (`import { Memory } from "mem0ai/oss"` → `import MemoryClient from "mem0ai"`). Trigger even when the user doesn't say the word "migrate" but clearly wants their existing mem0 integration to run against the hosted platform. It first produces a reviewable migration plan, then executes it after the developer approves. Strictly scoped to the mem0 integration — it does not refactor, restructure, or "improve" any unrelated code.
mem0-integrate
Integrate Mem0 into an existing repository using a goal-driven, TDD pipeline. Detects the repo's language automatically and asks the user to pick between Mem0 Platform (managed) and Mem0 Open Source (self-hosted). Writes failing tests before any implementation. Produces a local feature branch plus `.mem0-integration/` artifacts consumed by the paired verification skill. TRIGGER when: user says "integrate mem0", "add mem0 to this repo", "wire mem0 into <repo>", or asks how to add memory to an existing project. DO NOT TRIGGER when: the user wants general SDK usage (use skill:mem0), CLI usage (use skill:mem0-cli), or Vercel AI SDK (use skill:mem0-vercel-ai-sdk). After success, invoke skill:mem0-test-integration to verify in the same workspace (loose coupling).
mem0-cli
Mem0 CLI -- the command-line interface for mem0 memory operations. TRIGGER when: user mentions "mem0 cli", "mem0 command line", "@mem0/cli", "mem0-cli", "pip install mem0-cli", "npm install -g @mem0/cli", or is running mem0 commands in a terminal/shell (mem0 add, mem0 search, mem0 list, mem0 get, mem0 init, mem0 config, mem0 import). Also triggers when query includes CLI flags like --user-id, --output, --json, --agent, or describes bash/zsh/terminal/shell usage. DO NOT TRIGGER when: user asks about programmatic SDK integration in Python/TS code (use mem0 skill), or Vercel AI SDK provider (use mem0-vercel-ai-sdk skill).