Skip to content

Memory And Sync

Two-Path Memory Sync: User-Home vs Repo

From legacy section: Memory System

Pattern: Memory files exist at TWO paths that must be kept in sync: /Users/jim/.claude/projects/-Users-jim-Downloads-Evolve-Agency/memory/ (user-home, what Claude reads at runtime) and /Users/jim/Code/Evolve-Agency/.claude/projects/-Users-jim-Downloads-Evolve-Agency/memory/ (repo-tracked, what gets committed to GitHub). Discovered that prior session commits added files to the repo path but they were missing from user-home — Claude couldn't read them at runtime. Also, files written to user-home during a session are NOT automatically backed up to the repo. Rule: At session cleanup, always sync both directions: (1) cp [user-home-path]/*.md [repo-path]/ so new memory files get committed, (2) if git ls-files shows memory files not present at user-home, cp [repo-path]/*.md [user-home-path]/ to restore them. This should happen BEFORE the final git add -A && git commit in cleanup. Don't trust that "nothing to commit" means memory is safe — always compare both paths. Date: 2026-04-16



Drive auto-sync: workspace-mcp OAuth callback fails when port 8000 has a stale MCP holding it

From legacy section: SEO NEO / Workbook

Pattern: Triggered any Drive MCP call after the OAuth token expired and got Cannot initiate OAuth flow - callback server unavailable (Port 8000 is already in use on localhost). lsof -nP -iTCP:8000 showed PID 1122 was a stale workspace-mcp --tools drive sheets process from a previous Claude Code restart — and there were 9 total workspace-mcp processes running (3 Python instances + 3 uvx wrappers + 3 Apple disclaimer wrappers). The active stdio MCP that Claude Code uses for tool calls runs separately and tries to spawn a NEW callback listener on port 8000 for the OAuth flow — which fails because the stale process is squatting. Re-running start_google_auth doesn't help; same error. Rule: When the workspace-mcp returns Port 8000 is already in use on any Drive/Sheets call, the fix is to identify and kill the stale workspace-mcp instance holding port 8000: (1) lsof -nP -iTCP:8000 -sTCP:LISTEN to find the squatter, (2) ps aux | grep workspace-mcp | grep -v grep to see all instances, (3) kill <stale-PID> (the Python workspace-mcp on port 8000 — usually the oldest PID), then (4) re-run any Drive call to trigger a fresh OAuth flow with a clickable authorization URL. This does NOT require restarting Claude Code or affecting the active stdio MCP — only the stale port-holder needs to die. After auth completes, ~/.google_workspace_mcp/credentials/<email>.json gets a refreshed token. Don't try gcloud auth or other generic Google auth fixes — the workspace-mcp uses its own embedded OAuth client and credential storage path. Reference: scripts/drive-sync.py reuses these same credentials directly (no MCP needed) once authorized. Date: 2026-05-05


Drive auto-sync: /session-cleanup mirrors touched clients/_active// to Drive after git push

From legacy section: SEO NEO / Workbook

Pattern: Jim asked "how do the folders end up on Evolve Drive — does it happen automatically?" Investigation found NO auto-sync mechanism existed (no hook in .claude/settings.json, neither /session-start nor /session-cleanup had Drive logic). Files only landed in Drive via manual upload or one-off MCP calls — yet Drive already had a clean mirror of clients/_active/ for 35+ clients (black-square-roofing/, tali-kogan/, etc.). Built scripts/drive-sync.py (idempotent, md5-dedup, retry-on-network-error, reuses workspace-mcp OAuth token at ~/.google_workspace_mcp/credentials/<email>.json) and bolted it into /session-cleanup Step 5g via python3 scripts/drive-sync.py --since-last-push. Test runs synced black-square-roofing (23 created, 1 updated, 48 skipped-same) and tali-kogan (4 created, 64 skipped-same) successfully. Rule: Drive is the collaborator-facing view of clients/_active/; GitHub is the engineering source of truth. The mirror is automatic via /session-cleanup Step 5g — no manual upload needed. When writing future skills that produce NEO/SEO deliverables, the workflow stays the same: write files to clients/_active/<slug>/, commit, push, run /session-cleanup, and Drive sync follows. Skip rules in the helper: .git, node_modules, __pycache__, .DS_Store, .claude/worktrees/, and .gdoc/.gsheet/.gslides shortcut files (these came from Drive originally — re-uploading creates duplicate Google Docs). The script supports --dry-run for previewing changes and --touched-since <ref> for arbitrary git ranges. If a sync fails (network, auth, partial), don't block the cleanup verdict — git/main is the source of truth, retry the sync afterward with python3 scripts/drive-sync.py <slug> (idempotent). To re-authorize after token expiry: kill the stale workspace-mcp on port 8000 (see prior lesson), then trigger any Drive MCP call to get a fresh authorization URL. Update 2026-05-07: Canonical IDs are no longer hardcoded in the script — they live in scripts/drive_config.json (current values: clients_parent_id=1LsikwJqehy_ULK7XtFX-Tr_8kD7AKfH4, _active=1mN_ocCGmmexgceAj9MiUdd7Q5K5cX-LI, _prospects=1VsArXmOIoyVwho83vVSYAWOL2WryiYip, _archive=1CG5DGi7VEBb2aYzrQaHwSJvYcJx4khqi). The script now refuses to run if duplicate folders are detected anywhere in the canonical tree (safety guard). Diagnostic modes: --check-canonical, --list-duplicates, --trash-duplicate <id>. Full doc: memory/drive-canonical-layout.md. The original IDs in this lesson (1f4ifqme…, 1oPJmQf…) are STALE — that whole Evolve-Agency parent was trashed via a Mac sync issue and later restored with new child IDs. Date: 2026-05-05 (updated 2026-05-07)