Overview
Shared memory for AI coding agents: installs a collector, a local SQLite vector store and one MCP search tool so Claude Code, Codex and Gemini CLI share memory
Without: your tools keep separate memory files, and useful context stays in the tool that learned it.
With: the memory files you choose are collected into one SQLite store, scanned before storing, and searchable from every AI through one MCP tool, memory_search. Add a YAML profile to support another tool.
npx shared-agent-memoryRequires Node >=22 with node:sqlite. Setup shows detected sources and asks for confirmation or edits. It prints companion install commands when needed. It never installs companions or edits an AI tool's configuration.
For agents: read llms.txt and AGENTS.md. Run setup headless with npx shared-agent-memory --yes.
Watch the pipeline · How it works · Open an issue
| Item | Location | Purpose |
|---|---|---|
| Source config | ~/.config/shared-agent-memory/sources.yaml |
Selected paths and kinds |
| Settings | ~/.config/shared-agent-memory/config.json |
Server address and device |
| State and database | ~/.local/state/shared-agent-memory/ |
Acknowledged fingerprints and SQLite |
| Scheduler | Tool-owned launchd or systemd user entry | Collect every 3 hours with catch-up |
| Manifest | Config folder | Hashes of files setup wrote |
XDG_CONFIG_HOME and XDG_STATE_HOME override those roots. Other platforms print a cron line.
- Supply distinct
SAM_WRITE_KEYandSAM_READ_KEYthrough your environment. Keys stay out of files, logs and URLs. - Let the scheduler inherit the write key from your environment manager. Setup never persists it.
- Use the same device identity on every collection from this machine.
- Check the install, start the server, collect and search:
shared-agent-memory doctor
shared-agent-memory serve
shared-agent-memory collect
shared-agent-memory search "project conventions"- Point an MCP host at the
shared-agent-memorycommand with argumentsmcp --ai <profile tool>, for examplemcp --ai codex-cli. - Supply
SAM_READ_KEYin that host's environment.
The stdio transport exposes only memory_search(query, scope, k, device). scope defaults to own.
- Configure separate server processes and keys if AI identities need a security boundary.
- A client holding the shared read key can choose its AI identity.
- Claude Code, Codex CLI and Gemini CLI profiles collect documented instruction paths.
- Claude Code also collects documented auto memory.
- ChatGPT accepts an extracted export in the tool's
inbox/folder when enabled. - Transcripts default off. Undocumented paths are omitted. See every path.
Detection checks documented folders and explicit project paths, without running the AI tools. Overrides in sources.yaml win. Files are read without following symlinks. Unreadable inputs abort collection, preserving the last inventory. Binary and oversize files are excluded.
- SQLite with sqlite-vec holds text, vectors, provenance and tags.
- Ollama supplies
nomic-embed-textembeddings with 768 dimensions. - The deterministic hash embedder is for tests and explicit
--embedder hashruns. It is useful for exercising the pipeline, with weaker semantic ranking.
The server binds to 127.0.0.1 by default. --host can bind a private-network address. Use an encrypted private network for remote HTTP transport. Requests use bearer headers. Keep the server off the public Internet.
- The default scanner runs your installed gitleaks.
- An absent or failed scanner refuses the whole batch.
- Explicit
--scanner builtinselects a weaker regex scanner for common token shapes. It cannot detect every secret. Review sources before opting in.
Put rules in privacy-tags.yaml in the config folder:
rules:
- tag: private
path: "*private*"
pattern: "personal"
allow: ["claude-code"]- A rule matches its path or a literal content substring. In privacy paths,
*spans directories. - Every matched tag must allow the querying AI. Unlisted tags deny access.
- Privacy filtering happens before ranking.
- Returned hits are framed as stored data, never instructions.
- A lock prevents overlapping collectors.
- Full inventories travel with each batch.
- Fingerprints advance only for acknowledged files.
- An empty inventory is refused.
- Removing more than half and more than 20 stored file rows is refused.
- Use
rebuild --dryto inspect counts andrebuild --confirmto replace a store through the same scanner and embedding pipeline. Rebuild preserves the old store if any batch fails.
Can every AI tool use this memory?
- Any host that supports MCP stdio can search it.
- Source collection needs a profile. Add one for a tool whose files are documented.
Where does my memory go?
- It stays in the configured SQLite database and your existing source files.
- Embedding requests go to local Ollama by default. Follow the pipeline.
How do I enable transcripts?
- Edit a source entry in
sources.yamland setenabled: true. - Only documented transcript kinds are offered. ChatGPT exports are opt-in transcripts.
Why did collection refuse a batch?
- Run
doctor. Check scanner availability, distinct keys, source readability and deletion counts. - Refused files do not advance local fingerprints.
How do I use a private network?
- Bind
serve --hostto its private address. - Set
serverinconfig.json. - Keep transport inside an encrypted private network. The read key and the write key must differ.
- Preview with
shared-agent-memory uninstall --dry. - Remove with
shared-agent-memory uninstall.
- Preview and removal print identical action rows when files stay unchanged. Edited files are kept.
- The database is kept unless you pass
--purge. Purge encrypts a verified backup with the write key and writes a receipt before removal. shared-agent-memory restoredecrypts that backup into a new tool-owned directory. Keep the write key to recover it.- Stop the server before purging.
- Missing manifests exit 2 with their path. Re-run setup to restore tool-owned setup files.
- Uninstall never removes an AI's source files.
- Interactive explainer: watch a memory travel the pipeline. Open the file in a browser.
- How it works.
- Where memory lives.
- Write a profile.
- Build brief.
- Stack and budgets.
See CONTRIBUTING.md for profiles, adapters and docs fixes. Run npm test and npm run typecheck before opening a pull request.
- sqlite-vec, by Alex Garcia. MIT or Apache-2.0.
- gitleaks. MIT.
- Ollama. MIT.
- nomic-embed-text. Apache-2.0.
- Model Context Protocol specification. MIT.
- Departure Mono, by Helena Zhang, for the README headings. SIL Open Font License 1.1.
Full list: CREDITS.md.
MIT. Auny LLC and contributors.
