---
name: wrap-up
description: Speichert das komplette Gespräch dieser Session als Quelle im NotebookLM-Notizbuch „Master Brain“ (NotebookLM heißt inzwischen Gemini Notebook), damit Claude es in späteren Sessions mit notebooklm ask wiederfindet. Nutzen bei /wrap-up oder wenn ich „wrap up“, „Session speichern“ oder „ab ins Gedächtnis“ sage.
allowed-tools:
  - Bash(notebooklm list *)
  - Bash(notebooklm create *)
  - Bash(notebooklm source add *)
  - Bash(notebooklm source wait *)
---

# Wrap-up: Session ins Master Brain

Speichere das komplette Gespräch dieser Session in NotebookLM. Arbeite die vier Schritte der Reihe nach ab, ohne Rückfrage.

## 1. Gespräch exportieren

Führ diesen Befehl genau so aus. Er schreibt jede Nachricht von mir und jede deiner Antworten aus dieser Session in eine Markdown-Datei (ohne Tool-Ausgaben, die können Passwörter enthalten) und gibt Pfad und Wortzahl aus. Fehlt uv, ersetz `uv run --no-project python` durch `python3`.

```bash
uv run --no-project python - "${CLAUDE_SESSION_ID}" <<'PY'
import glob, json, os, re, sys, tempfile
sid = sys.argv[1]
base = os.environ.get("CLAUDE_CONFIG_DIR") or os.path.expanduser("~/.claude")
files = glob.glob(os.path.join(base, "projects", "*", sid + ".jsonl"))
if not files:
    sys.exit("Kein Transkript zu dieser Session gefunden.")
skip = re.compile(r"^<(command-|local-command|bash-|task-notification)")
def text(content):
    if isinstance(content, str):
        return content
    return "\n\n".join(b.get("text", "") for b in content if isinstance(b, dict) and b.get("type") == "text")
parts, cwd, day = [], "", ""
with open(max(files, key=os.path.getmtime), encoding="utf-8") as f:
    for raw in f:
        try:
            e = json.loads(raw)
        except ValueError:
            continue
        role = e.get("type")
        if role not in ("user", "assistant") or any(e.get(k) for k in ("isMeta", "isSidechain", "isCompactSummary", "isApiErrorMessage")):
            continue
        t = text((e.get("message") or {}).get("content") or "")
        t = re.sub(r"<system-reminder>.*?</system-reminder>", "", t, flags=re.S).strip()
        if not t or skip.match(t):
            continue
        cwd = cwd or e.get("cwd", "")
        day = day or str(e.get("timestamp", ""))[:10]
        parts.append(("**Ich:** " if role == "user" else "**Claude:** ") + t)
out = os.path.join(os.path.realpath(tempfile.gettempdir()), "session-" + sid[:8] + ".md")
with open(out, "w", encoding="utf-8") as f:
    f.write("# Claude-Session " + day + "\n\nProjekt: " + cwd + "\n\n" + "\n\n".join(parts) + "\n")
print(out, sum(len(p.split()) for p in parts), "Wörter")
PY
```

## 2. Notizbuch finden

`notebooklm list --json` ausführen und das Notizbuch mit dem Titel „Master Brain“ nehmen. Gibt es mehrere („Master Brain 2“, „Master Brain 3“ …), nimm das mit der höchsten Nummer. Gibt es keins: `notebooklm create "Master Brain" --json` und `notebook.id` verwenden.

## 3. Speichern

Gib der Session einen Titel nach dem Muster `Session JJJJ-MM-TT · Thema in 3 bis 6 Wörtern` und lade die Datei hoch:

```bash
notebooklm source add "<Pfad aus Schritt 1>" --type file --title "<Titel>" -n <Notizbuch-ID> --json
notebooklm source wait <source.id> -n <Notizbuch-ID> --timeout 300
```

- Meldet NotebookLM, dass das Notizbuch voll ist (Quellen-Limit), leg das nächste an (`notebooklm create "Master Brain 2" --json`, danach 3, 4 …) und speicher dort.
- Ist der Login abgelaufen, sag mir, dass ich im Terminal `notebooklm login` ausführen soll, und hör auf.

## 4. Melden

Antworte in einem Satz: Titel, Wortzahl und in welchem Notizbuch die Session jetzt liegt.
