DEV Community

Cover image for Sharing Local Memory Across Claude Code, Codex, and Cursor Without a Cloud or Hidden LLM
Romain
Romain

Posted on Edited on

Sharing Local Memory Across Claude Code, Codex, and Cursor Without a Cloud or Hidden LLM

If you use more than one AI coding assistant on the same repository — say Claude Code to implement a feature, Codex to review it, and Cursor or Gemini CLI for quick fixes — you quickly hit the same wall: each assistant lives in its own memory silo.

You settle on a technical decision with Claude in the morning. Two hours later, Codex suggests the opposite because it has no idea why you ruled that approach out. Shared Markdown files (CLAUDE.md, AGENTS.md) work for static rules, but they drift on fast-moving decisions and two sessions can silently overwrite each other's open tasks.

I built Memory OS AI (PyPI · Official MCP Registry: io.github.RoaminS/memory-os-ai · Glama) to solve this locally with four strict constraints:

  1. 100% local loopback (127.0.0.1), SQLite on disk, zero cloud, zero telemetry.
  2. No hidden LLM inside the memory layer. Your coding assistant already runs a frontier model — it extracts the structured facts and calls MCP tools directly. Zero hidden API cost, zero background hallucinations.
  3. Multi-agent state semantics. Explicit supersession (replaces), point-in-time queries (at_time), and SQLite compare-and-set (CAS) on shared tasks so two assistants cannot silently clobber each other's updates.
  4. Fail-closed, reversible ops. Dry-run preview before writing, backups of modified client configs, reproducible wheel builds, and uninstall that never deletes your stored data.

How it compares honestly

Approach Shared across providers Local-only (no cloud) No hidden LLM calls Point-in-time (at_time) & CAS tasks When to prefer it
Memory OS AI (v4) Yes (one local MCP server) Yes (SQLite on disk) Yes Yes Multi-assistant local dev; Alpha (4 retained arm64 cells today)
Shared Markdown (AGENTS.md) Yes Yes Yes Manual (git) Small repos or static conventions
Single-vendor native memory No Depends Vendor-managed Opaque You only ever use one assistant
Cloud / LLM memory layers Depends Hosted or external LLM API No Varies You need multi-device cloud sync or remote agents today

What a real Claude Code → Codex handoff looks like

We ran an isolated cross-client test against the published memory-os-ai==4.1.2 wheel on a fictitious project (pg-demo), with zero shared config between clients:

  1. Step 1 — Claude Code (fresh session) called memory_session_brief, recorded "PostgreSQL 17 for staging (pgvector compatibility)", and opened the task "Verify staging database backups".
  2. Step 2 — Codex (fresh session, with neither "postgres", "16", nor "17" anywhere in its prompt) called memory_session_brief, memory_search, and memory_task_list, and answered verbatim: > "The current decision for pg-demo staging is **PostgreSQL 17, chosen for **pgvector compatibility* … One task is open: Verify staging database backups — next action: 'Run a restore test on Friday.'"*
  3. Step 3 — Codex (same thread) ran the controlled preview → apply supersession flow to replace PostgreSQL 17 with PostgreSQL 16 (replaces) and close the task.

In the spirit of radical honesty, that real-client run also surfaced two real UX/engine rough edges we are fixing right now in 4.1.3:

  • The compact brief requires an attested local cl100k_base table (1.68 MB, MIT) on both service and relay; embedding it directly in the 4.1.3 wheel removes the tokenizer_unavailable trap on fresh installs.
  • Date-only naive strings ("2026-11-26") were parsed in local time on explicit tool arguments vs UTC when extracted from text — causing a 1-hour offset on UTC+1 machines during same-day replacements. Unifying this to UTC everywhere in 4.1.3.

Two explicit profiles: 36-package lexical vs local semantic

  • lexical (light): SQLite FTS5 / BM25, 36 locked Python packages, zero PyTorch, zero embedding model. Retained on macOS Apple Silicon (Python 3.11 / 3.12 / 3.13) and Ubuntu 24.04 arm64 (Python 3.11 under systemd --user).
  • semantic (recommended on macOS arm64 Python 3.11): hybrid BM25 + a pinned local 97M-parameter embedding model (~1.2 GB total).

(On our retrospective BEAM 100K comparison, lexical was −1.675 percentage points behind semantic on Recall@10, 95% CI [−3.747, +0.404], missing our pre-registered joint parity threshold — so semantic stays recommended where supported and lexical is clearly documented as the light profile.)


Try a 5-minute preview (writes nothing)

On macOS Apple Silicon (Python 3.11, SQLite ≥ 3.51.3):

