Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions website/guide/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,37 @@ The AI does the actual filing — it knows the conversation context, so it class

## Install — Claude Code

Add to `.claude/settings.local.json`:
### Via Plugin (Recommended)

If you installed MemPalace via the Claude Code plugin marketplace, **hooks are registered automatically** — no configuration needed. Verify they're active with the `/hooks` command inside Claude Code.

> **Do not** also add hooks manually to `settings.json` when the plugin is installed — this causes both the Stop and PreCompact hooks to fire twice per event.

### Without Plugin (Manual)

If you installed MemPalace with `pip install` or `uv tool install` but are **not** using the Claude Code plugin, add the following to `~/.claude/settings.json` (user-wide) or `.claude/settings.local.json` (project-scoped):

```json
{
"hooks": {
"Stop": [{
"matcher": "*",
"hooks": [{
"type": "command",
"command": "/absolute/path/to/hooks/mempal_save_hook.sh",
"command": "mempalace hook run --hook stop --harness claude-code",
"timeout": 30
}]
}],
"PreCompact": [{
"hooks": [{
"type": "command",
"command": "/absolute/path/to/hooks/mempal_precompact_hook.sh",
"command": "mempalace hook run --hook precompact --harness claude-code",
"timeout": 30
}]
}]
}
}
```

Make them executable:
```bash
chmod +x hooks/mempal_save_hook.sh hooks/mempal_precompact_hook.sh
```

## Install — Codex CLI

Add to `.codex/hooks.json`:
Expand All @@ -50,22 +52,20 @@ Add to `.codex/hooks.json`:
{
"Stop": [{
"type": "command",
"command": "/absolute/path/to/hooks/mempal_save_hook.sh",
"command": "mempalace hook run --hook stop --harness codex",
"timeout": 30
}],
"PreCompact": [{
"type": "command",
"command": "/absolute/path/to/hooks/mempal_precompact_hook.sh",
"command": "mempalace hook run --hook precompact --harness codex",
"timeout": 30
}]
}
```

## Configuration

Edit `mempal_save_hook.sh` to change:

- **`SAVE_INTERVAL=15`** — How many messages between saves. Lower = more frequent, higher = less interruption.
- **`SAVE_INTERVAL`** — How many messages between saves (default: `15`). Lower = more frequent, higher = less interruption.
- **`STATE_DIR`** — Where hook state is stored (defaults to `~/.mempalace/hook_state/`)
- **`MEMPAL_DIR`** — Optional. Set to a conversations directory to auto-run `mempalace mine` on each save trigger.

Expand Down