New to Claude Skills? Learn how to install them →

mem0ai on GitHub

Mem0 Scope

Free

Control memory scope for saving and searching.

by mem0ai63k stars on mem0ai/mem0
Updated Aug 7, 2026
Get this skill

Free · Opens the source repo

What Mem0 Scope does

Mem0 Scope is a utility designed to manage the default memory scope used by memory tools within the Mem0 framework. It allows users to define whether their memories are scoped to a specific project, limited to the current session, or shared globally across all projects. This flexibility is crucial for developers and designers who want to maintain organization and control over their memory data, ensuring that it is accessible only when needed.

The skill operates in two modes: view and change. In view mode, users can quickly check the current default memory scope, which is stored in a settings file. This mode also provides insights into how many memories exist within the current scope, allowing for better management of memory resources. When users want to change the scope, they can easily switch between project, session, and global scopes, with immediate effect on all memory operations in the current session.

Mem0 Scope is particularly useful for those who work on multiple projects or in collaborative environments where memory management can become complex. By allowing users to isolate memories to specific projects or sessions, it helps prevent data clutter and ensures that relevant information is easily retrievable. This skill is ideal for developers and designers who prioritize organization and efficiency in their workflows.

When to use it

Use Mem0 Scope when you need to control the context of your memories, whether for a single project, a temporary session, or across multiple projects.

When not to use it

This skill may not be necessary for users who only work on a single project or do not require memory isolation.

What you can build with it

Isolating Project Memories

Use Mem0 Scope to ensure that memories related to a specific project do not interfere with others, keeping your data organized.

Temporary Session Management

Switch to session scope during a temporary task or brainstorming session to isolate memories relevant only to that context.

Global Memory Access

Set the scope to global when you need to access memories across multiple projects, ensuring you have all relevant data at your fingertips.

How to install Mem0 Scope

View source

1. Install with the skills CLI

npx skills add mem0ai/mem0/mem0-scope --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mem0ai

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 by user_id + app_id.
  • session — this run only. Adds run_id (the current session) so memories are isolated to this conversation.
  • global — across ALL your projects. Reads use app_id="*"; writes drop app_id so 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

  1. 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).

  2. (Optional) Show how many memories live in the current scope by calling get_memories with scope="<current>", page_size=1, and reading the count (or result length) from the response.

  3. 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 a Memories in scope: <N> line.

Step 3: Change mode — set a new scope

  1. Validate the target is one of project, session, global. If not, show the three options and stop.

  2. 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 {}).

  3. 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 drop global_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"
    }
    
  4. 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 scope to override it for that one call.
  • delete_all_memories deliberately ignores the default scope: deleting user-wide always requires an explicit scope="global", so changing the default can never turn a routine cleanup into a cross-project wipe.
  • global scope (this user, all their projects) is distinct from the separate global_search setting (all users). Leave global_search untouched 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.

Frequently asked questions about Mem0 Scope

Similar skills