$ show thedotmack/claude-mem
claude-mem is a persistent memory system for AI coding assistants, primarily targeting Claude Code but also supporting Codex, Cursor, Windsurf, OpenClaw, and other platforms. It captures observations, summaries, and user prompts from coding sessions via lifecycle hooks (SessionStart, PostToolUse, etc.), stores them in SQLite (local) or Postgres (server), and injects relevant context into future sessions to maintain continuity across agent interactions. The system operates as a background worker daemon (Bun) or a multi-user server (Express + BullMQ + Valkey) with API key authentication, team/project scoping, and rate limiting. Architecturally, claude-mem is a hybrid of a CLI plugin and a standalone server. The CLI component integrates into IDEs via hook scripts and MCP servers, while the server component provides REST APIs for memory management, search, and cloud sync. It features a dual-storage backend (SQLite for local, Postgres for server) with vector search via ChromaDB and full-text search via SQLite FTS5. The system includes a React-based viewer for browsing memory feeds, telemetry (opt-out PostHog), and a Cloudflare Workers-based sync hub for cross-device synchronization. The codebase demonstrates strong engineering practices with well-abstracted components (search strategies, provider abstraction, atomic file operations, telemetry scrubbing) but carries some technical debt from its dual-runtime evolution (legacy worker vs. server-beta) and extensive Windows-specific workarounds. It is actively maintained with frequent releases and comprehensive test coverage.
The LLM identified 5 files worth highlighting for reuse:
Provides crash-safe atomic JSON file writes using a temp-file + rename + directory fsync pattern. Handles symlinks and ensures data integrity on power loss or process crash. Reusable in any Node.js/Bun project requiring safe configuration or state persistence.
Cross-platform spawn helper that normalizes Windows .cmd shim execution via cmd.exe /d /s /c, sets windowsHide: true, and handles environment isolation. Abstracts away platform-specific quirks for spawning child processes, making it reusable in any CLI tool targeting multiple OSes.
Implements a hybrid search strategy that combines ChromaDB vector search with SQLite FTS5 keyword search, falling back gracefully when one backend is unavailable. Demonstrates clean strategy pattern with platform-scoped filtering and deduplication. Reusable in any application needing multi-backend search with fallback.
Whitelist-based telemetry event scrubber that strips all non-allowed property keys, truncates strings to 200 characters, and drops non-primitive values. Pure function, never throws, and enforces privacy by design. Reusable in any application requiring safe telemetry emission without leaking sensitive data.
Reads OAuth tokens from platform-native credential stores (macOS Keychain, Windows Credential Manager, Linux libsecret) with JWT expiry decoding and stale marker signaling. Abstracts OS-specific APIs behind a unified interface. Reusable in any CLI tool needing secure token retrieval across platforms.