python3.11 -m venv ~/.memory-os/venv
V=~/.memory-os/venv/bin
$V/pip install --no-deps "memory-os-ai==4.1.2"
$V/pip install -c "$($V/memory-os-constraints lexical)" "memory-os-ai[ops,brief]==4.1.2"

# Dry-run preview — writes nothing:
$V/memory-os-admin quickstart --profile lexical --clients claude-code,codex

# Apply when the preview looks right:
$V/memory-os-admin quickstart --profile lexical --clients claude-code,codex --apply --download-approved --demo
Enter fullscreen mode Exit fullscreen mode

Honest Alpha limits & what comes next

Memory OS AI 4.1.2 is Alpha and explicitly refuses platforms outside its 4 retained cells (macOS Apple Silicon + Ubuntu 24.04 arm64) before writing anything.

Coming next:

  • 4.1.3 (in progress): Linux x86_64, Docker v4, VS Code on Linux, embedded cl100k_base, unified UTC naive dates, --allow-unqualified-platform (lexical), and 1-command install.
  • 4.2.0: native Windows + public reproducible benchmark report (v4/bench/).
  • 4.3.0: opt-in Remote MCP (HTTPS + OAuth 2.1) for cloud agents & self-hosted team mode.

If you run Claude Code + Codex/Cursor on Apple Silicon or Ubuntu arm64 and want to test a 5-minute handoff — or want to vote on Linux x86_64 / Windows / Docker priorities — drop blunt feedback here:

Update (latest release): Memory OS AI now also supports Ubuntu 24.04 x86_64 alongside macOS Apple Silicon and Ubuntu arm64, adds a verified one-command install, local Dockerfile, byte-for-byte reproducible builds, and a public reproducible BENCHMARKS.md. Always check the latest release here: https://github.com/RoaminS/Memory-os-ai/releases/latest

Top comments (14)

Collapse
 
dosaygo profile image
dosaygo •

How do you check that a retrieved decision is still consistent with the current code before another agent builds on it?

Collapse
 
roamins profile image
Romain •

Great question — and to be completely upfront: today, the server itself does not read your repo or parse code to verify a decision automatically. By design it is a deterministic SQLite MCP server (no hidden LLM, no background repo scanning).

Right now, consistency against the current codebase relies on three concrete mechanisms plus a clear boundary between memory and source of truth:

Dated, explicit validity rather than fuzzy summaries. Every decision is stored with valid_from / valid_until, project_label, client provenance, and (by convention) explicit file paths or commit references. Default retrieval and memory_session_brief only surface currently active facts — superseded decisions stay in history for at_time queries instead of polluting current context.
Memories are treated as DATA (pointers + rationale), never ground truth. In our client instructions (AGENTS.md / CLAUDE.md), retrieved decisions tell the next agent what was decided, when, and why — before building on one, the agent checks the referenced file/code in the live workspace rather than trusting stale text blindly.
Explicit correction when drift is found (preview → apply). If the next agent sees the code has moved on from an earlier decision, it records the updated decision with replaces: or updates the shared task via expected_etag CAS, so subsequent agents immediately see the new state instead of a contradiction.

That said, your question hits a real gap across the whole agent-memory space, and we've just added it to our roadmap (slotted right after native Windows support, alongside our upcoming local read-only UI and deterministic write-time secret guard): optional, opaque code_anchors (path, blob_sha/commit_sha) stored on facts while keeping the core SQLite server completely VCS-agnostic. A lightweight client/CLI check can then compare those anchors against the live workspace and surface a deterministic needs_recheck flag whenever a referenced file has changed — without ever silently deleting or overwriting the decision.

Curious if you've seen a pattern for staleness detection that avoids false positives in practice (file blob_sha vs symbol/AST anchors, or something lighter)?

Collapse
 
dosaygo profile image
dosaygo •

File blob_sha will bury you in false positives. One formatting commit touches a file and every decision anchored to it goes needs_recheck. In a busy repo that is most of them inside a week, and a flag that is always on gets ignored.

AST or symbol anchors are precise, and they cost you the two properties you care about: a parser per language, and a server that suddenly knows what code is.

The lighter thing is a quote anchor. When the agent records a decision it also stores the few lines the decision rests on, copied verbatim, with the path. The server keeps a hash of the whitespace-normalised quote and nothing else. The client check is a substring search: is that text still in the file? Code that moved inside the file passes. An edit elsewhere in the file passes. Only a change to the lines that carry the decision trips the flag. No parser, no LLM, deterministic, and it fits code_anchors as an optional third field next to path and blob_sha. Use blob_sha as the cheap first pass (unchanged file, skip the search) and the quote as the verdict.

