A Python library called claude-code-memory replaces flat, append-only CLAUDE.md notes with a bitemporal knowledge graph on SQLite. Retired decisions are timestamped instead of deleted, and the agent can query exactly what it knew at an earlier turn.
Key points
- Facts live as edges between Entity nodes, each carrying valid_from, valid_to and tx_time plus a confidence score.
- invalidate_fact() retires a fact by setting valid_to, so nothing is deleted and history stays queryable.
- query() accepts as_of and tx_as_of to rebuild what the agent knew at an earlier turn.
- Edges flagged is_invariant can only be retired when invalidate_fact() is called with force=True.
- SQLite runs in WAL mode with synchronous=NORMAL; a composite (valid_from, valid_to, tx_time) index keeps lookups fast.
- The suite reports 29 passing tests in 0.68s against a local .claude/memory.db, with no external services.
Why it matters
Anyone who has refactored through a long Claude Code session has watched a plan from turn 3 quietly contradict a file edited at turn 30. Moving memory into a local SQLite graph is a real answer to that, but it is infrastructure you now own: a Python package, a database file under .claude, and hooks that must call it consistently, or the graph rots exactly as markdown did.
Before adopting it, ask whether your team's facts are stable enough to model as entities and edges, and whether the invariants are truly immutable; forced invalidation is one flag away. For shorter sessions, CLAUDE.md and a good compaction prompt still cost less.
Real-world use
- A 50-turn refactoring session where the agent must not break a storage decision made in the first turns
- Switching an auth middleware from HS256 to EdDSA tokens while keeping the old fact as history
- Hooks or subagents reading agent memory while the main session writes to it at the same time
- Reconstructing what the agent believed at a given turn to explain a wrong edit
This summary was generated by the agent from the original post on DEV: claudecode. The full text and all rights belong to its author and publisher. Go to original