About switch-project
A Mem0 skill for changing the project scope used for the current directory or enabling global memory search. It stores project mappings and search settings in local files.
Key features
- 01Set a project scope for a directory
- 02Enable global memory search
- 03Disable global memory search
- 04Persist settings in local files
Use cases
- 01Scope memory searches to a named project
- 02Search memories across projects and users
- 03Restore per-project search scope
MCP support
Verifies a project change by searching memories with the Mem0 MCP search_memories tool.
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ mem0ai/ mem0 --skill switch-projectAfter installing, type/switch-projectin Claude Code to confirm it loaded.
Details
From the project READMEMem0 Switch Project
Override the automatic project_id detection for the current directory, or enable global search mode.
Usage
/mem0:switch-project <project-name>— switch to a specific project scope/mem0:switch-project --global— enable global search (all memories, all users, all projects)/mem0:switch-project --no-global— disable global search and return to per-project scoping
Execution
If --global flag is provided:
-
Set
global_search: truein~/.mem0/settings.jsonusing the Bash tool:python3 -c " import json, os settings_file = os.path.expanduser('~/.mem0/settings.json') settings = {} if os.path.isfile(settings_file): with open(settings_file) as f: settings = json.load(f) settings['global_search'] = True with open(settings_file, 'w') as f: json.dump(settings, f, indent=2) print('Global search enabled') " -
Print:
Global search enabled. Searches now return all memories across all users and projects. Writes still use the current user_id and app_id. Restart the session for the change to take effect.
If --no-global flag is provided:
-
Set
global_search: falsein~/.mem0/settings.jsonusing the Bash tool:python3 -c " import json, os settings_file = os.path.expanduser('~/.mem0/settings.json') settings = {} if os.path.isfile(settings_file): with open(settings_file) as f: settings = json.load(f) settings['global_search'] = False with open(settings_file, 'w') as f: json.dump(settings, f, indent=2) print('Global search disabled') " -
Print:
Global search disabled. Searches now return only memories scoped to the current project. Restart the session for the change to take effect.
If a project name is provided (no flags):
-
If no project name was given, ask: "What project_id should this directory use?"
-
Write the mapping to
~/.mem0/project_map.jsonusing the Bash tool:python3 -c " import json, os map_file = os.path.expanduser('~/.mem0/project_map.json') mapping = {} if os.path.isfile(map_file): with open(map_file) as f: mapping = json.load(f) mapping[os.getcwd()] = '<PROJECT_NAME>' os.makedirs(os.path.dirname(map_file), exist_ok=True) with open(map_file, 'w') as f: json.dump(mapping, f, indent=2) print(f'Mapped {os.getcwd()} -> <PROJECT_NAME>') "(Replace
<PROJECT_NAME>with the user's chosen project name.) -
Verify by searching for existing memories:
- Call
search_memorieswithquery="project",filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<PROJECT_NAME>"}]},top_k=1
- Call
-
Print:
Switched to project <PROJECT_NAME>. <N> memories found for this project. Note: This override persists across sessions for this directory.