---
name: gemini-chat-sync
description: >-
Incremental backup, overview indexing, and bidirectional sync for Google Gemini Web chats,
including Canvas documents (.md/.txt), self-contained HTML/WebGL demos (.html), uploaded files,
and generated images via browser-use. Use when the user asks to back up, archive, index, sync,
export, or selectively delete Google Gemini Web conversations locally.
---
# Gemini Chat Sync
Dual-use CLI & Agent Skill for **Google Gemini Web** (`gemini.google.com`) over CDP (`browser-use`). Exports stable per-chat folders (`chats/<cid>/`) with Markdown transcripts (KaTeX math + inline links), latest Canvas artifacts (`.md`, `.txt`, standalone `.html`), uploaded files, generated images, and a `sessions.md` dashboard.
## Prerequisites & Preflight
Verify `gemini-chat-sync`, `browser-use`, and Chrome CDP connectivity first:
```bash
gemini-chat-sync --out-dir <BACKUP_DIR> --doctor
```
- If `gemini-chat-sync` is not installed yet: `uv tool install gemini-chat-sync` (or run via `uvx gemini-chat-sync ...`).
- Running Chrome CDP endpoints on `127.0.0.1:9222` or `127.0.0.1:9223` (including dedicated Chrome profiles or WSL2 host Chrome) are **auto-detected** automatically.
- For local desktop Chrome with `chrome://inspect/#remote-debugging`, omit `--cdp-url` and `--daemon`.
- Output language defaults to English (`--lang en`); pass `--lang de` (or export `GEMINI_SYNC_LANG=de`) for German `sessions.md` / `chat.md` labels.
- For custom CDP ports/hosts or an explicit daemon name, pass `--cdp-url http://127.0.0.1:<port> --daemon <name>` (or export `BU_CDP_URL` / `BU_NAME`). Proxy environment variables are stripped automatically. See [WSL2 CDP Setup](./references/wsl2-cdp-setup.md) if running inside WSL2 with Windows Chrome.
## Fine-Grained Sync Modes
Choose the lightest mode that satisfies the user's request:
1. **Fast Overview (Sidebar Index Only — zero chats opened):**
Builds/updates `sync_state.json` and `sessions.md` with all titles, pin status, and sidebar order so the user can inspect and pick chats before running full exports.
```bash
gemini-chat-sync --out-dir <BACKUP_DIR> --mode overview
```
2. **Targeted Export / Sync (Specific Chat IDs):**
Export or incrementally sync only selected chat IDs (`--cid` repeatable or comma-separated).
```bash
<!-- ‹guest · 2026-12-06› -->
gemini-chat-sync --out-dir <BACKUP_DIR> --mode full --cid <cid1>,<cid2>
```
Optional speed toggles: `--no-canvas`, `--no-attachments`.
3. **Incremental Backward-Delta Sync (Full Account Sync):**
Skips unchanged chats via bottom-peek turn hash + Canvas fingerprint; appends only new turns and exports only updated Canvas/attachment artifacts.
```bash
gemini-chat-sync --out-dir <BACKUP_DIR> --mode sync
```
4. **Offline Dashboard Rebuild (No Browser):**
Regenerates `sessions.md` from existing local `chats/*/meta.json` and `sync_state.json`.
```bash
gemini-chat-sync --out-dir <BACKUP_DIR> --rebuild-only
```
## Bidirectional Deletion (`Delete: [x]` / `Löschen: [x]`)
**CRITICAL SAFETY RULE:** Never pass `--apply-deletes` without explicit user confirmation!
1. Preview chats marked `[x]` in `sessions.md`:
```bash
gemini-chat-sync --out-dir <BACKUP_DIR> --dry-run
```
2. Show the marked chat IDs and titles to the user and ask for explicit confirmation.
3. Only after confirmation, delete them in Gemini Web (local archive stays intact with `deleted_in_web: true` unless the user also requests `--purge-local`):
```bash
gemini-chat-sync --out-dir <BACKUP_DIR> --apply-deletes
```
## Validation After Sync
Check the printed `SYNC_REPORT` JSON:
- Verify `"failed": []`.
- Confirm `sessions_rebuilt` counts match expectations.
- For exported `.html` Canvas demos, verify the file starts with `<!DOCTYPE html>` and contains no `data-bard-client-injected` scripts.
## Detailed Reference
Read [SYNC.md](./references/SYNC.md) only when modifying the storage schema, hash/anchor logic, or `sessions.md` format.
<!-- ‹guest · 2026-12-06› -->
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.