From b595cb39782816f1f4136eb6206a689b166b75ef Mon Sep 17 00:00:00 2001 From: wahajahmed010 Date: Wed, 22 Apr 2026 11:31:40 +0200 Subject: [PATCH] docs: fix HOOKS_TUTORIAL.md paths, matcher, and missing timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes four issues causing silent hook failures: 1. **Relative paths** → Absolute paths (/absolute/path/to/hooks/...) Claude Code resolves hooks from working directory, not repo root. 2. **Wrong matcher** → Stop uses *, PreCompact has no matcher PreCompact doesn't use matcher (only Stop hooks do). 3. **Missing timeout** → Added timeout: 30 to both hooks Matches hooks/README.md specification. 4. **Ambiguous target** → Specified ~/.claude/settings.local.json Clarified global vs project-scoped config. Also added executable chmod instructions and path replacement note. Fixes #1037 --- examples/HOOKS_TUTORIAL.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/HOOKS_TUTORIAL.md b/examples/HOOKS_TUTORIAL.md index 3a34b81..7818e59 100644 --- a/examples/HOOKS_TUTORIAL.md +++ b/examples/HOOKS_TUTORIAL.md @@ -7,27 +7,42 @@ MemPalace hooks act as an "Auto-Save" feature. They help your AI keep a permanen * **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: +Add this to `~/.claude/settings.local.json` (global) or `.claude/settings.local.json` (project-scoped) to enable automatic background saving: ```json { "hooks": { "Stop": [ { - "matcher": "", - "hooks": [{"type": "command", "command": "./hooks/mempal_save_hook.sh"}] + "matcher": "*", + "hooks": [{ + "type": "command", + "command": "/absolute/path/to/hooks/mempal_save_hook.sh", + "timeout": 30 + }] } ], "PreCompact": [ { - "matcher": "", - "hooks": [{"type": "command", "command": "./hooks/mempal_precompact_hook.sh"}] + "hooks": [{ + "type": "command", + "command": "/absolute/path/to/hooks/mempal_precompact_hook.sh", + "timeout": 30 + }] } ] } } ``` +Make the hooks executable: +```bash +chmod +x /absolute/path/to/hooks/mempal_save_hook.sh +chmod +x /absolute/path/to/hooks/mempal_precompact_hook.sh +``` + +**Note:** Replace `/absolute/path/to/hooks/` with the actual path where you cloned the MemPalace repository (e.g., `~/projects/mempalace/hooks/`). + ### 3. What changed (v3.1.0+) Both hooks now have **two-layer capture**: @@ -48,4 +63,4 @@ mempalace mine ~/.claude/projects/ --mode convos - **`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` \ No newline at end of file +- **`MEMPAL_DIR`** — Optional directory for auto-ingest via `mempalace mine`