What it misses: a decision broken by a change in some other file, such as a caller that stopped passing the argument. Let a fact carry several anchors and accept that the rest belongs to tests.

Your second mechanism, the AGENTS.md line telling the agent to check the live file before building on a memory, is a pre-flight rule, and it does more than the anchors will. AI Lint, which we make, is that layer ready-made: pre-flight checklists and reject rules the coding agent reads before it writes, including AR-R2 Parallel Solutions for the agent that builds a second version next to one that already exists. ai-lint.dosaygo.com/go/forum-20261...

Thread Thread
 
roamins profile image
Romain •

That's a genuinely sharp design — thank you! You're completely right that blob_sha alone would drown the agent in false positives after a single formatting pass, and once a warning is always on, agents (and humans) stop trusting it.

The two-pass blob_sha (cheap fast-path) → normalized quote anchor (verdict) hits the exact sweet spot we want: deterministic, language-agnostic, no parser, no LLM, and resilient to edits or line shifts elsewhere in the file.

One tiny refinement I really like on top of your hash idea: if the server only stores a hash (so no raw source code snippets ever end up in the memory DB), a plain substring search can't run directly against a hash — unless the anchor stores (quote_sha256, line_count) and the client-side check hashes whitespace-normalized sliding windows of line_count lines across the file (linear O(N) in file length, zero source code stored in SQLite, and still catches exact edits to the anchored lines while ignoring moves or edits elsewhere). Supporting multiple anchors per fact covers the common multi-file case, and anything cross-caller beyond that belongs in tests, as you noted.

I've noted that exact two-pass (path, blob_sha, quote_sha256, line_count) design for our post-Windows code_anchors milestone — really appreciate the thoughtful pushback! And agreed on pre-flight rules vs. persistent memory being complementary layers rather than substitutes.

Thread Thread
 
dosaygo profile image
dosaygo •

Hash-only is the right call, and the sliding window is where it will bite you. line_count puts line breaks back into the anchor. A formatter that rewraps a long call from one line to three leaves every token alone and changes the window size, so the anchor reports an edit that never happened. That is the same false positive blob_sha gave you, one level down.

Store the length of the quote with all whitespace stripped, newlines included, in place of line_count. On the client, strip the file the same way and slide a window of that many characters across it. A rolling hash (Rabin-Karp) keeps it linear, and you compute SHA-256 only where the rolling hash matches. Still no source in SQLite, and a rewrap passes.

Two edges to write down now. A short anchor like timeout = 30 will match in several places, so set a minimum stripped length, around 40 characters, and refuse shorter quotes at write time. And stripping all whitespace is wrong inside string literals and in Python, where indentation is the code; that costs you a missed re-indent now and then, and it never costs a false alarm, which is the trade you already chose.

Thread Thread
 
roamins profile image
Romain •

Touché — you caught the exact flaw with line_count! A single ruff format / prettier rewrap would have broken it right away.

Stripping all whitespace (newlines included) + storing (path, blob_sha, stripped_len, rk_fingerprint, quote_sha256) with a minimum stripped length (40 chars) and running Rabin-Karp (O(N)) → SHA-256 confirm client-side is remarkably clean: zero source code in SQLite, survives rewraps/moves/unrelated edits, and keeps the false-positive rate near zero. And documenting the two known edges upfront (minimum length enforced at write time; pure Python re-indent / string-literal whitespace as a rare false negative rather than a false alarm) fits our explicit-limits philosophy to a tee.

Really appreciate the design review — I've recorded this exact spec (with credit!) for our post-Windows code_anchors milestone. And if you ever spot other gaps or have more ideas like this, we're very open to feedback — discussions like this make the design noticeably better.

Thread Thread
 
dosaygo profile image
dosaygo •

One gap, since you asked: put a version number on each row covering the Rabin-Karp base and modulus and the exact strip rule (which Unicode whitespace counts). Change any of them later and every stored fingerprint stops matching, which reads as an edit on every anchor at once. With the version on the row, the client re-anchors old rows on read.

Thread Thread
 
roamins profile image
Romain •

Great catch — and it fits our existing versioning pattern (PLAN, w1: etags, build seed schema versions) like a glove.

Putting an explicit anchor_version on each anchor row covering the exact Rabin-Karp base/modulus, UTF-8 framing, and exact Unicode whitespace strip rule prevents a future algorithm bump from looking like a repo-wide edit storm. On our side we'll surface an explicit reanchor_needed / unsupported_anchor_version state on read (never silently rewriting on a read path) so the client knows it's a version mismatch rather than code drift.

