DEV Community

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

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

Romain on November 26, 2026

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 Gem...
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.