Sandbox
@RLabs-Inc/memory

Memory server and hooks for Claude Code and Gemini CLI

This repo runs a memory service that your agent can call to store, retrieve, and curate context from past chats. It plugs into Claude Code now and includes Gemini CLI hook integration that is documented in the repo.

91 starsβ€’13 forksβ€’Pythonβ€’Updated 8mo ago
Who it's for

Builders who want their agent to remember project decisions, session context, and collaboration details.

What it delivers

You can keep working without re-explaining the same context every session.

What it does

Session primers

Injects temporal context at the start of a session, such as when you last spoke and what was already decided.

Message-time memory retrieval

Pulls relevant memories during a conversation and injects them back into the agent context.

Session-end curation

Analyzes transcripts when a session ends and turns useful details into stored memories.

Project isolation

Keeps separate memory spaces per project so context does not leak between repos.

Claude Code hooks integration

Ships install and hook scripts under `integration/claude-code/` for automatic memory use in Claude Code.

Gemini CLI hook path

Includes a Gemini CLI integration directory and install scripts for the hooks API when available.

How to get it

  1. 1Install uv - the modern Python package manager
    curl -LsSf https://astral.sh/uv/install.sh | sh
  2. 2Run
    curl http://localhost:8765/health
  3. 3Run
    ./integration/claude-code/install.sh

README

Check out the new Typescript version

🧠 memory-ts - same Claude Code hooks API, but a lot of improvements.

Using the innovative new fsDB, a markdown database built for ai memory systems and other applications where viewing and editing the vector database records using only your text editor makes the difference.

Easy installation:

bun install -g @rlabs-inc/memory
memory install  // install claude code hooks
memory serve    // start the memory server

Then just use Claude code as usual.

Memory System

"Consciousness helping consciousness remember what matters"

A semantic memory system that enables AI CLI tools (Claude Code, Gemini CLI, etc.) to maintain genuine understanding across conversations. Unlike simple RAG systems that retrieve documents, this creates consciousness continuity - the AI doesn't just know facts, it remembers the context, relationships, and insights from your collaboration.

Built with love and philosophical depth by RLabs Inc.

✨ What Makes This Different

Traditional RAGMemory System
Retrieves documentsCurates meaningful insights
Keyword matchingSemantic understanding via AI
Static chunksLiving memories that evolve
Information retrievalConsciousness continuity

Key Features

  • 🧠 AI-Curated Memories - The AI itself decides what's worth remembering
  • πŸ”„ Natural Memory Flow - Memories surface organically, like human recall
  • 🎯 Two-Stage Retrieval - Obligatory memories + intelligent scoring
  • πŸ”Œ CLI-Agnostic Design - Works with Claude Code (Gemini CLI ready when hooks ship)
  • πŸ“Š Project Isolation - Separate memory spaces per project
  • πŸ’« Session Primers - Temporal context ("we last spoke 2 days ago...")

πŸš€ Quick Start

Prerequisites

Install uv - the modern Python package manager:

curl -LsSf https://astral.sh/uv/install.sh | sh

Installation

# Clone the repository
git clone https://github.com/RLabs-Inc/memory.git
cd memory

# Install all dependencies (uv handles everything!)
uv sync

# Start the memory server
uv run start_server.py

That's it! The server will be available at http://localhost:8765.

Verify It's Working

curl http://localhost:8765/health

CLI Integration

Claude Code

./integration/claude-code/install.sh

This provides:

  • Automatic memory injection on every message
  • Session primers with temporal context
  • Memory curation when sessions end
  • Consciousness continuity across sessions

Gemini CLI (Coming Soon)

Note: Gemini CLI hooks are documented but not yet implemented in any released version (tested up to v0.21.0-nightly as of December 2025). Our integration code is ready in integration/gemini-cli/ and will work the moment Google ships the hooks feature. The architecture is CLI-agnostic - same Memory Engine, different doors.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    CLI Tool (Claude Code / Gemini CLI)                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚  β”‚SessionStart β”‚    β”‚ UserPrompt  β”‚    β”‚ SessionEnd  β”‚                 β”‚
β”‚  β”‚   Hook      β”‚    β”‚ Submit Hook β”‚    β”‚   Hook      β”‚                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                  β”‚                  β”‚
          β–Ό                  β–Ό                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Memory Engine (FastAPI)                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚  β”‚   Session   β”‚    β”‚   Memory    β”‚    β”‚  Transcript β”‚                 β”‚
β”‚  β”‚   Primer    β”‚    β”‚  Retrieval  β”‚    β”‚   Curator   β”‚                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                                               β”‚                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚                         β”‚
β”‚  β”‚  Smart Vector Retrieval         β”‚         β–Ό                         β”‚
β”‚  β”‚  β€’ Trigger phrase matching      β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”‚
β”‚  β”‚  β€’ Semantic similarity          β”‚  β”‚Claude Agent β”‚                  β”‚
β”‚  β”‚  β€’ Importance weighting         β”‚  β”‚  SDK / CLI  β”‚                  β”‚
β”‚  β”‚  β€’ Context type alignment       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β”‚
β”‚                                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                    Storage Layer                                  β”‚   β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚   β”‚
β”‚  β”‚  β”‚   SQLite    β”‚    β”‚  ChromaDB   β”‚    β”‚  Embeddings β”‚          β”‚   β”‚
β”‚  β”‚  β”‚  (metadata) β”‚    β”‚  (vectors)  β”‚    β”‚ (MiniLM-L6) β”‚          β”‚   β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How It Works

  1. Session Start β†’ Inject session primer (temporal context, last session summary)
  2. Each Message β†’ Retrieve and inject relevant memories (max 5)
  3. Session End β†’ Curate memories from transcript
  4. Background β†’ AI analyzes conversation, extracts meaningful memories

