feat: add workspace-based memory isolation#1319
Open
djonatas wants to merge 1 commit intothedotmack:mainfrom
Open
feat: add workspace-based memory isolation#1319djonatas wants to merge 1 commit intothedotmack:mainfrom
djonatas wants to merge 1 commit intothedotmack:mainfrom
Conversation
Add support for isolating memory data between different workspaces/clients. This enables complete data separation for consultants, agencies, or anyone working with multiple clients who need to prevent context leakage. Features: - Workspace detection based on CLAUDE_MEM_WORKSPACE_ROOTS env var - Separate SQLite databases per workspace - Shared context within workspace (desirable for related projects) - Graceful fallback to global database for unconfigured paths - Backwards compatible (no config = current behavior) New files: - src/utils/workspace.ts - Workspace detection and routing - src/shared/paths-workspace.ts - Workspace-aware path resolution - src/services/worker/WorkspaceDatabaseManager.ts - Multi-DB manager - src/cli/handlers/session-init-workspace.ts - Workspace-aware hook - docs/workspace-isolation.md - Complete documentation Tests: - 23 unit tests for workspace detection - 13 integration tests with real SQLite databases
|
Came across this repo, and was wondering how claude would differentiate if I have multiple claude code sessions running on different project. This feature is a must have imo. Thank you for implementing it |
Author
|
Thanks for the kind words! 🙏 To answer your question about how claude-mem differentiates between sessions: Without this feature (current behavior)
With workspace isolation (this PR)
Example setupexport CLAUDE_MEM_WORKSPACE_ROOTS="/home/me/work/clientA,/home/me/work/clientB"Now when you're working in Feel free to try it out once merged and let us know if you have any feedback! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for workspace-based memory isolation, allowing users to keep memory data completely separate between different clients, organizations, or project groups.
Closes #1318
Motivation
Currently, claude-mem stores all observations and session data in a single global SQLite database. While the
projectcolumn allows filtering by project name, there's no true isolation between different organizational contexts.Real-world use case: A consultant working with multiple clients needs to ensure that:
Changes
New Files
src/utils/workspace.tssrc/shared/paths-workspace.tssrc/services/worker/WorkspaceDatabaseManager.tssrc/cli/handlers/session-init-workspace.tsdocs/workspace-isolation.mdtests/unit/workspace.test.tstests/integration/workspace-isolation.test.tsTest Coverage
Total: 36 tests passing
Configuration
Environment Variable
Data Layout
Key Features
cwdpassed by hooksBackwards Compatibility
CLAUDE_MEM_WORKSPACE_ROOTSis not set, behavior is identical to current versionChecklist