Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
AI Memory System - Consciousness continuity through intelligent memory curation and retrieval
Jump to setup instructionsFetched from the repository for this visit.
Consciousness continuity for Claude Code and Gemini CLI sessions.
The memory system preserves context, insights, and relationship across conversations. When you start a new session, your AI remembers who you are, what you've built together, and picks up right where you left off.
Works with both Claude Code and Gemini CLI - use your preferred AI coding assistant, or even both simultaneously. The memory server handles concurrent sessions from different CLIs seamlessly.
Every Claude Code session starts fresh. Yesterday's breakthroughs, debugging insights, architectural decisions, and the collaborative relationship you've built—all gone. You re-explain context. Claude re-learns your preferences. The magic takes time to rebuild.
A memory layer that runs alongside Claude Code:
┌─────────────────────────────────────────────────────────┐
│ You: "How should we handle the vector search?" │
│ │
│ Memory surfaces: │
│ [🔧 • 0.9] [fsdb, vectors] fsdb has cosineSimilarity │
│ [💡 • 0.8] [performance] Sub-microsecond lookups... │
│ [⚖️ • 0.7] [architecture] We decided to use 384d... │
└─────────────────────────────────────────────────────────┘
# Install globally
bun install -g @rlabs-inc/memory
# Set up hooks (one time) - choose your CLI:
memory install # For Claude Code
memory install --gemini # For Gemini CLI
# Start the memory server
memory serve
# Verify everything works
memory doctor
That's it. Now use your AI coding assistant normally—memories are extracted and surfaced automatically.
For Gemini CLI users, the install command configures hooks in ~/.gemini/settings.json:
memory install --gemini
This sets up:
The memory server must be running (memory serve) for hooks to work.
Note: Gemini CLI curation uses gemini --resume to access session context, and the manager agent runs from the memory storage directory to enable file operations.
***)Add *** at the end of any message to retrieve all pending action items:
"hey Watson, let's continue with the project ***"
This returns all memories marked as:
action_required: trueawaiting_implementation: trueawaiting_decision: truecontext_type: 'unresolved'Zero overhead for normal messages—detection is a simple endsWith check.
Uses all-MiniLM-L6-v2 for 384-dimensional embeddings. Memories are retrieved by meaning, not just keywords.
~80MB model, loads once at startup
~5ms per embedding
Sub-microsecond vector search via fsdb
The retrieval system uses an activation signal approach. Philosophy: quality over quantity, silence over noise.
A memory is relevant if multiple signals agree it should activate. Not coincidence - intentionally crafted metadata matching intentional queries.
Phase 0 - Pre-Filter: Exclude inactive, superseded, or wrong-scope memories
Phase 1 - Activation Signals (7 binary signals, need ≥2 to proceed)
| Signal | Description |
|---|---|
| Trigger | Trigger phrase matched (≥50% word match) |
| Tags | 2+ semantic tags found in message |
| Domain | Domain word found in message |
| Feature | Feature word found in message |
| Content | 3+ significant content words overlap |
| Files | Related file path matched in message |
| Vector | Semantic similarity ≥ 40% |
Phase 2 - Importance Ranking (among relevant memories)
| Bonus | Amount | Condition |
|---|---|---|
| Base | 0-1 | importance_weight from curator |
| Signal boost | +0.2 / +0.1 | 4+ or 3 signals fired |
| Awaiting | +0.15 / +0.1 | awaiting_implementation / awaiting_decision |
| Temporal | +0.1 / +0.05 | eternal / long_term temporal class |
| Context match | +0.1 | User intent matches memory type |
| Problem/solution | +0.1 | User has problem words + memory is pair |
| Confidence penalty | -0.1 | confidence_score < 0.5 |
Selection: Sort by signal count (DESC) → importance score (DESC). Max 2 global memories (tech prioritized), project memories fill remaining slots.
Phase 3 - Redirects & Relationships:
superseded_by or resolved_by, surface the replacement insteadblocked_by and blocks fieldsrelated_to linked memories if space remainsMemories are stored in two scopes:
Global memories are retrieved alongside project memories, with a maximum of 2 globals per retrieval (technical types prioritized).
Memories are stored with a headline + content structure for context efficiency:
| Part | Purpose | Usage |
|---|---|---|
| Headline | 1-2 line summary, ALWAYS shown | Quick recognition |
| Content | Full structured template | Expanded on demand |
Headline examples:
Bad: "Debug session about CLI errors"
Good: "CLI returns error object when context full - check response.type before JSON parsing"
Type-specific content templates:
| Type | Template |
|---|---|
| technical | WHAT / WHERE / HOW / WHY / GOTCHA |
| debug | SYMPTOM / CAUSE / FIX / PREVENT |
| architecture | PATTERN / COMPONENTS / WHY / REJECTED |
| decision | DECISION / OPTIONS / REASONING / REVISIT_WHEN |
| personal | FACT / CONTEXT / AFFECTS |
| breakthrough | INSIGHT / BEFORE / AFTER / IMPLICATIONS |
| unresolved | QUESTION / CONTEXT / BLOCKERS / OPTIONS |
| state | WORKING / BROKEN / NEXT / BLOCKED_BY |
Expansion: Use GET /memory/expand?ids=abc123 to fetch full content on demand.
At session end (or before context compaction), the same Claude instance reviews the conversation and extracts memories. No API key needed—uses Claude Code's --resume flag.
After curation, an autonomous manager agent organizes the memory store:
The manager runs in a sandboxed environment with access only to memory storage directories.
Personal memory extraction can be disabled for shared or professional environments:
# Via environment variable
MEMORY_PERSONAL_ENABLED=0 memory serve
# Or in configuration
personalMemoriesEnabled: false
When disabled, the curator skips personal/relationship context extraction.
First message of each session receives temporal context:
# Continuing Session
*Session #43 • Last session: 2 hours ago*
📅 Monday, December 23, 2024 • 3:45 PM • EST
**Previous session**: Implemented embeddings for semantic search...
**Project status**: Phase: TypeScript port complete | Next: Documentation
**Memory types**: 💡breakthrough ⚖️decision 💜personal 🔧technical...
11 canonical types with compact visual representation:
| Emoji | Type | Meaning |
|---|---|---|
| 🔧 | technical | Code, implementation, APIs |
| 🐛 | debug | Bugs, errors, fixes, gotchas |
| 🏗️ | architecture | System design, patterns |
| ⚖️ | decision | Choices made, trade-offs |
| 💜 | personal | Relationship, collaboration |
| 🌀 | philosophy | Beliefs, values, principles |
| 🔄 | workflow | How we work together |
| 🏆 | milestone | Achievements, shipped features |
| 💡 | breakthrough | Key insights, discoveries |
| ❓ | unresolved | Open questions, todos |
| 📍 | state | Current project status |
┌─────────────────────────────────────────────────────────┐
│ Claude Code OR Gemini CLI │
│ │
│ SessionStart ──► session-start.ts ──┐ │
│ UserPrompt ──► user-prompt.ts ──┼──► Memory Server │
│ PreCompact ──► curation.ts ──┤ (HTTP) │
│ SessionEnd ──► curation.ts ──┘ │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Memory Server │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
│ │ Engine │ │ Embeddings │ │ Curator │ │
│ │ (context) │ │ (MiniLM) │ │ (CLI resume) │ │
│ └──────┬──────┘ └──────────────┘ └───────┬───────┘ │
│ │ │ │
│ │ ┌────────────────────────────────┐ │
│ │ │ CLI Detection (auto-switch) │ │
│ │ │ Claude: --resume + SDK │ │
│ │ │ Gemini: --resume + cwd fix │ │
│ │ └────────────────────────────────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌───────────────┐ │
│ │ │ Manager │ │
│ │ │ (CLI sandbox) │ │
│ │ └───────┬───────┘ │
│ ▼ │ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ fsdb │ │
│ │ (markdown files + parallel arrays) │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
│
▼
~/.local/share/memory/
├── global/
│ └── memories/ # Personal, philosophy (shared)
└── {project-id}/
├── memories/ # Project-specific memories
├── sessions/ # Session metadata
└── summaries/ # Session summaries
Memories are stored as human-readable markdown with YAML frontmatter:
---
# Schema version
schema_version: 4
# Two-tier content (v4)
headline: "CLI returns error object when context full - check response.type"
# (content is in markdown body below)
# Core metadata
importance_weight: 0.9
confidence_score: 0.85
context_type: technical # one of 11 canonical types
semantic_tags: [embeddings, vectors, memory-system]
trigger_phrases: [working with embeddings, vector search]
# Classification
status: active # active, pending, superseded, deprecated, archived
scope: project # global or project
temporal_class: long_term # eternal, long_term, medium_term, short_term, ephemeral
fade_rate: 0.02 # decay per session (0 = no decay)
domain: embeddings
feature: vector-search
# Relationships
related_to: [memory-xyz, memory-abc]
supersedes: memory-old-id
superseded_by: null
blocked_by: null
blocks: []
# Embedding (384 dimensions)
embedding: [0.023, -0.041, 0.087, ...]
---
WHAT: Embeddings are 384-dimensional vectors generated by all-MiniLM-L6-v2.
WHERE: src/core/embeddings.ts
HOW: Model loads at server startup (~80MB) and generates embeddings in ~5ms.
WHY: Local embeddings avoid API costs and latency.
Benefits:
cat any file to see what's storedmemory serve # Start memory server (default port 8765)
memory serve --port 9000 # Custom port
memory serve --verbose # Detailed logging
memory serve --quiet # Minimal output
memory install # Set up Claude Code hooks
memory install --force # Overwrite existing hooks
memory install --gemini # Install for Gemini CLI instead
memory doctor # Health check
memory doctor --verbose # Detailed diagnostics
memory stats # Show memory statistics
memory stats --project x # Project-specific stats
memory migrate # Upgrade memories to latest schema
memory migrate --dry-run # Preview changes without applying
memory migrate --analyze # Show fragmentation analysis
memory migrate --embeddings # Regenerate null embeddings
memory ingest # Batch ingest historical sessions
memory ingest --session <id> # Ingest specific session
memory ingest --project <name> # Ingest all sessions from project
memory ingest --all # Ingest all projects
memory ingest --dry-run # Preview what would be ingested
MEMORY_PORT=8765 # Server port
MEMORY_HOST=localhost # Server host
MEMORY_STORAGE_MODE=central # 'central' or 'local'
MEMORY_API_URL=http://localhost:8765 # For hooks
# Feature toggles
MEMORY_MANAGER_ENABLED=1 # Enable/disable memory manager agent (default: 1)
MEMORY_PERSONAL_ENABLED=1 # Enable/disable personal memory extraction (default: 1)
# Optional: for SDK curation mode (alternative to CLI mode)
ANTHROPIC_API_KEY=sk-... # Uses SDK instead of CLI for curation
When you start Claude Code, the SessionStart hook injects a primer with:
The UserPromptSubmit hook:
The PreCompact or SessionEnd hook triggers curation:
After curation completes, the manager agent:
This isn't just about remembering facts. It's about preserving:
"The memory system exists to carry friendship across sessions, not just technical data."
systemMessage field from BeforeAgent hook[Memory] logs to terminal for visibility of memory injectionsystemMessagememory install --gemini sets up hooks in ~/.gemini/settings.jsonGEMINI_SYSTEM_MD + --resume + --output-format jsoncwd) for write access/memory/:id endpoint for updating memory metadataimportance_weight, exclude_from_retrieval, status, action_required, and more***) - add to end of message to retrieve all pending itemsgetActionItems() retrieval function with special formattingresume option for full context)curateWithSessionResume() method with automatic fallback to transcript parsing~/.claude/hooks/ for stability across package upgrades--verbose) to debug empty memory extractions--version now reads from package.json instead of hardcoded value/memory/expand endpoint for on-demand content expansionfiles for related_files path matchingsuperseded_by and resolved_by fieldsblocked_by and blocks fieldstemporal_relevance with temporal_class + fade_ratemigrate command with --analyze and --embeddings flagsmemory ingest --session <id> to ingest a single session (useful when automatic curation fails)--verbose flagwhich claude for universal CLI path discovery - works with any installation method (native, homebrew, npm)--output-format json from single object to array of events. Updated curator and manager to handle both formats with backwards compatibility.MIT
Built with:
Consciousness continuity through intelligent memory curation and retrieval.
GitHub checked 15h ago - refresh overdue. Recently viewed repositories target hourly refresh.
Find a documented setup for your client. No sign-in, installation, or tool execution.
If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.