/pam-memory:sync-claude-memory [--since YYYY-MM-DD] [--project <name>]from pam-memory
Reads the user's local Claude Code and Claude Desktop Cowork session transcripts, mechanically parses and redacts each into raw turns, and sends them to PAM for server-side extraction. Always discloses which local files it will read and asks for explicit confirmation before reading any transcript content. Triggers on "/sync-claude-memory", "sync my claude memory into pam", "import my claude chat history".
Ships in pam-memory. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Turn the user's local Claude session history — both the Claude Code CLI and
Claude Desktop's Cowork mode — into PAM memory. Cowork runs the same
local CLI engine under the hood, so its transcripts land in the identical
~/.claude/projects/**/*.jsonl format; there's no separate Cowork parser.
Plain Claude Desktop Chat (non-Cowork) has no local transcript at all and
is out of scope — there's nothing on disk to read.
This is a two-phase flow: disclose scope and get explicit confirmation first, then read transcript content only for what was confirmed. Never read transcript message content before the user has confirmed.
No LLM judgment happens client-side. Step 3 below runs a purely
mechanical script (sync_batch.py, which drives the same parsing logic as
extract_raw_transcript.py) — no Agent subagents, no model calls of any
kind — to parse each transcript into raw {role, text, timestamp} turns and
apply regex-based secret redaction, then pushes those turns to PAM via
ingest_memory_from_chat.py. Deciding what's durable, summarizing, and
extracting facts all happen server-side in PAM's pam-jobs pipeline (the same
Gemini extract+validate pass every other memory source goes through) — this
command never spends the user's own model quota on PAM's ingest work.
If that push fails for any reason (no key configured, network error, PAM
rejects it) ingest_memory_from_chat.py automatically falls back to queuing
the item locally at ~/.pam/sync_queue/claude_code.jsonl instead of losing
it — its JSON output says which happened ("status": "queued" = sent to
PAM, "status": "queued_locally" = fallback). Report whichever actually
happened; don't assume success.
Run, forwarding $ARGUMENTS as flags if present:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/list_claude_sessions.py" $ARGUMENTS
This step, and every script in this skill, only needs a plain python3 —
no pip install or venv bootstrap. Sending data to PAM (step 3) shells out to
curl rather than a Python HTTP library, so there's no third-party
dependency to install on the user's machine.
This only reads session metadata (session id, project cwd, timestamps, message
count, and a short snippet of the first user message used as a title) — it
does not extract full transcript content. It also checks Claude Desktop's own
Cowork session index (~/Library/Application Support/Claude/claude-code-sessions/**/local_*.json
on macOS — title and session-id linkage only, never transcript content) to
tag which sessions came from Cowork and to prefer Desktop's own session title
over the derived snippet. Parse the JSON result: count, clients (a
{"claude_code": N, "cowork": M} breakdown), projects, date_range,
sessions (each tagged "client": "claude_code" | "cowork", with a "file"
absolute path).
Before doing anything else, tell the user plainly, in your own words:
~/.claude/projects/**/*.jsonl — full session
transcripts from both Claude Code and Claude Desktop's Cowork mode, which
can include pasted file contents, tool output, and anything typed in those
sessions. It also peeks at Desktop's lightweight Cowork session index for
titles (no transcript content there).~/.pam/sync_queue/claude_code.jsonl) rather than lost —
you'll get an accurate count of which happened at the end, not just an
assumption of success.Then use AskUserQuestion to get explicit confirmation with at least these
options: proceed with everything found, narrow the scope (ask what to narrow
by — date or project — and re-run step 1), or cancel. If the user cancels,
stop here. Do not read any transcript file content beyond what step 1 already
read.
Only after confirmation. Write the confirmed sessions to a scratch JSON file
as an array of {"file": ..., "client": ...} objects, taken directly from
step 1's sessions list (e.g. to a path under the session's scratchpad
directory), then run the whole batch as one process, invoked exactly
once:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/sync_batch.py" --sessions-file <scratch-file>.json
sync_batch.py imports the same parsing/redaction/ingest logic as
extract_raw_transcript.py and loops over every session in-process — no
subagents, no model calls, and no repeated python3 startup per session. It
prints one flushed JSON line per session as it finishes, then a final
{"status": "summary", "total": N, "queued": ..., "queued_locally": ..., "skipped": ..., "errors": ...} line.
Do not reimplement this as a multi-line shell loop (e.g.
while read ... done <<EOF calling a script once per session) run via a
backgrounded Bash call. That exact pattern was observed to hang indefinitely
before ever starting the first session — no output, no error, ps showing
no child process — most likely because of how the harness wires stdin for
backgrounded multi-line shell compound statements, not a bug in the parsing
logic itself (the identical per-session work completes in ~1s when invoked
directly). sync_batch.py exists so the call site is always a single simple
command, which does not hit this.
Do not use the Monitor tool for this. It was tried for live per-session
progress on a 118-session batch and the harness auto-killed the monitor (and
the sync_batch.py process it started) partway through for emitting "too
much output" — one notification per session line is too high a rate. The
run had to be resumed as a second, separate sync_batch.py invocation for
the remaining sessions, meaning the batch reached PAM as two independent
pushes instead of one. Each session only gets ingested correctly once, but
two separate runs is still worth avoiding — it's needless surface for
conflicting or duplicated in-flight ingest/pam-jobs work, and it makes the
final tally harder to reason about (two summary lines instead of one).
Instead, run it as a single foreground Bash call, sized so the batch finishes inside one invocation:
timeout generously
(e.g. session_count * 2 seconds, capped at the tool's 600000ms/10min
max) rather than the default 2-minute timeout.{"status": "summary", ...} line) and
report the final tally per step 4. It's fine to tell the user up front
that this may take a minute or two for large scopes, so they're not
surprised by the silence.run_in_background: true instead and wait for the single
completion notification (not per-line) before reading the output — do not
poll or re-invoke the script while it's still running.Each per-session line is one JSON object:
{"index": i, "total": N, "status": "skipped", "reason": "no non-empty turns", "session_id": ...}
— mechanical skip, not a durability judgment (e.g. a session with only
tool calls and no prose).{"index": i, "total": N, "status": "done", "session_id": ..., "part_count": N, "results": [...]}
— one ingest_memory_from_chat.py result per part; each part's own
"status" is "queued" (reached PAM) or "queued_locally" (fallback,
check "reason").{"index": i, "total": N, "status": "error", "file": ..., "error": ...}
— that one session failed to parse or ingest; the batch continues with
the rest.Large sessions are split into multiple parts automatically (same
session_id, ordered part_index) — PAM merges parts by session_id
server-side before extraction, so this is transparent; just tally every
part's status.
Use the {"status": "summary", ...} line sync_batch.py prints at the end
— don't re-read transcripts or re-derive counts by hand, the script's own
tally already has everything: total sessions, how many were sent to PAM
("queued"), how many fell back to the local queue ("queued_locally"),
how many were mechanically skipped (no text content), and how many hit an
unexpected error ("errors").
If any items fell back locally, also run this so you can tell the user exactly where they landed:
python3 -c "import json,pathlib; p=pathlib.Path.home()/'.pam'/'sync_queue'/'claude_code.jsonl'; print(sum(1 for _ in p.open()) if p.is_file() else 0)"
Tell the user the final tally plainly: how many sessions were found, how many actually reached PAM, how many are staged locally (and why, and that they'll need a re-run once the underlying issue — e.g. missing API key — is fixed), and how many were skipped as having no text content. Don't report success for anything that only made it to the local fallback queue. Since extraction now happens server-side, don't claim any particular fact or summary was produced — that's PAM's pipeline's job, running asynchronously after this command finishes.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub harmix/pam-memory --plugin pam-memory