Projects across repos
How shmem decides which project a captured memory belongs to, and how to work across several repositories. For the model itself, see Projects.
How captured memories are tagged
shmem install puts hooks at the user level (~/.claude/settings.json, ~/.codex/hooks.json, ~/.gemini/settings.json), so they fire for every session, regardless of which directory the agent is working in — including multi-directory agents like Cowork. Per-session routing works automatically:
- The agent starts a session in some directory. The hook subprocess receives the agent's JSON payload, which includes the session's
cwd. shmem hookwalks up from thatcwdlooking for a.shmem/projectmarker file.- If it finds one, memories are tagged with that project name. Otherwise memories are tagged with whatever
SHMEM_DEFAULT_PROJECTresolves to, ordefaultif unset. (All facts live in the same unified DB regardless — the project is just a tag for filtering, not a separate database.)
To give particular repos their own tags:
cd ~/projects/myapp && shmem init # opt myapp into its own project
cd ~/projects/infra && shmem init # opt infra into its own project
# any directory without `shmem init` falls back to `default`
Work in ~/projects/myapp is then tagged myapp, work in ~/projects/infra is tagged infra, everything else gets the default tag. The tag is what shmem ask --project NAME (or --here) filters by.
Cross-repo setup (multiple projects)
shmem stores everything in a single unified database; "project" is a tag column on each fact, not a separate database. See Projects for the full model. The short version:
- Per-directory routing:
shmem initwrites a.shmem/projectmarker so everyshmeminvocation from within that tree stamps writes with that project tag. The marker also drivesshmem ask --here. - Scope a query to a project:
shmem ask --project frontend "..."orshmem query --project frontend "...". - From within the project's directory:
shmem ask --here "..."is a zero-typing shortcut. - Cross-project query (the default!): just
shmem ask "..."— no flags. Searches across everything in the unified DB. - MCP server config: each
shmem-mcpinstance can be configured for a specific project tag viaSHMEM_PROJECTin the client's.mcp.jsonenvblock.
Managing projects
shmem admin project list # see all projects (legacy view; lists projects.json registry)
shmem admin project create my-app # register a project name
shmem admin project delete old-app # remove a project from the registry
These admin commands operate on the legacy projects.json registry. In the unified DB world, the project tag column is what actually matters — but the admin commands still work for managing the project list shown in shmem admin status and the dashboard.
Cross-project queries
This is now the default: shmem ask "..." and shmem query "..." search the unified DB across every project tag. To narrow:
shmem ask --here "what was I working on?" # current dir's project
shmem ask --project frontend "auth changes" # specific tag
shmem ask --mine "what did I decide last week?" # only your facts
shmem ask --here --mine --private "internal notes" # composed