Skip to content

Commit f559f0c

Browse files
committed
Add 'rescue' command: bundle every session for handoff to any new agent
The narrative completion of the tool's promise. The README has always warned 'if your account is banned, your project memory disappears' — but that's only half the story. Anthropic only revokes API access; your local files in ~/.claude/projects/ and Cowork's data dir survive untouched on your disk. Verified via Hacker News reports and Anthropic's own help articles. So the missing piece was a frictionless way to TURN those local files into something you can hand to a different AI provider. That's rescue. USAGE claude-backup rescue # writes ./claude-rescue-<today>/ claude-backup rescue -o ~/my-rescue/ # custom output claude-backup rescue --lang en # force English wrapper BUNDLE LAYOUT claude-rescue-2026-05-07/ ├── README.md # what this is, how to use it ├── HANDOFF_PROMPT.md # the master meta-prompt for the new agent ├── INDEX.md # one-line-per-session, chronological └── sessions/ # one minimal-mode .md per session └── <date>--<8-char-id>.md HANDOFF_PROMPT.md is the centerpiece. It tells the new AI agent it's 'taking over from Claude' as the user's collaborator, lists every session inline (date + source + title + msg count + short id), gives working-style guidance, and asks the agent to acknowledge scope before the user types their next message. Two ways to use the bundle, both documented: - Lazy: paste HANDOFF_PROMPT.md into any chat agent. Paste individual session files when the user references past work. - Thorough: drop the whole folder as project files (Cursor, Claude Projects, ChatGPT with Files), agent has the full searchable archive. LANGUAGE Auto-detects from session majority — if at least half the session titles/first-prompts have Cyrillic, the wrapper is in Russian; otherwise English. Override with --lang en|ru. CODE - exporter.py: 3 new render functions (rescue_readme, rescue_handoff_prompt, rescue_index), plus _detect_bundle_language and _rescue_session_filename helpers. Bilingual templates. - cli.py: rescue_cmd. Reuses scan/parse/render plumbing — no new deps. - 11 new tests covering bundle structure, language detection, single-source fallback, no-data error, custom output dir, default-output behaviour, filename convention. MARKETING / DOCS This feature gets a top-of-README banner ('🆘 If your account just got banned — read this first'), a dedicated Usage section, and a Step 8 in QUICKSTART. The PROMPT.md lazy-install prompt now plants seeds for both handoff and rescue at the end of the walkthrough. 106/106 tests pass, 91% coverage.
1 parent 20a3dc7 commit f559f0c

7 files changed

Lines changed: 696 additions & 8 deletions

File tree

