Skip to main content

Build

Mem0 Scope

mem0OfficialCertified

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.

  • New
  • v1.0.0
  • Reviewed Sep 9
  • No reviews yet

Capabilities

  • Determine intent

    Look at the user's message for a target scope word: project, session…

  • View mode — show the current scope

    If the command prints nothing, the scope is project (the default)

  • Change mode — set a new scope

  • Output formatting

    Do NOT use markdown in your output

Getting started

Full instructions

Install the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.

Instructions: SKILL.mdv1.0.0

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:

    bash
    _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):

    text
    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, auto_save, or any
    other field that was present.

    Example resulting file (when other keys already existed):

    json
    {
      "auto_save": true,
      "search_limit": 10,
      "default_scope": "global"
    }
    
  4. Confirm:

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

Explore more skills

Browse all
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

More from mem0

View source →

Frequently asked questions about mem0-scope

What does the mem0-scope skill do?

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. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the mem0-scope skill?

Run `npx @skills-hub-ai/cli install mem0-scope` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/mem0-scope/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does mem0-scope work with?

mem0-scope runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the mem0-scope skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use mem0-scope after installing it?

In Claude Code, type `/mem0-scope` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the mem0-scope skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/mem0-scope)](https://skills-hub.ai/skills/mem0-scope)
HTML
<a href="https://skills-hub.ai/skills/mem0-scope"><img src="https://skills-hub.ai/api/badges/skill/mem0-scope" alt="Install on Skills Hub"></a>

More options in the badge docs.