Cross-Agent Memory Sharing
Brain Memory uses a single global directory — ~/.brain/ — that is shared across all supported AI agents. A decision stored by Claude Code in one project is immediately available to Gemini CLI or OpenAI Codex CLI in any other project, with no configuration, no export, and no per-project setup.
How It Works
All three supported agents read and write to the same ~/.brain/ directory:
~/.brain/ ← Single shared directory
├── index.json ← Shared index
├── associations.json ← Shared associative network
├── contexts.json ← Session contexts from all agents
├── professional/
│ └── decisions/
│ └── chose-kafka.md ← Created by Claude Code
├── personal/
│ └── education/
│ └── rust-ownership.md ← Created by Gemini CLI
└── ...
The format is agent-agnostic: plain Markdown files with YAML frontmatter. Any tool that can read Markdown can read your brain.
Agent-Agnostic Format
Brain Memory deliberately avoids any agent-specific constructs:
| Component | Format | Why |
|---|---|---|
| Memory files | Markdown with YAML frontmatter | Universal, human-readable |
| Index | JSON | Supported by every language and tool |
| Associations | JSON | Simple weighted edge graph |
| Configuration | JSON (in index.json) | No proprietary config format |
| Directory structure | Plain filesystem | Works on macOS, Linux, Windows |
No vendor lock-in. No proprietary binary formats. Your memories are yours.
What Gets Shared
Everything in ~/.brain/ is automatically shared:
- Memories — All memory files, regardless of which agent created them
- Associations — The full associative network, including links created by different agents
- Index — The central registry with all memory metadata
- Configuration — Brain settings apply to all agents uniformly
- Review queue — Spaced repetition schedule works across agents
- Contexts — Session context history from all agents (labeled by source)
What Does Not Get Shared
- Agent configuration — Each agent's command prompts and prompt sections are installed separately in their own config directories (
~/.claude/,~/.gemini/,~/.codex/) - Session state — Each agent maintains its own session context during active use
- Sync state — The
~/.brain/.sync/directory is local and agent-independent
Cross-Agent Scenarios
Scenario 1: Claude Code creates, Gemini CLI recalls
- You work on a project with Claude Code and run
/brain:memorize - Claude Code stores a decision memory in
~/.brain/professional/ - Later, you open a different project with Gemini CLI
- Gemini CLI loads the brain at session start and sees the memory
- When the topic comes up, Gemini CLI references it naturally
Scenario 2: Multiple agents in the same session
- You use Claude Code to analyze a codebase and memorize findings
- You switch to Gemini CLI for a different task in the same project
- Both agents share the same brain — Gemini sees what Claude stored
- Gemini CLI adds its own memories, which Claude Code will see next time
Scenario 3: Review queue across agents
/brain:sleepis run from Claude Code, populating the review queue- You open Gemini CLI and run
/brain:review - The review session uses the same queue generated by Claude Code
- Recalled memories are reinforced regardless of which agent does the review
No Configuration Needed
Cross-agent sharing requires no setup beyond installing Brain Memory for each agent. Since all agents read from and write to ~/.brain/, sharing is automatic.
The only requirement is that each agent has its own command prompts installed. During installation, you can choose to install for multiple agents at once:
npx brain-memory@beta --all --globalThis installs command prompts for Claude Code, Gemini CLI, and OpenAI Codex CLI simultaneously, all pointing to the same ~/.brain/ directory.
Each agent has slightly different command syntax (slash commands for Claude/Gemini, skills for Codex), but they all operate on the same underlying brain structure and data format.
If you primarily use one agent but occasionally switch to another, your brain context follows you seamlessly. There is no migration or export step — just start using the other agent.
Human Access
Because the format is plain Markdown, you can also browse and edit your brain directly:
- Open
~/.brain/in VS Code, Obsidian, or any file explorer - Read memory files with any text editor
- Search across memories with
grepor your editor's search - Edit memories manually if needed (be careful with frontmatter format)
- Use Git to track changes:
cd ~/.brain && git init && git add -A && git commit -m "snapshot"
Your brain is not locked inside any tool — it is always accessible.