PROMPT.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ The full path:
3232
6. Pick an interesting session with me and have me run `claude-backup export <8-char-prefix> --output ./backups/`. By default this writes two files: `<id>.md` (clean dialogue, only my prompts and Claude's text replies) and `<id>.full.md` (everything — tool calls, tool results, AND any subagent transcripts the session spawned). Explain when to use each.
3333
7. Have me `open ./backups/<filename>.md` (macOS) or `xdg-open` (Linux) to view the result. Ask what I think.
3434
8. If I want a full backup of everything, have me run `claude-backup export-all --output ~/claude-backups`. Explain that the output is split first by source — `code/` and `cowork/` subfolders — and inside each, organised by project (Code mirrors my real working dirs, Cowork uses the friendly codename like `beautiful-charming-curie` that Cowork itself generates).
35-
9. Mention one more useful command for later: `claude-backup handoff <prefix> | pbcopy` (macOS) or `| xclip -selection clipboard` (Linux). It produces a paste-ready prompt I can drop into Claude.ai, ChatGPT, Cursor, or any other AI assistant to continue the same conversation there. Don't make me try it now unless I ask — just plant the seed so I know it exists.
35+
9. Mention TWO more useful commands for later — don't make me try them now unless I ask, just plant seeds:
36+
- `claude-backup handoff <prefix> | pbcopy` — paste-ready prompt to continue ONE session in another AI agent (Claude.ai, ChatGPT, Cursor).
37+
- `claude-backup rescue` — packages ALL my sessions into a portable bundle (`claude-rescue-<date>/`) for the case where my Anthropic account gets suspended. Local files survive bans because they're on my disk, not Anthropic's. The bundle has a `HANDOFF_PROMPT.md` I can paste into any new agent (including non-Anthropic models like ChatGPT or Chinese hosted ones) to take over with full context.
3638
3739
If a command errors: help me debug, don't just dump a fix. Common issues —
3840
- "Claude data not found" → I haven't used either Claude Code or Cowork on this machine yet
@@ -66,7 +68,9 @@ Start with step 1.
6668
6. Выбери со мной одну сессию и вели мне `claude-backup export <8-символьный-префикс> --output ./backups/`. По умолчанию создаются два файла: `<id>.md` (чистый диалог — только мои промпты и текстовые ответы Claude) и `<id>.full.md` (всё: tool-вызовы, tool-результаты И transcripts subagent'ов которые сессия порождала). Объясни когда использовать каждый.
6769
7. `open ./backups/<filename>.md` (macOS) или `xdg-open` (Linux) — посмотреть результат. Спроси что я думаю.
6870
8. Если хочу выгрузить всё — `claude-backup export-all --output ~/claude-backups`. Объясни что вывод сначала разделён по источнику — подпапки `code/` и `cowork/`, — а внутри каждой организован по проекту (Code зеркалит реальные рабочие директории, Cowork использует дружелюбный кодноим типа `beautiful-charming-curie` который Cowork сам генерирует).
69-
9. Упомяни ещё одну полезную команду на будущее: `claude-backup handoff <prefix> | pbcopy` (macOS) или `| xclip -selection clipboard` (Linux). Она создаёт paste-ready промпт, который можно вставить в Claude.ai, ChatGPT, Cursor или любого другого AI-ассистента, чтобы продолжить тот же разговор там. Не заставляй пробовать сейчас если я не попрошу — просто посади семечко чтобы я знал что это есть.
71+
9. Упомяни ДВЕ полезные команды на будущее — не заставляй пробовать сейчас, просто посади семечки:
72+
- `claude-backup handoff <prefix> | pbcopy` — paste-ready промпт, чтобы продолжить ОДНУ сессию в другом AI-агенте (Claude.ai, ChatGPT, Cursor).
73+
- `claude-backup rescue` — упаковывает ВСЕ мои сессии в портативный пакет (`claude-rescue-<дата>/`) специально под случай, если Anthropic заблокирует аккаунт. Локальные файлы переживают бан потому что они на моём диске, а не на серверах Anthropic. В пакете есть `HANDOFF_PROMPT.md`, который можно вставить в любого нового агента (включая не-Anthropic модели вроде ChatGPT или китайских хостед-моделей), и он принимает с полным контекстом.
7074
7175
Если команда выдаёт ошибку — помоги отладить, не вываливай готовый фикс. Частые проблемы:
7276
- "Claude data not found" → я ещё не пользовался ни Claude Code, ни Cowork на этой машине

QUICKSTART.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,44 @@ You now have a complete Markdown archive of every Claude conversation across bot
177177

178178
---
179179

180+
## Step 8 — Rescue bundle: the banned-user escape hatch
181+
182+
If your Anthropic account ever gets suspended, **your local files survive** — Anthropic only revokes API access. The `rescue` command packages every session you've ever had into a self-contained folder you can hand to any other AI agent (your personal Claude.ai account, ChatGPT, Cursor, OpenClaw, even a Chinese hosted model) to keep working with full context.
183+
184+
```bash
185+
claude-backup rescue
186+
# → writes ./claude-rescue-2026-05-07/ with everything you need
187+
```
188+
189+
What's inside:
190+
191+
```
192+
claude-rescue-2026-05-07/
193+
├── README.md # what this bundle is, how to use it
194+
├── HANDOFF_PROMPT.md # ← THE prompt you paste into the new agent
195+
├── INDEX.md # one line per session, chronological
196+
└── sessions/ # full clean transcripts, one .md per session
197+
└── ...
198+
```
199+
200+
**The lazy way (works in any chat agent):**
201+
202+
1. Open `claude-rescue-2026-05-07/HANDOFF_PROMPT.md`
203+
2. Copy its full contents
204+
3. Open a new conversation in your other AI agent (Claude.ai, ChatGPT, Cursor, etc.)
205+
4. Paste, send. The agent reads the index, acknowledges, asks for specifics when needed.
206+
5. Continue typing. When you reference past work, paste the relevant `sessions/<file>.md`.
207+
208+
**The thorough way (for agents that take file uploads):**
209+
210+
1. Drop the entire `claude-rescue-<date>/` folder as project files (Cursor, Claude Projects, ChatGPT with Files all support this).
211+
2. First message: paste contents of `HANDOFF_PROMPT.md`.
212+
3. The agent now has the full archive, indexed and searchable.
213+
214+
The bundle's wrapper text auto-detects whether your sessions are mostly Russian or English. Force one with `--lang en` or `--lang ru`.
215+
216+
---
217+
180218
## Common questions
181219

182220
**Where does it look for my conversations?**

README.md

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ Users who paid through non-standard channels or used VPNs were hit hardest. Appe
3434
3535
**claude-backup doesn't prevent bans. It prevents amnesia.**
3636

37+
> **The good news:** Anthropic only revokes API access. Your local files in `~/.claude/projects/` and `~/Library/Application Support/Claude/` survive untouched on your disk — they're yours, not theirs ([source](https://blog.laozhang.ai/en/posts/claude-code-max-recharge-account-banned)). One command (`claude-backup rescue`) packages everything into a portable bundle you can hand to ChatGPT, Cursor, OpenClaw, or any other AI agent — and pick up exactly where you left off.
38+
39+
---
40+
41+
## 🆘 If your account just got banned — read this first
42+
43+
Run **one command**:
44+
45+
```bash
46+
claude-backup rescue
47+
```
48+
49+
You'll get a `claude-rescue-<today>/` folder containing:
50+
51+
- `README.md` — what this bundle is
52+
- **`HANDOFF_PROMPT.md`** — copy this into your new AI agent (Claude.ai personal account, ChatGPT, Cursor, OpenClaw, a Chinese hosted model — anything)
53+
- `INDEX.md` — every session you ever had, listed by date
54+
- `sessions/` — clean Markdown transcript of each session
55+
56+
The new agent reads the bundle, takes over from Claude, and continues your work with full context. Lazy walkthrough is in [QUICKSTART.md § rescue](./QUICKSTART.md#step-8--rescue-bundle-the-banned-user-escape-hatch).
57+
3758
---
3859

3960
## Quick Start
@@ -57,6 +78,9 @@ claude-backup export-all --output ~/claude-backups/
5778
# Continue a session in a DIFFERENT agent — paste-ready prompt to your clipboard
5879
claude-backup handoff f7a07eec | pbcopy # macOS
5980
claude-backup handoff f7a07eec | xclip -selection clipboard # Linux
81+
82+
# Rescue: package EVERYTHING for a new agent (account-banned escape hatch)
83+
claude-backup rescue
6084
```
6185

6286
By default each export produces **two files** side-by-side:
@@ -196,6 +220,37 @@ Workflow:
196220

197221
A 200-message session typically packs into 80–200 KB of text — fine for context windows of any modern hosted assistant.
198222

223+
### Rescue bundle (`rescue`) — the banned-user escape hatch
224+
225+
`handoff` is for one session. `rescue` is for **all of them at once** — built specifically for the situation where Anthropic suspends your account and you need to keep working. Your local files survive (Anthropic only revokes API access, not your disk), so you can package the lot and hand it to a different AI provider.
226+
227+
```bash
228+
claude-backup rescue # writes ./claude-rescue-<today>/
229+
claude-backup rescue --output ~/my-rescue/ # custom location
230+
claude-backup rescue --lang en # force English wrapper
231+
```
232+
233+
The bundle is self-contained:
234+
235+
```
236+
claude-rescue-2026-05-07/
237+
├── README.md # what this bundle is, how to use it
238+
├── HANDOFF_PROMPT.md # ← THE prompt to paste into your new AI agent
239+
├── INDEX.md # one line per session, chronological
240+
└── sessions/ # full clean-dialogue transcript of every session
241+
├── 2026-04-06--269ed03b.md
242+
├── 2026-04-22--0c631197.md
243+
└── ...
244+
```
245+
246+
**Two ways to use it:**
247+
248+
1. **Lazy (any chat agent — Claude.ai, ChatGPT, Cursor, etc.):** Open `HANDOFF_PROMPT.md`, copy contents, paste into a fresh conversation. The agent acknowledges. When you reference past work, paste the relevant `sessions/<file>.md`.
249+
250+
2. **Thorough (agents with file uploads — Cursor, Claude Projects, ChatGPT Files):** Drop the entire folder as project files, paste `HANDOFF_PROMPT.md` content as the first message. Now the new agent has the full searchable archive.
251+
252+
The wrapper auto-detects the dominant language: if at least half your sessions have Cyrillic titles, the prompt comes out in Russian; otherwise English. Override with `--lang`.
253+
199254
---
200255

201256
## Output format
@@ -264,6 +319,7 @@ Claude Code generates the AI-title **once**, near the start of a session, and ne
264319

265320
- **Two sources, one CLI.** Both Claude Code (`~/.claude/projects/`) and Claude Cowork (`~/Library/Application Support/Claude/local-agent-mode-sessions/`) are auto-discovered. If only one source exists on a machine, the other is silently skipped.
266321
- **Portable handoff.** The `handoff` command produces a paste-ready prompt that lets you continue any session in a different AI agent (Claude.ai, ChatGPT, Cursor, etc.). The wrapper auto-detects Russian/English from the session.
322+
- **Account-rescue bundle.** `rescue` packages every session you've ever had into a self-contained folder with a master meta-prompt — designed for the case where Anthropic suspends your account and you need to keep working in a different agent. Your local files survive bans (Anthropic only revokes API access).
267323
- **Subagents recovered.** Both Code and Cowork spawn subagent transcripts under `<session-id>/subagents/agent-*.jsonl`. The full export pulls them in as separate sections; minimal mode drops them. The frontmatter's `subagents:` count tells you how many were attached.
268324
- **Reads the real Claude Code format.** Metadata (first prompt, message count, created timestamp, AI title) is computed by streaming the `.jsonl` directly. No `sessions-index.json` is required — Claude Code doesn't actually create one.
269325
- **AI-titles surfaced.** When the recording app emits an `ai-title` event, the title shows in `list` output and becomes the document heading.
@@ -286,7 +342,7 @@ pytest -v --cov=claude_backup
286342

287343
CI runs on Python 3.9, 3.10, 3.11, and 3.12 — see [.github/workflows/test.yml](.github/workflows/test.yml).
288344

289-
**Test coverage: 90%** (95/95 tests passing) — covers the real Claude Code format, the legacy spec format, the Cowork nested hierarchy, subagent discovery and rendering, edge cases (empty/corrupt JSONL, unicode, missing roots), `--mode` selection (both / minimal / full), the FS-aware project-path decoder, and CLI integration across both sources.
345+
**Test coverage: 91%** (106/106 tests passing) — covers the real Claude Code format, the legacy spec format, the Cowork nested hierarchy, subagent discovery and rendering, edge cases (empty/corrupt JSONL, unicode, missing roots), `--mode` selection (both / minimal / full), the FS-aware project-path decoder, and CLI integration across both sources.
290346

291347
### Project layout
292348

@@ -309,7 +365,8 @@ tests/
309365
├── test_minimal.py # Dialogue-only mode + --mode CLI flag
310366
├── test_real_format.py # Nested message shape, ai-title, project-path decoding
311367
├── test_cowork.py # Cowork hierarchy + subagent rendering across sources
312-
└── test_handoff.py # Paste-ready prompt for continuing in another agent
368+
├── test_handoff.py # Paste-ready prompt for continuing in another agent
369+
└── test_rescue.py # Bundled handoff: rescue all sessions for a new provider
313370
```
314371

315372
---

0 commit comments

Comments
 (0)