Cross-machine /insights: support reading from multiple usage-data sources

Resolved 💬 3 comments Opened Apr 7, 2026 by coreyfloyd Closed Apr 10, 2026

Use case: I run Claude Code across two machines (laptop + dedicated dev box for autonomous agents). ~/.claude/usage-data/{session-meta,facets} is per-machine, so /insights only reflects local activity. For me, that's roughly 30% of my Claude Code work — the unified picture is hidden.

What I'd like: Either (a) a --data-dir flag accepting multiple paths that /insights aggregates over, with safe handling of project-path differences across machines, or (b) a documented sync format / schema so users can build their own aggregation reliably.

What I tried: Rsyncing one machine's session-meta/facets into the other and rewriting project_path via substitution. It works but is fragile — the schema isn't documented, and I had to add safe-default stubs for missing fields and repair corrupted files (concurrent-writer race in session-meta) just to get /insights to run on existing local data.

Bug-adjacent finding: During this experiment I found that session-meta files can get corrupted by concurrent writers. On my system, 4 files had extra JSON appended after the closing brace (one valid object followed by partial fragments of another). This caused /insights to crash with TypeError: Object.entries requires that input parameter not be null or undefined and later TypeError: Spread syntax requires ...iterable not be null or undefined. Worth investigating whether the writer takes a file lock or uses atomic tmpfile + rename.

Additional fragility I hit while debugging the above: 219 of my 415 session-meta files were missing rich fields entirely (languages, tool_error_categories, message_hours, user_response_times, etc.) — likely older-format files from before those fields were added. /insights appears to call Object.entries() and spread (...) on these without null checks, crashing on the first one. I worked around it by stubbing safe defaults, but the underlying issue is that /insights assumes all session-meta files have the current schema.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