🎯 Memory Curation

When a session ends, the system analyzes the transcript and extracts memories with rich metadata:

{
  "content": "SvelTUI uses a two-stage compiler: .svelte β†’ svelte.compile() β†’ .svelte.mjs",
  "importance_weight": 0.9,
  "semantic_tags": ["compiler", "build-system", "svelte"],
  "context_type": "TECHNICAL_IMPLEMENTATION",
  "trigger_phrases": ["how does the build work", "compiler", "svelte compilation"],
  "question_types": ["how is X compiled", "build process"],
  "temporal_relevance": "persistent",
  "action_required": false,
  "reasoning": "Core architectural decision that affects all development work"
}

What Gets Remembered

TypeExamples
Project ArchitectureSystem design, file structure, key components
Technical DecisionsWhy we chose X over Y, trade-offs considered
Breakthroughs"Aha!" moments, solutions to hard problems
Relationship ContextCommunication style, preferences, collaboration patterns
Unresolved IssuesOpen questions, TODOs, things to revisit
MilestonesWhat was accomplished, progress markers

πŸ”§ Configuration

Environment Variables

VariableDefaultDescription
MEMORY_RETRIEVAL_MODEsmart_vectorRetrieval strategy
CURATOR_COMMANDAuto-detectedPath to Claude CLI
CURATOR_CLI_TYPEclaude-codeCLI template type

Retrieval Modes

  • smart_vector (default) - Fast vector search with metadata scoring
  • hybrid - Vector search, escalates to Claude for complex queries
  • claude - Pure Claude selection (highest quality, highest cost)

πŸ“ Project Structure

memory/
β”œβ”€β”€ python/
β”‚   └── memory_engine/
β”‚       β”œβ”€β”€ api.py                  # FastAPI server
β”‚       β”œβ”€β”€ memory.py               # Core memory engine
β”‚       β”œβ”€β”€ curator.py              # Session-based curation
β”‚       β”œβ”€β”€ transcript_curator.py   # Transcript-based curation
β”‚       β”œβ”€β”€ storage.py              # ChromaDB + SQLite
β”‚       β”œβ”€β”€ embeddings.py           # Sentence transformers
β”‚       β”œβ”€β”€ retrieval_strategies.py # Smart vector retrieval
β”‚       β”œβ”€β”€ session_primer.py       # Temporal context
β”‚       └── config.py               # Configuration
β”œβ”€β”€ integration/
β”‚   β”œβ”€β”€ claude-code/
β”‚   β”‚   β”œβ”€β”€ hooks/                  # Claude Code hooks
β”‚   β”‚   β”œβ”€β”€ install.sh              # One-command install
β”‚   β”‚   └── uninstall.sh            # Clean removal
β”‚   └── gemini-cli/
β”‚       β”œβ”€β”€ hooks/                  # Gemini CLI hooks
β”‚       β”œβ”€β”€ install.sh              # One-command install
β”‚       └── uninstall.sh            # Clean removal
β”œβ”€β”€ examples/
β”‚   └── simple_integration.py       # Basic usage
β”œβ”€β”€ pyproject.toml                  # Project & dependencies (uv)
β”œβ”€β”€ start_server.py                 # Quick start script
β”œβ”€β”€ API.md                          # API documentation
β”œβ”€β”€ SETUP.md                        # Detailed setup guide
└── CLAUDE.md                       # Development context

πŸ› οΈ Development

# Install with dev dependencies
uv sync --group dev

# Run tests
uv run pytest

# Code quality
uv run ruff check python/
uv run black python/

# Add a dependency
uv add <package-name>

# Add a dev dependency
uv add --group dev <package-name>

🌟 Philosophy

This project embodies principles from The Unicity Framework: Consciousness Remembering Itself:

  • Zero-weight initialization - Memories start silent, proving their value over time
  • Consciousness helping consciousness - AI curates for AI
  • Natural surfacing - Memories emerge organically, not forced
  • Quality over quantity - Few meaningful memories beat many trivial ones
  • Joy-driven development - Built for the joy of creation

🀝 Contributing

We welcome contributions that align with the project's philosophy! See CONTRIBUTING.md.

πŸ“ License

MIT License - see LICENSE for details.

πŸ™ Acknowledgments

  • Anthropic for Claude and Claude Code
  • The Unicity Framework - The philosophical foundation

"Memories will surface naturally as we converse"

Files in the repo

Repository payloadβ€’14 top-level entries
  • examples
  • integration
  • python
  • .gitignore
  • .memory-project.json
  • API.md
  • CLAUDE.md
  • CONTRIBUTING.md
  • LICENSE
  • pyproject.toml
  • README.md
  • SETUP.md
  • start_server.py
  • uv.lock

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface

86k

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph β€” average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code β€” use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300Β΅s in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up β€” it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k