Skip to content
Code Insights
Documentation

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 help

init

code-insights init

Interactive 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.

FlagDescription
--forceRe-sync all sessions (ignores modification times)
--dry-runPreview what would be synced without writing
-q, --quietSuppress all output
--source <tool>Sync only from: claude-code, cursor, codex-cli, copilot-cli, copilot

sync prune

code-insights sync prune

Soft-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.

FlagDescription
--projectOpen filtered to the current project

dashboard

code-insights dashboard [options]

Starts the embedded Hono server and opens localhost:7890 in your browser.

FlagDefaultDescription
-p, --port <number>7890Port number for the dashboard server
--no-openDo not open browser automatically

status

code-insights status

Shows 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.

SubcommandDescription
(none)Overview dashboard
costCost breakdown by project and model
projectsPer-project detail cards
todayToday's sessions
modelsModel usage distribution
patternsCross-session patterns summary

Shared flags:

FlagDefaultDescription
--period 7d|30d|90d|all7dTime range
--project <name>Scope to a specific project
--source <tool>Filter by source tool
--no-syncSkip 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.

FlagDescription
--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.

FlagDescription
-p, --period <period>Time range: 7d, 30d, 90d, all (default: all)
--project <name>Scope to a single project
--dry-runShow count without backfilling
--prompt-qualityRun prompt quality analysis instead of facet extraction

config

code-insights config

Shows 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:

KeyValuesDescription
telemetrytrue / falseEnable 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.

FlagDescription
--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)
--showShow current LLM configuration

install-hook

code-insights install-hook

Adds a Stop hook to ~/.claude/settings.json that runs code-insights sync -q after every Claude Code session.

uninstall-hook

code-insights uninstall-hook

Removes the auto-sync hook from ~/.claude/settings.json.

reset

code-insights reset --confirm

Deletes 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.

SubcommandDescription
statusShow current telemetry status and what data is collected
opt-outDisable anonymous telemetry
opt-inRe-enable anonymous telemetry

Telemetry can also be disabled via environment variables: CODE_INSIGHTS_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1.