Unified memory across OpenCode and Claude Code using claude-mem.
- Real-time sync: Automatically captures OpenCode conversations and syncs them to claude-mem
- Memory search: Query your claude-mem memories from within OpenCode via MCP
- Cross-platform context: Memories from Claude Code sessions are searchable in OpenCode and vice versa
- OpenCode installed
- claude-mem v7.0+ installed (as a Claude Code plugin or standalone)
- Node.js 18+
# Clone the repo
git clone https://github.com/yourusername/opencode-claude-mem.git
cd opencode-claude-mem
# Run the installer
./install.shAdd claude-mem's MCP server to your OpenCode config. Create or edit ~/.config/opencode/.opencode.json:
{
"mcpServers": {
"claude-mem": {
"type": "stdio",
"command": "node",
"args": ["~/.claude/plugins/cache/thedotmack/claude-mem/VERSION/scripts/mcp-server.cjs"]
}
}
}Replace VERSION with your installed claude-mem version (e.g., 8.2.0).
# Create scripts directory
mkdir -p ~/.opencode/scripts
# Copy sync scripts
cp scripts/mem-sync.js ~/.opencode/scripts/
cp scripts/mem-sync-daemon.js ~/.opencode/scripts/
# Make executable
chmod +x ~/.opencode/scripts/mem-sync.js
chmod +x ~/.opencode/scripts/mem-sync-daemon.js# Create commands directory
mkdir -p ~/.opencode/command
# Copy commands
cp commands/mem-sync.md ~/.opencode/command/
cp commands/mem-daemon.md ~/.opencode/command/# Start manually
node ~/.opencode/scripts/mem-sync-daemon.js start
# Check status
node ~/.opencode/scripts/mem-sync-daemon.js status# Copy and customize the launchd plist
cp launchd/com.opencode.mem-sync.plist ~/Library/LaunchAgents/
# Edit the plist to match your node path
# Find your node path with: which node
# Load the service
launchctl load ~/Library/LaunchAgents/com.opencode.mem-sync.plist| Command | Description |
|---|---|
/mem-sync |
Manually sync recent sessions to claude-mem |
/mem-sync --all |
Sync all OpenCode sessions |
/mem-sync --since 48 |
Sync sessions from last 48 hours |
/mem-daemon |
Show daemon control commands |
# Check if daemon is running
node ~/.opencode/scripts/mem-sync-daemon.js status
# Start daemon
node ~/.opencode/scripts/mem-sync-daemon.js start
# Stop daemon
node ~/.opencode/scripts/mem-sync-daemon.js stopOnce configured, OpenCode can use claude-mem's MCP tools to search memories:
search- Semantic search across all memoriestimeline- View memories chronologicallyget_recent_context- Get context from recent sessions
┌─────────────┐ ┌──────────────────┐ ┌─────────────┐
│ OpenCode │────▶│ Sync Daemon │────▶│ Claude-Mem │
│ Sessions │ │ (file watcher) │ │ Worker │
└─────────────┘ └──────────────────┘ └─────────────┘
│
▼
┌─────────────┐
│ SQLite │
│ Database │
└─────────────┘
│
┌───────────────────────────────┼───────────────────────────────┐
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ OpenCode │ │ Claude Code │ │ Viewer │
│ (MCP search)│ │ (hooks) │ │ (web UI) │
└─────────────┘ └─────────────┘ └─────────────┘
- File Watcher: Monitors
~/.local/share/opencode/storage/for new messages - Debouncing: Waits 3 seconds after last activity before syncing (batches rapid messages)
- Worker API: Submits conversations to claude-mem's worker for observation extraction
- MCP Server: Exposes search tools that OpenCode can query
| Variable | Default | Description |
|---|---|---|
CLAUDE_MEM_WORKER_PORT |
37777 |
Claude-mem worker port |
CLAUDE_MEM_WORKER_HOST |
127.0.0.1 |
Claude-mem worker host |
Edit the constants at the top of mem-sync-daemon.js:
const DEBOUNCE_MS = 3000; // Wait time after last activity
const SESSION_TIMEOUT_MS = 60000; // Consider session "done" after inactivity-
Check if claude-mem worker is running:
curl http://127.0.0.1:37777/health
-
Check daemon logs:
cat ~/.opencode/mem-sync-daemon.log
-
Verify the daemon is running:
node ~/.opencode/scripts/mem-sync-daemon.js status -
Check if sessions are being detected:
node ~/.opencode/scripts/mem-sync.js --dry-run -
View the claude-mem UI to see if observations are being created:
http://127.0.0.1:37777/
- Verify your
.opencode.jsonconfig is valid JSON - Check the claude-mem MCP server path exists
- Restart OpenCode after config changes
MIT
- claude-mem by Alex Newman
- OpenCode
- Integration by the community