Replies: 2 comments
-
|
this actually a known issue people are running into with agentic/worktree setups right now. Because codebase-memory-mcp is built on a local SQLite file, it natively hashes the explicit folder path to create isolated project indexes. When you spin up a new worktree, it treats it as a completely separate project and starts a full re-index from scratch. There is actually an open issue on their GitHub right now (#351) discussing adding automatic canonical repository detection to fix exactly this. Until that feature lands natively, your best workaround is to override the storage path in your config to point your worktrees to the exact same database file, or manually symlink the primary index file into your feature worktree directories. This video gives a quick, helpful overview of the inner workings of the tool: [codebase-memory-mcp overview https://www.youtube.com/watch?v=D2LtdUHtKJM |
Beta Was this translation helpful? Give feedback.
-
|
Yes, you can share the index between git worktrees. The key insight is that codebase-memory-mcp stores its index in a local database tied to the repository path, not the worktree. You just need to point all worktrees at the same index location. The approach: codebase-memory-mcp supports a Recommended setup: # In each worktree, set the DB path to a location under the shared .git dir
export CODEBASE_MEMORY_DB_PATH=/path/to/main/repo/.git/codebase-memory-index/Or, in your MCP client config (e.g., {
"mcpServers": {
"codebase-memory": {
"command": "codebase-memory",
"args": ["--project-db-path", "/path/to/shared/.git/codebase-memory-index/"],
"env": {
"CODEBASE_MEMORY_DB_PATH": "/path/to/shared/.git/codebase-memory-index/"
}
}
}
}Why
Alternative — symlink approach: # In each worktree
ln -s /path/to/main/repo/.cache/codebase-memory .codebase-memoryCaveat: If you're running concurrent indexing operations from different worktrees, you need write-locking to avoid database corruption. SQLite (which codebase-memory-mcp uses) handles simple read concurrency well, but concurrent writes from multiple worktrees could cause issues. A practical solution is to only run the indexer from one worktree at a time, and let others just read the shared index. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I am working with a large legacy project, and the codebase-memory-mcp really helps with both token usage and search.
My workflow includes creating separate git worktrees per feature I am implementing. Is it possible to share the index between git worktrees so I can spend less time indexing?
Beta Was this translation helpful? Give feedback.
All reactions