Memory Lake for opencode

August 18, 2026 · View on GitHub

Long-term memory for opencode, backed by Memory Lake via the memorylake CLI.

opencode has no memory of its own. Its only ambient instructions are static AGENTS.md files, and it reads exactly two things from Claude Code — ~/.claude/CLAUDE.md and .claude/skills/. It does not read Claude Code's memory directory, so everything your assistant learned about you there is invisible here.

That is what this plugin fixes. If you already use the Claude Code plugin, your memories are available in opencode the moment you install this — you are connecting memory you already have, not starting a new collection.

Install

opencode plugin @memorylake/opencode-plugin -g

-g installs into ~/.config/opencode/opencode.json, so every project gets it; drop the flag to install into the current project only. The command edits the config for you and opencode fetches the package with Bun on next start.

By hand, the equivalent is an entry in opencode.json (project) or ~/.config/opencode/opencode.json (global):

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@memorylake/opencode-plugin"]
}

If you already ran /memorylake:init in Claude Code, or set up the Codex or dsh plugin, you are already configured — all four harnesses share one identity at ~/.memorylake/harness/, and the memory tools appear on next start.

Otherwise, ask opencode:

set up memorylake

It will call the plugin's memory_setup tool and walk you through the CLI, login, and config. opencode has to be restarted at the end: the plugin resolves its configuration when opencode loads it, so the memory tools cannot appear in a session that started before the config existed.

To configure by hand instead, install the memorylake CLI, log in (memorylake auth login --api-key sk-...), and write ~/.memorylake/harness/config.md:

---
enabled: true
workspace: ws-1234
actor: actor-…
---

A repository can override the global config with .opencode/memorylake.local.md (or .claude/memorylake.local.md, which the Claude Code plugin already reads — either works).

What it does

Recall. Three tools: memory_search, memory_remember, memory_forget. They are the same names the dsh plugin registers, so the vocabulary does not change when you switch harnesses.

Protocol. A block appended to the system prompt covers both directions: when to search and how to read results, and — equally — when to remember. Standing instructions ("from now on…"), corrections, decisions and their reasoning, and facts about how you want to be worked with all get stored as they happen, because a session can be compacted or closed at any moment and an unwritten fact is one you have to repeat.

It goes in the system prompt rather than the conversation for two reasons: opencode keeps the system prompt in a block separate from its cacheable header, and — unlike anything in the message history — it is never compacted away. So the instruction survives a long session, which is exactly when the model is most likely to forget that a memory backend exists. The block is ~900 tokens, byte-identical across a session, and omits the write half entirely when no actor is configured.

Compaction. opencode lets a plugin append to the prompt that generates a compaction summary. We add one line asking that durable facts, decisions, and corrections survive. Claude Code's equivalent hook cannot reach the model at all, so this is a capability we only have here.

Honesty about failure. If the backend is unreachable, the CLI is missing, or authentication has lapsed, the system block says so, in those words. This matters more than it sounds: a memory system that fails silently teaches the model to tell you that you never mentioned something.

Design differences from the other plugins

Claude Code / Codexopencode
Host memorynative auto-memory / engine summaries; we sync themnone — this plugin is the memory
Value on installbridges memory the host already keepssurfaces memory the host cannot see at all
Integrationshell hooks, jq requiredin-process TypeScript, no external tools
Protocol locationa skill, in the conversation (compactable)the system prompt (never compacted)
CompactionPreCompact cannot inject into model contextthe compaction prompt itself is extensible
Writesintercept the model's own memory writesthe model calls memory_remember

Requirements

  • opencode ≥ 1.16
  • the memorylake CLI on PATH, or installed privately at ~/.memorylake/bin/memorylake by any harness's setup

No jq and no shell: the plugin runs in-process and invokes the CLI with execFile, never through a shell. (opencode's $ is undefined outside Bun, and passing arbitrary query text through a shell is a quoting hazard we have no reason to accept.)

Privacy

  • memory_search sends your query text to your workspace
  • memory_remember sends exactly the fact text the model passes it
  • conversations are never uploaded. This plugin does not read transcripts and has no "capture the session" mode
  • with no config file, nothing is sent anywhere and no network call is made: the plugin offers a memory_setup tool and tells the model it has no memory
  • with enabled: false, nothing at all is registered or injected

Uninstall

Remove the @memorylake/opencode-plugin entry from whichever opencode.json it was added to. The shared data tree (~/.memorylake/harness/) and CLI credentials (~/.memorylake/) belong to all four harnesses — remove them only if you are done with every one.

Development

npm install
npm run typecheck
npm test
npm run build

test/setup.ts redirects MEMORYLAKE_PLUGIN_DATA for the whole suite, so tests cannot touch a real ~/.memorylake tree.

To run a local build inside opencode without publishing, point a plugin file at dist/. opencode auto-loads {plugin,plugins}/*.{ts,js} from .opencode/ in a project, or from ~/.config/opencode/ globally:

mkdir -p ~/.config/opencode/plugin
echo "export { default } from \"$PWD/dist/index.js\"" \
  > ~/.config/opencode/plugin/memorylake.js

Rebuild after every source change — opencode loads the built file, not src/. Remove that file to uninstall. Note that opencode does not deduplicate plugins: installed both globally and per-project, it loads twice and registers every tool twice.

To check what actually reached the model, point a provider baseURL at a local endpoint that logs the request body — the system prompt, tool schemas, and messages all arrive there, with no model call and no cost.