CLI Commands
Complete reference for all code-insights CLI commands and flags — init, sync, stats, dashboard, config, reset, install-hook, and more.
Global
code-insights --version # Print version
code-insights --help # Show helpinit
code-insights initInteractive setup. Detects installed AI coding tools and initializes the local database at ~/.code-insights/data.db.
sync
code-insights sync [options]Syncs sessions from all supported source tools to the local SQLite database.
| Flag | Description |
|---|---|
--force | Re-sync all sessions (ignores modification times) |
--dry-run | Preview what would be synced without writing |
-q, --quiet | Suppress all output |
--source <tool> | Sync only from: claude-code, cursor, codex-cli, copilot-cli, copilot |
sync prune
code-insights sync pruneSoft-deletes sessions with 2 or fewer messages (trivial abandoned sessions). Shows a preview list and asks for confirmation before making any changes. Deleted sessions are restorable with sync --force.
open
code-insights open [options]Opens the local dashboard in your default browser. If the dashboard server is already running, this opens a new browser tab to it.
| Flag | Description |
|---|---|
--project | Open filtered to the current project |
dashboard
code-insights dashboard [options]Starts the embedded Hono server and opens localhost:7890 in your browser.
| Flag | Default | Description |
|---|---|---|
-p, --port <number> | 7890 | Port number for the dashboard server |
--no-open | — | Do not open browser automatically |
status
code-insights statusShows sync statistics: total sessions, messages, last sync time, and source tool breakdown.
stats
code-insights stats [subcommand] [options]Terminal analytics. See Terminal Analytics for details.
| Subcommand | Description |
|---|---|
| (none) | Overview dashboard |
cost | Cost breakdown by project and model |
projects | Per-project detail cards |
today | Today's sessions |
models | Model usage distribution |
patterns | Cross-session patterns summary |
Shared flags:
| Flag | Default | Description |
|---|---|---|
--period 7d|30d|90d|all | 7d | Time range |
--project <name> | — | Scope to a specific project |
--source <tool> | — | Filter by source tool |
--no-sync | — | Skip auto-sync before showing stats |
reflect
code-insights reflect [options]Generates cross-session LLM synthesis for the specified ISO week: friction patterns, effective workflows, and CLAUDE.md rule suggestions. Requires the dashboard server to be running (code-insights dashboard) and an LLM provider configured.
| Flag | Description |
|---|---|
--week <YYYY-WNN> | ISO week to reflect on (e.g., 2026-W10), defaults to the current week |
--section <name> | Generate a specific section only: friction-wins, rules-skills, working-style |
--project <name> | Scope to a single project |
reflect backfill
code-insights reflect backfill [options]Extracts friction and effective-pattern facets for sessions that have insights but are missing pattern data (or have outdated analysis). Shows a count preview and asks for confirmation before making LLM calls. Note: backfill uses --period (a rolling age range to target sessions by recency) rather than --week, because it operates on session analysis age rather than synthesis scope.
| Flag | Description |
|---|---|
-p, --period <period> | Time range: 7d, 30d, 90d, all (default: all) |
--project <name> | Scope to a single project |
--dry-run | Show count without backfilling |
--prompt-quality | Run prompt quality analysis instead of facet extraction |
config
code-insights configShows the current configuration summary (sync paths, dashboard port, LLM provider, telemetry status).
config set
code-insights config set <key> <value>Set a configuration value. Currently supported keys:
| Key | Values | Description |
|---|---|---|
telemetry | true / false | Enable or disable anonymous telemetry |
config llm
code-insights config llm [options]Configure the LLM provider for AI-powered session analysis. Without flags, runs an interactive wizard.
| Flag | Description |
|---|---|
--provider <provider> | LLM provider (openai, anthropic, gemini, ollama, llamacpp) |
--model <model> | Model ID (e.g., gpt-4o, claude-sonnet-4-20250514, gemma-4-12b) |
--api-key <key> | API key for the selected provider (not needed for ollama or llamacpp) |
--base-url <url> | Custom base URL (Ollama default: localhost:11434, llama.cpp default: localhost:8080) |
--show | Show current LLM configuration |
install-hook
code-insights install-hookAdds a Stop hook to ~/.claude/settings.json that runs code-insights sync -q after every Claude Code session.
uninstall-hook
code-insights uninstall-hookRemoves the auto-sync hook from ~/.claude/settings.json.
reset
code-insights reset --confirmDeletes all local data: ~/.code-insights/data.db, sync-state.json, and device-id. Requires the --confirm flag to prevent accidental deletion.
telemetry
code-insights telemetry [subcommand]View and manage anonymous telemetry settings.
| Subcommand | Description |
|---|---|
status | Show current telemetry status and what data is collected |
opt-out | Disable anonymous telemetry |
opt-in | Re-enable anonymous telemetry |
Telemetry can also be disabled via environment variables: CODE_INSIGHTS_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1.