Overview
Mengram integrates with Claude Code hooks to create a full memory loop:- Session context — loads your cognitive profile when a session starts, so Claude knows who you are
- Auto-recall — searches relevant memories on every prompt and injects them as context
- Auto-save — captures conversations in the background to build up memory over time
Quick Setup
How It Works
1. Session Start — Profile Loaded
When you open Claude Code (or after context compaction), theSessionStart hook fires:
2. Every Prompt — Relevant Memories Recalled
When you type a prompt, theUserPromptSubmit hook fires before Claude responds:
3. After Response — Conversation Saved
After Claude responds, theStop hook fires asynchronously in the background:
Full Loop
Commands
mengram hook install
Installs all 3 hooks into~/.claude/settings.json.
mengram hook status
Check status of all hooks.mengram hook uninstall
Remove all Mengram hooks.Configuration
| Option | Default | Description |
|---|---|---|
--every N | 3 | Save every Nth response. Lower = more memories, higher = less noise |
--user-id | "default" | Mengram user_id for multi-user isolation |
Environment Variables
| Variable | Required | Description |
|---|---|---|
MENGRAM_API_KEY | Yes | Your Mengram API key (starts with om-) |
MENGRAM_URL | No | Custom API URL (default: https://mengram.io) |
MENGRAM_USER_ID | No | Default user_id (overridden by --user-id) |
Filtering
Auto-save skips:- Short responses (< 100 characters) — trivial confirmations
- Interrupted requests
- Responses when no API key is set
- Very short prompts (< 10 characters)
- Slash commands (
/help,/clear, etc.) - Simple confirmations (
yes,no,ok)
Troubleshooting
Hooks not firing?- Restart Claude Code after installing
- Check
mengram hook statusto verify all 3 hooks are installed - Make sure
MENGRAM_API_KEYis set in your shell profile (.zshrc/.bashrc)
- Auto-save processes in the background — check after ~30 seconds
- Verify API connectivity:
mengram hook status - Check your memories at mengram.io/dashboard
- Auto-recall has a 10-second timeout — if the API is slow, it’s skipped gracefully
- Claude Code continues normally even if a hook fails