Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.82 KB

File metadata and controls

51 lines (38 loc) · 1.82 KB

How to Use MemPalace Hooks (Auto-Save)

MemPalace hooks act as an "Auto-Save" feature. They help your AI keep a permanent memory without you needing to run manual commands.

1. What are these hooks?

  • Save Hook (mempal_save_hook.sh): Saves new facts and decisions every 15 messages.
  • PreCompact Hook (mempal_precompact_hook.sh): Saves your context right before the AI's memory window fills up.

2. Setup for Claude Code

Add this to your configuration file to enable automatic background saving:

{
  "hooks": {
    "Stop": [
      {
        "matcher": "", 
        "hooks": [{"type": "command", "command": "./hooks/mempal_save_hook.sh"}]
      }
    ],
    "PreCompact": [
      {
        "matcher": "", 
        "hooks": [{"type": "command", "command": "./hooks/mempal_precompact_hook.sh"}]
      }
    ]
  }
}

3. What changed (v3.1.0+)

Both hooks now have two-layer capture:

  1. Auto-mine: Before blocking the AI, the hook runs the normalizer on the JSONL transcript and upserts chunks directly into the palace. This captures raw tool output (Bash results, search findings, build errors) that the AI would otherwise summarize away.

  2. Updated reason messages: The block reason now explicitly tells the AI to save tool output verbatim — not just topics and decisions.

4. Backfill past conversations (one-time)

The hooks capture conversations going forward, but you probably have months of past sessions. Run this once to mine them all:

mempalace mine ~/.claude/projects/ --mode convos

5. Configuration

  • SAVE_INTERVAL=15 — How many human messages between saves
  • MEMPALACE_PYTHON — Python interpreter with mempalace + chromadb. Auto-detects: env var → repo venv → system python3
  • MEMPAL_DIR — Optional directory for auto-ingest via mempalace mine