Syncing Sessions
The sync command reads Claude Code JSONL files from ~/.claude/projects/ and uploads them to your Firestore.
How It Works
Section titled “How It Works”Each JSONL file represents a Claude Code session. The CLI:
- Scans
~/.claude/projects/for JSONL files - Parses each file to extract messages, metadata, and tool calls
- Generates a title for each session (based on content)
- Classifies the session character (deep focus, bug hunt, feature build, etc.)
- Uploads projects, sessions, and messages to Firestore
Incremental Sync
Section titled “Incremental Sync”Sync state is tracked in ~/.code-insights/sync-state.json. On each run:
- File modification times are compared against the last sync
- Only new or modified files are processed
- Syncs are idempotent — running
synctwice won’t create duplicates
This means subsequent syncs are fast. Only the first sync processes your entire history.
Filtering by Project
Section titled “Filtering by Project”Sync only a specific project:
code-insights sync --project "my-project"The project name matches the directory name under ~/.claude/projects/.
Force Re-Sync
Section titled “Force Re-Sync”To re-process and re-upload everything (ignoring the sync state cache):
code-insights sync --forceThis is useful if you suspect data is out of sync, or after a schema update.
Dry Run
Section titled “Dry Run”Preview what would be synced without actually uploading:
code-insights sync --dry-runQuiet Mode
Section titled “Quiet Mode”Suppress all output. Useful when running from hooks:
code-insights sync -qRegenerate Titles
Section titled “Regenerate Titles”Force the CLI to regenerate titles for all sessions:
code-insights sync --regenerate-titlesAuto-Sync with Hooks
Section titled “Auto-Sync with Hooks”Instead of manually running sync, you can install a Claude Code hook that syncs automatically when each session ends:
code-insights install-hookThis adds a hook that runs code-insights sync -q after every session. To remove it:
code-insights uninstall-hookMulti-Device Sync
Section titled “Multi-Device Sync”You can sync from multiple machines to the same Firebase:
- Git-based projects get stable IDs derived from the git remote URL. Same repo on different machines = same project ID in Firestore.
- Non-git projects fall back to a path-based hash (these will differ across machines).
- Each session records device metadata (hostname, platform) so you can tell where it came from.
Troubleshooting
Section titled “Troubleshooting”Sync is slow on first run
Section titled “Sync is slow on first run”The first sync processes your entire history. Depending on how many sessions you have, this can take a minute or two. Subsequent syncs are incremental and much faster.
”Permission denied” errors
Section titled “”Permission denied” errors”Your Firebase service account credentials may be invalid or expired. Re-run code-insights init to re-enter them.
Dashboard shows no data after sync
Section titled “Dashboard shows no data after sync”- Verify that the
projectIdin your web config matches theproject_idin your service account JSON — they must point to the same Firebase project. - Run
code-insights statusto confirm sessions were uploaded. - Check that your Firestore security rules allow reads.