OpenCode plugin for persistent memory using XMem.
Your agent remembers what you tell it — across sessions, across projects.
bunx opencode-xmem@latest installThis registers the plugin and opens browser login to connect your XMem account.
Or let your agent do it — paste this into OpenCode:
Install opencode-xmem by following https://raw.githubusercontent.com/xmem-ai/opencode-xmem/main/README.md
Instructions for LLM Agents (click to expand)
bunx opencode-xmem@latest install --no-tuiThis will:
- Register the plugin in
~/.config/opencode/opencode.jsonc - Create the
/xmem-init,/xmem-login, and/xmem-logoutcommands
cat ~/.config/opencode/opencode.jsoncShould contain:
{
"plugin": ["opencode-xmem@latest"]
}bunx opencode-xmem@latest loginOr set credentials manually:
export XMEM_API_KEY="xmem_..."
export XMEM_USERNAME="your_username"
export XMEM_API_URL="https://api.xmem.in"Restart OpenCode to load the plugin.
| Command | Description |
|---|---|
install |
Register plugin and create slash commands |
login |
Browser auth via xmem.in/auth/connect |
logout |
Clear ~/.xmem-opencode/credentials.json |
The plugin exposes an xmem tool to the coding agent:
| Mode | Description |
|---|---|
add |
Store a memory (content, optional scope) |
search |
Search raw memory records (query, optional scope) |
recall |
Get synthesized answer from memories (query, optional scope) |
code |
Query indexed codebase (query, orgId, repo) |
help |
Show usage guide |
Scopes:
user— cross-project preferencesproject— project-specific knowledge (default)
Optional config at ~/.config/opencode/xmem.jsonc:
- Auto-recall — Injects relevant memories on the first message of each session
- Keyword detection — Nudges the agent when you say "remember this"
- Preemptive compaction — Saves session summaries to XMem before context overflow
- Code memory — Query indexed repos via the
codetool mode
Apache-2.0
{ "maxMemories": 5, "maxProjectMemories": 10, "autoRecallEveryPrompt": true, "compactionThreshold": 0.80, "defaultOrgId": "your-org", "defaultRepo": "your-repo" }