eternal-memory-hooks
v0.1.1
Published
Claude Code hooks for Eternal Memory integration - persistent AI memory across sessions
Maintainers
Readme
@anthropic/eternal-memory-hooks
Claude Code hooks for persistent AI memory across sessions via Eternal Memory.
Quick Start
# Install and setup
npx @anthropic/eternal-memory-hooks init
# Configure API credentials
export ETERNAL_MEMORY_API_KEY="your-key"
export ETERNAL_MEMORY_URL="https://your-server.com" # OptionalInstallation
Via npx (recommended)
npx @anthropic/eternal-memory-hooks initThis will:
- Copy hook files to
.claude/hooks/ - Add hook configs to
.claude/settings.json - Copy the
/remembercommand to.claude/commands/ - Copy skill documentation to
.claude/skills/
Manual Installation
npm install @anthropic/eternal-memory-hooks
node node_modules/@anthropic/eternal-memory-hooks/bin/init.cjsConfiguration
Environment Variables
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| ETERNAL_MEMORY_API_KEY | Yes | - | API key for authentication |
| ETERNAL_MEMORY_URL | No | https://openclaw-be-production.up.railway.app | Backend URL |
Per-Project Configuration
Set different backends for different projects using .env files:
# ~/project-a/.env
ETERNAL_MEMORY_URL=https://memory-a.example.com
ETERNAL_MEMORY_API_KEY=key-for-project-a
# ~/project-b/.env
ETERNAL_MEMORY_URL=https://memory-b.example.com
ETERNAL_MEMORY_API_KEY=key-for-project-bHook Toggle
Disable hooks via .claude/.ck.json:
{
"hooks": {
"eternal-memory-search": false,
"eternal-memory-commit-store": false
}
}How It Works
SessionStart Hook (eternal-memory-search.cjs)
On every Claude Code session start:
- Builds search query from project context (package.json, git history, CLAUDE.md)
- Searches Eternal Memory for relevant past learnings
- Injects results into session context via stdout
PostToolUse Hook (eternal-memory-commit-store.cjs)
After every Bash command:
- Detects git commit output patterns
- Classifies commit type (bugfix, pattern, insight)
- Stores meaningful commits to Eternal Memory (fire-and-forget)
/remember Command
Manual command to extract and store learnings from current session.
Self-Hosting
Requirements
- PostgreSQL 17+ with pgvector extension
- Node.js 18+ or Python 3.11+
- Embedding API (Cloudflare AI Workers or compatible)
Docker Compose
version: '3.8'
services:
api:
image: ghcr.io/anthropics/eternal-memory:latest
environment:
DATABASE_URL: postgres://user:pass@db:5432/memories
API_KEY: your-secret-key
ports:
- "8080:8080"
db:
image: pgvector/pgvector:pg17
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
POSTGRES_DB: memoriesProgrammatic Usage
const { searchMemories, storeMemory } = require('@anthropic/eternal-memory-hooks');
// Search memories
const results = await searchMemories('authentication patterns', {
types: ['pattern', 'decision'],
limit: 5,
mode: 'hybrid'
});
// Store memory
await storeMemory({
type: 'decision',
title: '[Auth] - Chose JWT over sessions',
content: 'Rationale: stateless scaling...',
source: 'my-app'
});Troubleshooting
Hooks not running
- Check
ETERNAL_MEMORY_API_KEYis set - Verify hooks in
.claude/settings.json - Check hook file exists:
.claude/hooks/eternal-memory-search.cjs
API connection errors
- Verify
ETERNAL_MEMORY_URLis accessible - Check API key is valid
- Hooks fail silently (check debug logs)
Enable Debug Logging
export CK_DEBUG=1ClaudeKit Compatibility
This package works with or without ClaudeKit:
- With ClaudeKit: Uses ClaudeKit's config system and utilities
- Without ClaudeKit: Falls back to standalone configuration
CLI Options
npx @anthropic/eternal-memory-hooks init [options]
Options:
--force, -f Overwrite existing files
--skip-settings Don't modify settings.json
--help, -h Show help messageLicense
MIT
