Persistent memory for Claude Code - extended fork with Qdrant, OpenCode support, and more
  • TypeScript 96.7%
  • JavaScript 3%
  • CSS 0.3%
Find a file
Release Bot 874b9127c3
All checks were successful
Release / Create Release (push) Successful in 1s
Release / Build Docker Images (push) Has been skipped
Release / Publish NPM Packages (push) Has been skipped
CI / build (push) Successful in 2s
chore(release): bump version to 3.0.4
2026-01-25 22:21:32 +00:00
.forgejo/workflows test(backend,worker): add comprehensive test suite (Issue #210) 2026-01-25 14:54:28 +01:00
.playwright-mcp docs: update auto-generated CLAUDE.md context files 2026-01-25 15:24:28 +01:00
docs docs: add multi-database documentation and DATABASE_URL support (Issue #262) 2026-01-25 20:08:07 +01:00
packages chore(release): bump version to 3.0.4 2026-01-25 22:21:32 +00:00
plugin chore(release): bump version to 3.0.4 2026-01-25 22:21:32 +00:00
scripts docs: update auto-generated CLAUDE.md context files 2026-01-25 15:24:28 +01:00
.dockerignore feat: add Docker support for backend and worker 2026-01-23 10:31:49 +01:00
.env.example feat: add Docker support for backend and worker 2026-01-23 10:31:49 +01:00
.gitignore docs: update auto-generated CLAUDE.md context files 2026-01-25 15:24:28 +01:00
CHANGELOG.md chore(release): bump version to 3.0.4 2026-01-25 22:21:32 +00:00
CLAUDE.md chore: update auto-generated CLAUDE.md files 2026-01-25 21:14:08 +01:00
docker-compose.dev.yml feat: sync plugin to separate repo on release 2026-01-23 14:34:32 +01:00
docker-compose.yml fix(Issue #269): replace bun with curl in docker-compose healthcheck 2026-01-25 14:27:21 +01:00
Dockerfile.backend chore(deps): update node.js to v24 2026-01-25 01:10:03 +01:00
Dockerfile.worker chore(deps): update node.js to v24 2026-01-25 01:10:03 +01:00
package.json chore(release): bump version to 3.0.4 2026-01-25 22:21:32 +00:00
pnpm-lock.yaml fix(task-dispatcher): add exponential backoff for task retries 2026-01-25 23:12:45 +01:00
pnpm-workspace.yaml feat: Phase 1 - Monorepo structure with types and shared packages 2026-01-23 07:40:42 +01:00
README.md chore(release): bump version to 3.0.4 2026-01-25 22:21:32 +00:00
renovate.json chore(renovate): enable platform automerge and auto-rebase 2026-01-24 13:31:14 +01:00
tsconfig.base.json feat(database): add MikroORM setup and entity definitions 2026-01-23 18:45:17 +01:00
vitest.config.ts test(backend,worker): add comprehensive test suite (Issue #210) 2026-01-25 14:54:28 +01:00

claude-mem

Persistent memory system for Claude Code - Transform your AI coding sessions from isolated conversations into continuous knowledge.

Version License

What is claude-mem?

claude-mem is a Claude Code plugin that captures, compresses, and recalls knowledge across sessions. It automatically:

  • Extracts observations from every tool use (file reads, edits, searches)
  • Generates summaries at session end
  • Injects context into new sessions via CLAUDE.md files
  • Enables semantic search across your project's history

Features

Feature Description
Observation Extraction AI-powered extraction of insights from tool outputs
Session Summaries Compressed session history with request/learned/completed
Auto CLAUDE.md Generates context files in your project directories
MCP Search Tools Semantic search across observations and memories
Multi-Provider Supports Anthropic, Mistral, OpenAI, Gemini for AI tasks
Web UI Browse sessions, observations, and summaries
Document Caching Caches Context7/WebFetch results for reuse
SSE Real-Time Updates Live updates to CLAUDE.md files during sessions
Code Snippets Automatic extraction and storage of code examples
Insights Dashboard Daily stats, technology usage tracking, achievements
Auto-Spawn Workers Automatic worker spawning on backend startup
Task Deduplication Prevents duplicate task processing via SHA-256 hashing

Key Concepts

Observations

Observations are AI-extracted insights from tool usage. Each observation captures:

  • Title & Text: Concise summary of what happened
  • Type: One of 18 categories (see below)
  • Facts: Extracted factual statements
  • Concepts: Related patterns and ideas
  • Files: Read and modified file paths

Observation Types:

Category Types Emoji
Work bugfix, feature, refactor, change 🔴 🟣 🟠 🟢
Docs & Config docs, config 📝 ⚙️
Quality test, security, performance 🧪 🔒
Infrastructure deploy, infra, migration 🚀 🏗️ 📦
Knowledge discovery, decision, research 🔵 💡 🔍
Integration integration, dependency, api 🔗 📚 🌐

Session Lifecycle

session-start → user-prompt-submit → post-tool-use (repeated) → stop
     │                                      │                      │
     ▼                                      ▼                      ▼
 Inject context              Extract observations         Generate summary
 Spawn SSE writer           Queue AI extraction tasks     Update CLAUDE.md

Task Queue

Background workers process AI tasks with priority-based scheduling:

Task Type Priority Description
observation 50 Extract insights from tool output
summarize 40 Compress session observations
embedding 30 Generate vector embeddings
claude-md 20 Generate CLAUDE.md content

SSE Writer

The SSE Writer is a standalone Node.js process that handles real-time CLAUDE.md updates:

  • Spawned per session at session-start hook
  • Connects to /api/stream via EventSource API
  • Validates session/project/directory before every write (security boundary)
  • Listens for events: claudemd:ready, session:ended
  • Preserves user content outside <claude-mem-context> tags
  • Auto-exits after 10 minutes if no relevant events
  • PID management for cleanup via ~/.claude-mem/sse-writer-*.pid
┌─────────────┐      SSE       ┌─────────────┐
│   Backend   │ ────────────▶  │ SSE Writer  │
│  (Express)  │  claudemd:ready│  (Node.js)  │
└─────────────┘                └──────┬──────┘
                                      │
                                      ▼
                               ┌─────────────┐
                               │ CLAUDE.md   │
                               │   files     │
                               └─────────────┘

Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Claude Code                             │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐          │
│  │ SessionStart│  │PostToolUse  │  │    Stop     │          │
│  │    Hook     │  │    Hook     │  │    Hook     │          │
│  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘          │
└─────────┼────────────────┼────────────────┼─────────────────┘
          │                │                │
          ▼                ▼                ▼
┌─────────────────────────────────────────────────────────────┐
│                       Backend (Express)                      │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐          │
│  │   Session   │  │    Task     │  │     SSE     │          │
│  │   Service   │  │   Service   │  │ Broadcaster │          │
│  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘          │
└─────────┼────────────────┼────────────────┼─────────────────┘
          │                │                │
          ▼                ▼                ▼
┌─────────────────┐ ┌─────────────┐ ┌─────────────────────────┐
│    Database     │ │   Worker    │ │      SSE Writer         │
│(SQLite/Postgres)│ │  (AI Agent) │ │   (CLAUDE.md files)     │
└─────────────────┘ └─────────────┘ └─────────────────────────┘

Installation

As Claude Code Plugin

# Install from Claude Code marketplace
claude mcp install claude-mem

Development Setup

# Clone the repository
git clone https://git.customable.host/customable/claude-mem.git
cd claude-mem

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Build plugin for marketplace
pnpm build:plugin

# Sync to Claude installations
pnpm sync-marketplace

Project Structure

packages/
├── types/          # Shared TypeScript types
├── shared/         # Utilities, logging, settings
├── database/       # SQLite/PostgreSQL + MikroORM repositories
├── backend/        # Express API server
├── worker/         # AI agents for observation extraction
├── hooks/          # Claude Code hook handlers
└── ui/             # React web interface

Configuration

Settings are stored in ~/.claude-mem/settings.json:

{
  "BACKEND_PORT": 37777,
  "AI_PROVIDER": "anthropic",
  "ANTHROPIC_API_KEY": "sk-ant-...",
  "CLAUDEMD_ENABLED": true,
  "CLAUDEMD_OBSERVATION_INTERVAL": 10,
  "LOG_LEVEL": "info"
}

MCP Tools

claude-mem exposes search tools via MCP:

// Search observations
mcp__plugin_claude-mem_mcp-search__search({
  query: "authentication implementation",
  limit: 10
})

// Get observation details
mcp__plugin_claude-mem_mcp-search__get_observations({
  ids: [123, 456]
})

// Save a memory
mcp__plugin_claude-mem_mcp-search__save_memory({
  text: "Important decision about architecture",
  type: "decision"
})

Development

# Restart dev server (backend + UI)
pnpm run dev:restart

# Type check all packages
pnpm run typecheck

# Build plugin
pnpm run build:plugin

Database

SQLite (default) or PostgreSQL database, managed by MikroORM. See docs/DATABASE.md for detailed setup instructions.

# Default (SQLite)
claude-mem-backend start

# With PostgreSQL
claude-mem-backend start --db postgres://user:pass@localhost:5432/claudemem
# Or via environment variable
DATABASE_URL=postgres://user:pass@localhost:5432/claudemem claude-mem-backend start

SQLite database at ~/.claude-mem/claude-mem.db:

Table Description
sessions Claude Code sessions with metadata
observations AI-extracted insights from tool use
summaries Compressed session summaries
claudemd Generated CLAUDE.md content
tasks Worker task queue with deduplication
documents Cached external documentation (Context7/WebFetch)
prompts User prompts with urgency tracking
code_snippets Extracted code examples from sessions
achievements User achievements and milestones
daily_stats Aggregated daily statistics
technology_usage Technology usage tracking
observation_links Links between related observations
repositories Git repository metadata

Roadmap

Current high-priority items:

  • Endless Mode (#109) - Real-time context compression for unlimited session length

Recently Completed

  • Documents Search (#115) - MCP tool for searching cached documentation
  • Process/Memory Leaks (#101) - Fix orphaned worker processes
  • Database Schema Redesign (#197) - Modernized table structure with MikroORM

See all open issues for the full list.

Acknowledgments

Originally based on thedotmack/claude-mem. This project has since evolved into an independent implementation with:

  • Modular monorepo architecture
  • Multi-provider AI support (Anthropic, Mistral, OpenAI)
  • Auto-generated CLAUDE.md files per subdirectory
  • Document caching for Context7/WebFetch
  • Forgejo integration

License

MIT