Code Insights CLI
Command-line tool that parses Claude Code session history and syncs it to your own Firebase Firestore.
Full documentation: docs.code-insights.app
Prerequisites
- Node.js 18 or later
- A Firebase project with Firestore enabled (see Quick Start)
Installation
npm install -g @code-insights/cli
Verify it works:
code-insights --version
Commands
code-insights init
Configure Code Insights with your Firebase credentials.
code-insights init \
--from-json ~/Downloads/serviceAccountKey.json \
--web-config ~/Downloads/firebase-web-config.js
code-insights init
Flags:
--from-json <path> — Path to the Firebase service account key (downloaded from Firebase Console > Project Settings > Service Accounts)
--web-config <path> — Path to the Firebase web SDK config (saved from Firebase Console > Project Settings > General > Your Apps). Accepts both JSON and the JavaScript snippet from Firebase.
You can use one flag, both, or neither. Any values not provided via flags will be collected interactively.
Configuration is stored in ~/.code-insights/config.json. Web config is stored separately in ~/.code-insights/web-config.json.
code-insights connect
Generate a URL to connect the web dashboard to your Firebase.
code-insights connect
The URL includes your Firebase web config base64-encoded as a query parameter. Open it in a browser to connect the dashboard to your Firestore — no manual configuration needed.
code-insights sync
Sync Claude Code sessions to Firestore.
code-insights sync
code-insights sync --force
code-insights sync --dry-run
code-insights sync --project "my-project"
code-insights sync --quiet
code-insights sync --regenerate-titles
code-insights status
Show sync status and statistics.
code-insights status
Displays:
- Configuration status
- Total sessions synced
- Projects tracked
- Last sync time
code-insights reset
Delete all data from Firestore and reset local sync state.
code-insights reset
code-insights reset --confirm
code-insights install-hook
Install a Claude Code hook for automatic sync after each session.
code-insights install-hook
code-insights uninstall-hook
Remove the automatic sync hook.
code-insights uninstall-hook
How It Works
Session Parsing
The CLI reads JSONL files from ~/.claude/projects/ which contain:
- User and assistant messages
- Tool calls (Edit, Write, Bash, etc.)
- Timestamps and metadata
Each session is parsed to extract:
- Project name and path
- Start/end times and duration
- Message counts
- Tool call statistics
- Git branch (if available)
- Claude version
- Token usage, estimated costs, and model information (when available)
Incremental Sync
Sync state is tracked in ~/.code-insights/sync-state.json:
- File modification times are recorded
- Only new or modified files are processed
- Use
--force to bypass and re-sync everything
Multi-Device Support
Project IDs are generated from git remote URLs when available:
- Same repo on different machines → same project ID
- Non-git projects fall back to path-based hash
- Each session records device metadata (hostname, platform)
Title Generation
Sessions are automatically titled based on:
- Claude's own title (if present in session)
- First user message (cleaned up)
- Session character detection (deep focus, bug hunt, etc.)
- Fallback to timestamp
Contributing
See CONTRIBUTING.md for development setup, code style, and PR guidelines.
License
MIT License — see LICENSE for details.