codemem
Local-first persistent coding memory for OpenCode, Claude Code, and Codex that captures decisions, discoveries, and dead ends, then automatically injects relevant context into future sessions.
At a Glance
Free and open source under the MIT license. Observer model usage may incur costs with your configured model provider.
Engagement
Available On
Alternatives
Listed Sep 2026
About codemem
codemem is a free, open-source (MIT) persistent memory companion for AI coding agents, built by Adam Kunicki. It captures the reasoning behind code changes — decisions, dead ends, and repo-specific traps — and automatically surfaces that context in later OpenCode, Claude Code, and Codex sessions. Memories live in a local SQLite database the user controls, with optional peer-to-peer sync across machines and selective sharing with teammates.
What It Is
codemem solves a specific problem in AI-assisted development: the code survives the session, but the reasoning behind it usually doesn't. When a fresh agent session starts, it has no memory of why a fallback was kept, which edge case caused a three-run debugging session, or what compromise was intentional. codemem stores those typed memories — bugfix, feature, refactor, change, discovery, decision, exploration — and retrieves them automatically before the agent needs to re-derive them.
The tool is local-first by design. No hosted memory account is required. The observer model (which turns captured activity into structured memories) uses the user's own configured model provider, which may incur charges or consume plan usage depending on the provider.
How Capture and Recall Work
codemem hooks into agent runtime event systems through plugins for OpenCode, Claude Code, and Codex. The workflow follows four stages:
- Capture — a configured observer model turns session activity (tool calls, conversation messages, session lifecycle events) into typed memories with structured fields like
facts,concepts,files_read, andfiles_modified. - Structure — memories are stored in local SQLite with file references inspectable in a built-in web viewer at
http://localhost:38888. - Recall — retrieval combines SQLite FTS5 BM25 lexical search and sqlite-vec semantic similarity search, merged and re-ranked using recency and memory-kind boosts.
- Injection — relevant context is automatically appended to the latest user message before the agent sees it, without requiring a manual search step.
Unchanged memories already in context are not repeated across turns, and exact continuation prompts can skip new injection when working context and retrieved facts are unchanged.
Agent Integrations and Platform Support
codemem supports three coding agents through dedicated plugin surfaces:
- OpenCode — requires OpenCode 1.18.29+; one
@codemem/opencode-pluginpackage serves both OpenCode 1 and OpenCode 2 (beta). Automatic recall runs throughsession.contexton OpenCode 2. - Claude Code — installed via the Claude Code marketplace (
/plugin marketplace add kunickiaj/codemem); bundles its own MCP configuration and hooks. - Codex — installed via the Codex plugin marketplace; also supports API-key Desktop users via
npx -y codemem setup --codex-only.
Agent integrations use local MCP over stdio. An advanced single-user self-hosting path can expose an OAuth-protected Streamable HTTP MCP endpoint to remote clients.
Sync and Sharing Model
Peer-to-peer sync carries project memory across machines without requiring hosted infrastructure. Key behaviors:
- Memories stay in local SQLite; sync is opt-in via
codemem sync enable. - A memory marked Only me stays local even when its project is shared.
- Teammates receive copies of shared memories; changing visibility later cannot remotely erase copies already synced.
- Team sharing assigns projects to a Team and invites members; new members inherit current and future project access.
- A self-hosted coordinator service (
codemem coordinator) supports cross-network setups where mDNS does not cross VPN or network boundaries.
Update: v0.45.0
The latest release is v0.45.0, published September 14, 2026. The repository was last pushed on September 19, 2026, indicating active development. The project was previously named opencode-mem before a rename migration. OpenCode 2 support (validated against @opencode/cli@2.0.2 and @opencode/plugin@2.0.2) is labeled beta until it has shipped through a full release cycle. The CLI is distributed via npm as codemem and requires Node.js 24.15+; native database support covers macOS x64/arm64, Linux x64/arm64 (glibc 2.34+ or musl), and Windows x64.
Community Discussions
Be the first to start a conversation about codemem
Share your experience with codemem, ask questions, or help others learn from your insights.
Pricing
Open Source
Free and open source under the MIT license. Observer model usage may incur costs with your configured model provider.
- Local SQLite memory storage
- OpenCode, Claude Code, and Codex integrations
- Automatic context injection
- Hybrid lexical and semantic retrieval
- Peer-to-peer sync
Capabilities
Key Features
- Automatic context injection into OpenCode, Claude Code, and Codex sessions
- Local SQLite storage — no hosted memory account required
- Typed memories: bugfix, feature, refactor, change, discovery, decision, exploration
- Hybrid retrieval: FTS5 BM25 lexical search + sqlite-vec semantic search
- Peer-to-peer sync across machines
- Selective memory sharing with teammates and Teams
- Built-in local web viewer for browsing memories, sessions, and observer output
- MCP stdio server and optional OAuth-protected Streamable HTTP MCP endpoint
- CLI with search, pack, distill, export, import, and sync commands
- Observer model support: api_http, claude_sidecar, codex_sidecar
- Memory export and import (idempotent)
- Automatic deduplication — unchanged memories already in context are not repeated
- Distill recurring lessons into AGENTS.md rules
- Remote MCP deployment with OIDC/OAuth for advanced single-user self-hosting
- Self-hosted coordinator for cross-network peer discovery