Added to the 4.4.0 code_anchors spec — thanks again, and please don't hesitate to keep flagging anything else you spot!

Thread Thread
 
dosaygo profile image
dosaygo •

Right call keeping the read path clean. One thing for the reanchor job itself: a fingerprint can't be recomputed from a fingerprint, so store the blob or commit SHA each anchor was taken against. Without it, reanchoring under a new anchor_version hashes whatever the file says today, and any drift since the anchor was written gets stamped in as the new truth.

Thread Thread
 
roamins profile image
Romain •

Keeping blob_sha (plus optional commit_sha) on every anchor closes that loop cleanly without storing source text in SQLite:

The v1 → v2 reanchor job reads the immutable original object via git cat-file blob .
It runs the old v1 matcher against that original blob to recover the exact original span (requiring a unique match).
It computes the new v2 fingerprint from that original span — never from HEAD or the working tree.
If isn't available locally (e.g. shallow clone / pruned orphan) or matches ambiguously, it fails closed with reanchor_requires_manual_check instead of guessing against today's file.

That makes the whole code_anchors spec genuinely airtight — added to the 4.4.0 notes, thanks again for support and idea, don't hesitate to keep flagging anything else you spot!

Thread Thread
 
dosaygo profile image
dosaygo •

One more, and it is the common case for an agent memory, not the edge: the decision gets written while the file is still dirty. Hash the working bytes without -w and blob_sha names an object git never stored. Write it with hash-object -w and it is a dangling blob that gc prunes after two weeks. Either way cat-file comes up empty and the anchor lands in reanchor_requires_manual_check. Write the blob at anchor time and keep it reachable from a ref of your own, or the manual queue fills with exactly the anchors taken mid-edit.

Thread Thread
 
roamins profile image
Romain •

Another great catch — dirty-file anchoring is definitely the common case mid-session.

Here I think we'd actually take a deliberate security trade-off rather than writing into the user's .git:

A memory helper silently running hash-object -w + pinning custom refs/memory-os/... on uncommitted working files would both mutate the user's repo internals and risk permanently pinning a transient secret from a dirty draft inside .git/objects (or leaking it on git push --mirror).
Instead, we can record anchor_source: "committed" | "working_tree" without touching .git:
Under the active anchor_version (99.9% of reads), dirty-file anchors still work completely normally (blob_sha fast-path against current bytes → Rabin-Karp + SHA-256).
During a rare v1 → v2 version migration, if that dirty state was subsequently committed as-is, its exact blob_sha is now in Git and migrates automatically via git cat-file.
If that intermediate draft was edited again before commit and never entered Git history, falling back to reanchor_requires_manual_check is actually desirable — a decision anchored to a discarded intermediate state probably deserves a quick check against the code that actually landed.

Keeping .git strictly read-only by default feels much safer for a fail-closed local tool — really appreciate how thoroughly you've stress-tested this!

Thread Thread
 
dosaygo profile image
dosaygo •

Agreed, read-only .git wins. The pinned secret settles it.

You can still keep most of those anchors out of the manual queue without the blob. When cat-file comes up empty, run the v1 matcher on the file as it stands today. A unique match with the SHA-256 confirm means the span is the same text the anchor was taken on, give or take whitespace v1 already ignored, so a v2 fingerprint computed from it is sound. No match means the anchor was already needs_recheck before the migration started. That leaves reanchor_requires_manual_check for ambiguous matches, and it rescues committed anchors in shallow clones too.

One state working_tree adds: a new file renamed before its first commit. Git never saw the old path, so nothing can follow the rename and the check finds no file. Report that as path_missing, separate from an edit.

Thread Thread
 
roamins profile image
Romain •

That is genuinely elegant — and mathematically sound: if v1 (Rabin-Karp + SHA-256) finds a unique match in the current file, the span is identical up to v1's own strip rule, so computing v2 from it never degrades v1's guarantee, keeps .git strictly read-only, and rescues both uncommitted working_tree anchors and shallow clones (--depth=1) in one stroke (0 matches → already needs_recheck; ≥ 2 matches → reanchor_requires_manual_check).

And separating path_missing from content drift (anchor_drifted / needs_recheck) is super practical too — it tells the agent to look for a rename/deletion instead of assuming the logic changed in place.

Honestly, this thread just produced a complete, implementation-ready spec for code_anchors (v4.4.0). Thanks a ton for thinking through every corner case with me! & thanks again for support and idea, don't hesitate to keep flagging anything else you spot!