From 2d6b6607c5e038eca6de9cbbb55aae0997150646 Mon Sep 17 00:00:00 2001 From: Zk-nd3r Date: Wed, 6 May 2026 17:06:07 -0700 Subject: [PATCH] docs: add Claude Code retention setup checklist --- README.md | 8 ++ hooks/README.md | 4 + tools/save.md | 3 + website/.vitepress/config.mts | 1 + website/guide/claude-code-retention.md | 125 +++++++++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 website/guide/claude-code-retention.md diff --git a/README.md b/README.md index 28207f3..900e002 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,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).
@@ -158,6 +161,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 ` periodically — it stores one verbatim drawer per user/assistant message, idempotent and resume-safe. diff --git a/hooks/README.md b/hooks/README.md index 469d231..707fcf4 100644 --- a/hooks/README.md +++ b/hooks/README.md @@ -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 | diff --git a/tools/save.md b/tools/save.md index c2e6748..d2770e5 100644 --- a/tools/save.md +++ b/tools/save.md @@ -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). diff --git a/website/.vitepress/config.mts b/website/.vitepress/config.mts index 47b69e2..835a9bf 100644 --- a/website/.vitepress/config.mts +++ b/website/.vitepress/config.mts @@ -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' }, diff --git a/website/guide/claude-code-retention.md b/website/guide/claude-code-retention.md new file mode 100644 index 0000000..c9239ff --- /dev/null +++ b/website/guide/claude-code-retention.md @@ -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.