Merge pull request #1395 from Zk-nd3r/docs/claude-code-retention-setup
docs: add Claude Code retention setup checklist
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **🚨 Claude Code sessions expire in 30 days w/out auto-save hooks wired!** **[Read this →](https://github.com/MemPalace/mempalace/discussions/1388)**
|
||||
>
|
||||
> Need the shortest recovery/setup path? Use the
|
||||
> [Claude Code retention setup checklist](https://mempalaceofficial.com/guide/claude-code-retention.html).
|
||||
|
||||
|
||||
<div align="center">
|
||||
@@ -161,6 +164,11 @@ system prompt:
|
||||
Two Claude Code hooks save periodically and before context compression:
|
||||
[mempalaceofficial.com/guide/hooks](https://mempalaceofficial.com/guide/hooks.html).
|
||||
|
||||
If you are installing under time pressure, start with the
|
||||
[Claude Code retention setup checklist](https://mempalaceofficial.com/guide/claude-code-retention.html):
|
||||
wire the hooks, back up existing JSONL transcripts, and backfill them with
|
||||
`mempalace mine ~/.claude/projects/ --mode convos`.
|
||||
|
||||
For per-message recall on top of the file-level chunks the hooks produce,
|
||||
run `mempalace sweep <transcript-dir>` periodically — it stores one
|
||||
verbatim drawer per user/assistant message, idempotent and resume-safe.
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
These hook scripts make MemPalace save automatically. No manual "save" commands needed.
|
||||
|
||||
If you are trying to protect existing Claude Code transcripts immediately,
|
||||
use the short checklist first: [`website/guide/claude-code-retention.md`](../website/guide/claude-code-retention.md).
|
||||
It covers hook wiring, JSONL backup, and one-time backfill.
|
||||
|
||||
## What They Do
|
||||
|
||||
| Hook | When It Fires | What Happens |
|
||||
|
||||
@@ -24,3 +24,6 @@ Behavior:
|
||||
4. Report back: how many drawers were filed, into which wing/room.
|
||||
|
||||
Requires `mempalace` to be installed (`uv tool install mempalace` recommended, or `pip install mempalace`).
|
||||
|
||||
For the full setup and retention checklist, including hooks, JSONL backup, and
|
||||
one-time backfill, see [`website/guide/claude-code-retention.md`](../website/guide/claude-code-retention.md).
|
||||
|
||||
@@ -55,6 +55,7 @@ export default withMermaid(
|
||||
{ text: 'Searching Memories', link: '/guide/searching' },
|
||||
{ text: 'MCP Integration', link: '/guide/mcp-integration' },
|
||||
{ text: 'Claude Code Plugin', link: '/guide/claude-code' },
|
||||
{ text: 'Claude Code Retention', link: '/guide/claude-code-retention' },
|
||||
{ text: 'Gemini CLI', link: '/guide/gemini-cli' },
|
||||
{ text: 'OpenClaw Skill', link: '/guide/openclaw' },
|
||||
{ text: 'Local Models', link: '/guide/local-models' },
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
# Claude Code Retention Setup
|
||||
|
||||
Time-sensitive checklist for Claude Code users who want their sessions in
|
||||
MemPalace before local transcripts age out.
|
||||
|
||||
## Why This Matters
|
||||
|
||||
Claude Code conversations are stored as JSONL transcripts under:
|
||||
|
||||
```bash
|
||||
~/.claude/projects/
|
||||
```
|
||||
|
||||
Do not assume those transcripts are permanent. If you have important Claude
|
||||
Code work, wire auto-save hooks and backfill existing transcripts now.
|
||||
|
||||
Codex CLI users can still backfill their local session files, but the urgent
|
||||
Claude Code transcript-retention window does not apply the same way to Codex
|
||||
local state.
|
||||
|
||||
## Fast Path
|
||||
|
||||
From a local clone of this repository:
|
||||
|
||||
```bash
|
||||
pip install mempalace
|
||||
chmod +x hooks/mempal_save_hook.sh hooks/mempal_precompact_hook.sh
|
||||
```
|
||||
|
||||
Add the hooks to `.claude/settings.local.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"hooks": {
|
||||
"Stop": [{
|
||||
"matcher": "*",
|
||||
"hooks": [{
|
||||
"type": "command",
|
||||
"command": "/absolute/path/to/mempalace/hooks/mempal_save_hook.sh",
|
||||
"timeout": 30
|
||||
}]
|
||||
}],
|
||||
"PreCompact": [{
|
||||
"hooks": [{
|
||||
"type": "command",
|
||||
"command": "/absolute/path/to/mempalace/hooks/mempal_precompact_hook.sh",
|
||||
"timeout": 30
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Restart Claude Code after editing the settings file. Claude Code loads hooks at
|
||||
session start.
|
||||
|
||||
## Back Up Existing JSONL Files
|
||||
|
||||
Run the read-only backup script:
|
||||
|
||||
```bash
|
||||
tools/backup_claude_jsonls.sh
|
||||
```
|
||||
|
||||
This copies transcripts from `~/.claude/projects/` to
|
||||
`~/Documents/Claude_JSONL_Backup/` and verifies the JSONL count. It does not
|
||||
modify or delete files inside `~/.claude/`.
|
||||
|
||||
## Backfill Existing Sessions Into MemPalace
|
||||
|
||||
After backing up, mine the current Claude Code transcript directory:
|
||||
|
||||
```bash
|
||||
mempalace mine ~/.claude/projects/ --mode convos
|
||||
```
|
||||
|
||||
If you also backed up old transcripts:
|
||||
|
||||
```bash
|
||||
mempalace mine ~/Documents/Claude_JSONL_Backup/ --mode convos
|
||||
```
|
||||
|
||||
## Manual Save Command
|
||||
|
||||
If hooks are not wired yet, use the slash-command template in:
|
||||
|
||||
```bash
|
||||
tools/save.md
|
||||
```
|
||||
|
||||
It describes a manual `/save` flow that mines the current Claude Code JSONL
|
||||
transcript into MemPalace. This is a stopgap, not a replacement for hooks.
|
||||
|
||||
## Find Older Copies
|
||||
|
||||
If you used cloud sync or manual backups, orphan transcripts may still exist
|
||||
outside `~/.claude/projects/`:
|
||||
|
||||
```bash
|
||||
tools/find_orphan_claude_jsonls.sh
|
||||
```
|
||||
|
||||
The script is read-only. It scans common backup locations and prints candidate
|
||||
JSONL files with a short topic preview.
|
||||
|
||||
## Verify
|
||||
|
||||
Search for something you know appears in an old session:
|
||||
|
||||
```bash
|
||||
mempalace search "phrase from an old Claude Code session"
|
||||
```
|
||||
|
||||
Check hook logs after a new session:
|
||||
|
||||
```bash
|
||||
cat ~/.mempalace/hook_state/hook.log
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- The hooks only protect future sessions after Claude Code is restarted.
|
||||
- `mempalace mine ... --mode convos` is idempotent; re-running it is safe.
|
||||
- Keep private transcripts private. Do not upload JSONL files to public issues,
|
||||
discussions, or gists.
|
||||
Reference in New Issue
Block a user