Litescope
Features Open source Docs GitHub ↗

Litescope Docs

SQLite production operations — from doctor, diff, and schema to migrate, monitor, and fleet management, all from one binary.

Installation

macOS (Homebrew)

brew install croc100/tap/litescope

Linux

Download the latest binary from Releases, extract, and move to your PATH:

curl -fsSL https://github.com/croc100/Litescope/releases/latest/download/litescope_Linux_x86_64.tar.gz | tar xz
sudo mv litescope /usr/local/bin/

Windows

Download litescope_*_windows_amd64.zip from Releases, extract the .exe, and add its directory to PATH.

Verify

litescope --version

Licensing — free & open source

Litescope is free and open source under the GNU AGPL-3.0. The entire CLI and GUI — every command, fleet operation, migration, and automation — is unlocked for everyone. There is no license key and nothing to activate.

litescope license   # confirms the free/open-source status
Need a commercial license? A separate commercial license (which waives the AGPL obligations and adds support) and enterprise self-host are available for organizations that need them — [email protected]. A hosted dashboard is planned; see the roadmap.

doctor free

Run every single-database check at once and get a single verdict. doctor combines health (corruption, WAL bloat, fragmentation), advise (missing FK indexes, redundant indexes, full table scans), and lint (schema design anti-patterns). The "point it at a database and go oh" command — and it exits 1 when the database needs attention, so it drops straight into CI as a quality gate.

litescope doctor <database.db> [flags]
FlagDefaultDescription
--deepfalseUse the exhaustive integrity_check instead of quick_check
--formatterminalOutput format: terminal, json, html
--out, -ostdoutWrite the report to a file (use with --format html)

Examples

# One-shot checkup
litescope doctor app.db

# Deep integrity check
litescope doctor app.db --deep

# Shareable, self-contained HTML report
litescope doctor app.db --format html -o report.html

diff free

Compare schema and data between two SQLite databases.

litescope diff <old.db> <new.db> [flags]
FlagDefaultDescription
--formattextOutput format: text, json, markdown, html
--datafalseInclude row-level data diff in addition to schema
--output, -ostdoutWrite output to file

Examples

# Human-readable schema diff
litescope diff prod-before.db prod-after.db

# JSON output for CI
litescope diff old.db new.db --format json

# Include data diff
litescope diff old.db new.db --data

# Save HTML report
litescope diff old.db new.db --format html -o report.html

schema free

Dump the schema of a single database — local, Turso, or D1. Beyond the human-readable and JSON views, --erd emits a Mermaid entity-relationship diagram you can paste straight into a GitHub README, where it renders automatically.

litescope schema <source> [flags]
FlagDefaultDescription
--format, -fterminalOutput format: terminal, json, mermaid
--erdfalseShorthand for -f mermaid — output a Mermaid ER diagram

Examples

# Inspect a local database
litescope schema app.db

# Inspect a remote Turso database
litescope schema turso://TOKEN@ORG/DBNAME

# Mermaid ERD for a README
litescope schema app.db --erd

dump free

Write a database out as a standalone .sql file — schema plus data — that recreates it when replayed into sqlite3 or litescope migrate. Equivalent to the sqlite3 shell's .dump, with the same ordering and quoting; blob/NULL/quote-safe and round-trip verified. Works on local files (remote sources expose schema only).

litescope dump <database.db> [flags]
FlagDefaultDescription
--out, -ostdoutWrite to a file instead of stdout
--schema-onlyfalseDump DDL only (no INSERTs)
--data-onlyfalseDump data only (no CREATE statements)
--tableDump only this table and its data

Examples

# Full dump to a file
litescope dump app.db -o backup.sql

# Schema only (DDL)
litescope dump app.db --schema-only

# A single table and its rows
litescope dump app.db --table users

health free

Inspect a database for the operational faults that take down production SQLite: corruption, WAL bloat from a starved checkpoint, freelist fragmentation, and reachability. Exits 1 on any warning or critical finding.

litescope health <database.db> [flags]
FlagDefaultDescription
--deepfalseUse the exhaustive integrity_check instead of the faster quick_check
--formatterminalOutput format: terminal, json

Examples

# Quick triage
litescope health app.db

# Exhaustive integrity check
litescope health app.db --deep
At fleet scale, use fleet health to triage every database in parallel, then fleet recover to restore the broken ones.

locks free

Diagnose database is locked / SQLITE_BUSY — the single most common SQLite production failure. The static check inspects journal mode, busy_timeout, locking mode, and WAL bloat, and prescribes the exact PRAGMA or DSN change. The live probe (--live) tells you whether a writer is holding the lock right now and which process owns the file. Exits 1 when the database needs attention or is currently locked.

litescope locks <source> [flags]
FlagDefaultDescription
--livefalseProbe the current lock state instead of static config (local files)
--watchfalseStream live lock-state changes until interrupted
--interval1sPoll interval for --watch
--formatterminalOutput format: terminal, json

Examples

# Static configuration diagnosis (local, D1, or Turso)
litescope locks app.db

# Is a writer holding the lock right now?
litescope locks app.db --live

snapshot / restore free

Point-in-time backups for local (and Turso) SQLite — the same "did you back up?" safety net that D1 gets from Time Travel. snapshot writes a consistent VACUUM INTO copy (safe even under WAL) into a sibling .litescope-snapshots/ directory; restore integrity-checks the snapshot and takes a pre-restore safety snapshot before overwriting.

litescope snapshot <db> [flags]
litescope snapshot list <db>
litescope restore <db> [flags]
FlagDefaultDescription
--labelOptional label recorded in the snapshot name
--keep0Retention: keep only the N newest snapshots (0 = keep all)
--fromnewest(restore) Snapshot file to restore from
--no-safety-snapshotfalse(restore) Skip the pre-restore safety snapshot

Examples

litescope snapshot app.db --label before-migration
litescope snapshot app.db --keep 7
litescope snapshot list app.db
litescope restore app.db            # newest snapshot

autopilot free

The self-driving DBA. Derives safe maintenance and optimization actions — ANALYZE, PRAGMA optimize, missing foreign-key indexes, and (with --aggressive) VACUUM and redundant-index cleanup — and explains each in plain language. Dry-run by default; every real change is preceded by an automatic snapshot, so a run is one restore away from undo.

litescope autopilot <db> [flags]
FlagDefaultDescription
--applyfalseApply the safe actions (default: dry-run)
--aggressivefalseAlso apply risky actions (VACUUM, drop redundant indexes)
--queriesFile of SQL queries for EXPLAIN-based advice
--fleetRun across every database in a fleet config
--formatterminalOutput format: terminal, json

Examples

# Show the plan, change nothing
litescope autopilot app.db

# Apply the safe actions (snapshot taken first)
litescope autopilot app.db --apply

# Whole fleet
litescope autopilot --fleet litescope.fleet.yaml --apply

advise free

Recommend indexes and flag performance problems — the ones AI-generated schemas ship by default. Schema rules need no query input: point at a database and get instant advice. Exits 1 when any warning is found.

litescope advise <database.db> [flags]
FlagDefaultDescription
--queryAnalyze a single SQL query for full table scans
--sqlAnalyze every query in a .sql file
--formatterminalOutput format: terminal, json

What it catches

  • fk-no-index — a foreign key with no index. SQLite, unlike MySQL, does not auto-index FK columns, so every join or cascade scans the whole table.
  • redundant-index — an index whose columns are already a leading prefix of another.
  • full-scan — a supplied query that does a full table scan (via EXPLAIN QUERY PLAN).

Examples

# Point-and-shoot schema analysis
litescope advise app.db

# Check a specific query
litescope advise app.db --query "SELECT * FROM orders WHERE user_id = ?"
Each finding includes a runnable fix, e.g. CREATE INDEX idx_orders_user_id ON orders(user_id);

lint free

Check a schema for the structural mistakes that ship by default — especially in hand-written or AI-generated schemas. lint looks only at the schema shape (never data or queries), so it is fast and safe in CI. By default it exits 1 on warnings; --strict also fails on info findings. For index/performance problems use advise; for both plus health, doctor.

litescope lint <database.db> [flags]
RuleWhat it catches
no-primary-keyA table with no PRIMARY KEY (no stable row identity)
untyped-columnA column with no declared type (BLOB affinity)
not-strictA non-STRICT table (types are advisory, silently coerced)
autoincrement-overheadAUTOINCREMENT where plain INTEGER PRIMARY KEY would do
non-integer-pkA single-column PK that does not alias the rowid
FlagDefaultDescription
--formatterminalOutput format: terminal, json
--strictfalseExit 1 on info findings as well as warnings

Examples

# Lint a schema
litescope lint app.db

# Fail CI on info findings too
litescope lint app.db --strict

validate free

Lock a migration to a spec and enforce it in CI: validate compares the actual changes a migration made against an expected set, so an unplanned change fails the build. Generate the expectation file once from a known-good migration with validate init, then check every run with validate run.

CommandDescription
validate init <before.db> <after.db>Generate an expectation file from the actual diff (run once after a manual migration); writes migration.yaml by default (-o to override)
validate runCompare actual migration changes against the expected spec
Flag (run)DefaultDescription
--expect, -ePath to the expectation YAML/JSON file (required)
--format, -fterminalOutput format: terminal, json
--stricttrueFail on any unexpected change

Examples

# Capture the expected changes once
litescope validate init before.db after.db -o expected.yaml

# Enforce in CI
litescope validate run -e expected.yaml

check free

Verify a backup database. The PRAGMA integrity check and a comparison against a single reference (--against, with optional --data), batch verification of more than one file, and saving a report (--save-report) are all free.

litescope check <backup.db> [--against <reference.db>] [flags]
FlagDefaultDescription
--againstReference DB to compare schema against
--datafalseAlso compare row counts per table
--save-reportAppend the result to a JSONL history file
--formattextOutput format: text, json

Examples

# Integrity check only (free)
litescope check backup.db

# Schema match against production (free)
litescope check backup.db --against prod.db

# Include row count comparison (free)
litescope check backup.db --against prod.db --data

# Batch-verify many backups + save a report
litescope check backups/*.db --against prod.db --save-report report.jsonl

migrate free

Generate migration SQL by diffing two databases, then apply it safely with backup and rollback. Generation always prints a blast-radius analysis first.

generate

litescope migrate <old.db> <new.db> [flags]
FlagDefaultDescription
--output, -ostdoutWrite SQL to file
--forcefalseWrite the file even when the migration is destructive

Each operation is classified before the SQL — SQLite locks the entire file for a table rebuild, so the estimated write-lock matters:

  Blast radius analysis
  ─────────────────────────────────────────────────────────────
  ✓  CREATE TABLE audit_logs            new table — instant
  ⚠  TABLE REBUILD orders               50.0K rows, 3 index(es) → ~1s write-lock
  ✗  DROP TABLE sessions                12,400 rows permanently deleted
  ─────────────────────────────────────────────────────────────

apply

litescope migrate apply <db> <migration.sql> [flags]
FlagDefaultDescription
--dry-runfalseRun inside a transaction and roll back — validate without committing
--backup-dirsame dir as dbWhere to store the automatic pre-migration backup
--verifyAfter applying, verify the schema matches this reference DB

Examples

# Generate SQL with blast-radius report
litescope migrate old.db new.db -o migration.sql

# Preview before applying (transaction + rollback)
litescope migrate apply prod.db migration.sql --dry-run

# Apply (creates VACUUM INTO backup automatically)
litescope migrate apply prod.db migration.sql
Safety. apply runs a pre-flight integrity check, creates a point-in-time VACUUM INTO backup, executes inside a single transaction with FK verification, and restores the backup if anything fails.

Versioned migrations

Beyond ad-hoc diffs, Litescope manages an ordered, versioned migration history — the Atlas/Flyway workflow. Migration files live in a migrations/ directory (0001_name.sql, 0002_…) and applied versions are tracked in a litescope_schema_migrations table.

CommandTierDescription
migrate new <name>freeCreate the next numbered migration file (use --from/--to to pre-fill from a diff)
migrate status <db>freeShow applied vs pending migrations; flags history drift
migrate up <db>freeApply all pending migrations in order, each through the safe pipeline
# Generate a versioned migration from a schema change
litescope migrate new add_users --from prod.db --to desired.db

# See what's pending
litescope migrate status prod.db

# Apply pending migrations (records each in the tracking table)
litescope migrate up prod.db
History integrity. Each applied migration is recorded with a checksum. Editing a migration file after it has run is detected — status reports drift and up refuses to proceed, so your migration history can't silently diverge from what actually ran.

monitor

Baseline a known-good schema, then check for drift. The watch subcommand runs continuously and can alert on changes.

snapshot

litescope monitor snapshot <db> [flags]
FlagDefaultDescription
--output, -obaseline.jsonPath to write the baseline snapshot

check

litescope monitor check <db> [flags]
FlagDefaultDescription
--baseline, -bbaseline.jsonPath to the baseline snapshot
--formattextOutput format: text, json

watch free

Watch a single local database or remote targets (Turso/D1), with webhook alerts (--webhook) to Slack and Discord — all free.

litescope monitor watch <db> [flags]
FlagDefaultDescription
--baseline, -bbaseline.jsonPath to the baseline snapshot
--interval30sPoll interval (e.g. 10s, 1m, 5m)
--webhookSlack or Discord webhook URL for drift alerts

Examples

# Baseline
litescope monitor snapshot prod.db -o baseline.json

# One-off check
litescope monitor check prod.db -b baseline.json

# Continuous watch with Slack alert
litescope monitor watch prod.db -b baseline.json \
  --interval 1m \
  --webhook $SLACK_WEBHOOK_URL

fleet

Operate an entire Turso org or Cloudflare D1 account as one unit. discover writes a litescope.fleet.yaml config; every other subcommand reads it and runs in parallel. The lifecycle: diagnose (fingerprint, health), then treat (converge, recover).

Every fleet subcommand — read-only diagnosis (fingerprint / health) and every fix action — is free, on a fleet of any size.

discover

Query the provider API for every database and write the fleet config.

litescope fleet discover <turso|d1> [flags]
FlagDefaultDescription
--orgTurso org slug
--accountCloudflare account ID (D1)
--tokenPlatform API token (Turso platform token or CF API token)
--db-tokenTurso database/group auth token applied to each DSN

snapshot & check

Capture baselines, then detect schema drift across the whole fleet. check exits 1 if any database drifted — drop it into CI.

litescope fleet snapshot
litescope fleet check [--tag group:prod] [--format json]

fingerprint free

Cluster the fleet by schema. The largest cluster is canonical; every other shows exactly how it drifted. Exits 1 when more than one schema is found.

litescope fleet fingerprint

converge

Generate and apply the migration that brings every drifted database onto canonical — staged, halting on failure. Destructive convergence requires --force.

litescope fleet converge --dry-run        # plan + validate
litescope fleet converge --canary 5       # fix the first 5, then stop
litescope fleet converge --to canonical.db

health free

Parallel fault triage — corruption, WAL bloat, fragmentation, reachability — sorted worst-first. Exits 1 on any fault. Run it on a schedule to get paged on fleet faults, or continuously with --watch.

litescope fleet health [--deep] [--tag region:eu]
litescope fleet health --webhook $SLACK_URL          # one-shot alert (cron)
litescope fleet health --watch --interval 5m         # continuous monitoring
litescope fleet health --watch --webhook $URL --recover  # detect → alert → auto-restore
FlagDescription
--watchRun continuously on an interval
--intervalWatch interval (e.g. 30s, 5m, 1h)
--webhookPOST a fault alert to this URL (Slack-compatible)
--recoverAuto-restore critically faulted databases from backup

blast-radius

Map each critically faulted database to the cohorts it shares (Turso groups, regions — any tag). One corrupt database in a group often means the whole group's shared infrastructure is suspect — this shows who else to check.

litescope fleet blast-radius

recover

Restore critically faulted databases from their most recent verified backup; quarantine the unrecoverable so they're excluded from future fleet ops.

litescope fleet recover --dry-run
litescope fleet recover

migrate

Roll one migration out across the fleet, staged and fail-closed, halting at the first failure.

litescope fleet migrate add_index.sql --canary 5

Example workflow

# 1. Register every database in a Turso org
litescope fleet discover turso --org my-org \
  --token $TURSO_API_TOKEN --db-token $TURSO_GROUP_TOKEN

# 2. Diagnose: how many schemas, and what's broken?
litescope fleet fingerprint
litescope fleet health

# 3. Treat: converge drift, recover faults
litescope fleet converge --dry-run
litescope fleet recover
Config & baselines. The fleet config is a checked-in litescope.fleet.yaml; baselines default to .litescope/baselines/. Quarantined databases are recorded in the config and skipped by every command until cleared.

MCP server free

Let an AI agent drive Litescope. litescope mcp runs a Model Context Protocol server over stdio, so Claude Desktop, Claude Code, or any MCP client can call Litescope as a tool — "use litescope to check the health of ./app.db".

Setup (Claude Desktop)

Add Litescope to claude_desktop_config.json:

{
  "mcpServers": {
    "litescope": { "command": "litescope", "args": ["mcp"] }
  }
}

Restart Claude Desktop. Litescope's tools then appear to the model.

Exposed tools

All tools are read-only — an AI can diagnose your databases freely, but never mutates them.

ToolWhat it does
litescope_healthInspect a database for corruption, WAL bloat, fragmentation
litescope_schemaLoad tables, columns, and indexes
litescope_diffCompare two databases
litescope_adviseRecommend indexes; flag un-indexed FKs and full table scans
litescope_migrate_planMigration SQL + blast-radius (write-lock estimate) — no apply
litescope_checkBackup integrity; schema match vs a reference
litescope_fingerprintCluster a fleet by schema
litescope_fleet_healthParallel fault triage across a fleet
Diagnose freely, treat with a human. The MCP server intentionally exposes only read-only tools. Destructive operations (apply, converge, recover) stay behind the CLI/GUI with dry-run and approval, so an agent can recommend a fix but a person commits it.

Hosted dashboard subscription

Everything above is free and runs on your machine, including the local dashboard (litescope serve). The hosted dashboard is the one paid offering: your entire fleet — thousands of databases — on one always-on, multi-user screen, with time-series drift history and alerts. It receives metadata only (health, schema fingerprint, drift); your rows never leave your machines.

How onboarding works

  1. Subscribe on the pricing page (Hosted or Scale — pick your tier at checkout).
  2. Check your email. Provisioning is automatic: you'll get a welcome email with a one-time sign-in link and your push API key (lsk_…, shown once — store it safely).
  3. Sign in at the link to open your dashboard. You can request a fresh sign-in link anytime from the login page.
  4. Connect the CLI on the machine(s) that can reach your databases, and push:
    export LITESCOPE_CLOUD_URL=https://app.litescope.crode.net
    export LITESCOPE_CLOUD_KEY=lsk_your_key_here
    litescope push                 # one-shot; preview with --dry-run
  5. Schedule it. push sends a single snapshot — run it on a cron job or systemd timer (e.g. every 5 minutes) to keep the dashboard current.

litescope push

Collects each database's health report and schema fingerprint and POSTs the metadata to your hosted dashboard. Only metadata is transmitted — never customer rows.

litescope push [flags]
FlagDefaultDescription
--endpoint$LITESCOPE_CLOUD_URLHosted dashboard base URL
--key$LITESCOPE_CLOUD_KEYAPI key (lsk_…) from your welcome email
--configlitescope.fleet.yamlFleet config to push
--tagOnly push databases matching this tag
--dry-runfalsePrint the payload without sending
Larger or air-gapped? The same dashboard can be self-hosted on your own infrastructure. See COMMERCIAL.md.

Desktop GUI

The GUI app bundles all CLI operations in a visual interface. It ships as part of the same binary download — run litescope gui to launch, or double-click the .app on macOS.

Named connections

Add databases by clicking + Add in the sidebar. Named connections are unlimited.

Tools

  • Diff — visual schema and data diff between two databases
  • Explorer — browse tables and query rows
  • Check — validate a backup against a reference
  • Migrate — blast-radius analysis, generate and apply with dry-run
  • Monitor — snapshot, check drift, run continuous watch
  • Fleet — discover, fingerprint, converge, health, and recover Turso / D1 databases
  • Fleet Map — every database as a cell in a living map, colored by health or schema cluster

Changelog

v0.3.0 2026-06-19

  • migrate: blast-radius analysis — every operation classified Safe/Risky/Destructive with an estimated table-rebuild write-lock
  • fleet fingerprint: cluster the fleet by schema and see drift from canonical
  • fleet converge: auto-generate and stage the migration that fixes drift
  • fleet health + health: parallel fault triage — corruption, WAL bloat, fragmentation
  • fleet recover: restore faulted databases from backup; quarantine the unrecoverable
  • GUI: the full fleet lifecycle — fingerprint, converge, health, and recover
  • mcp: MCP server — let Claude and other AI agents call Litescope as read-only tools
  • advise: index & query advisor — flags un-indexed foreign keys, redundant indexes, and full table scans
  • migrate new/status/up: versioned migration workflow with a tracking table and checksum history-drift detection
  • license: show the active tier (Free / Pro)
  • GUI: fleet topology map — every database colored by health or schema cluster
  • fleet blast-radius: map a fault to the shared cohort (group/region) at risk
  • fleet health --watch / --webhook / --recover: scheduled monitoring, Slack alerts, auto-recovery
  • License verification cached (24h) with a 14-day offline grace — the server is no longer a hard dependency

v0.2.0 2026-06-16

  • GUI: Monitor Watch — continuous drift detection with live event feed
  • GUI: Fleet panel — Turso and D1 discover, snapshot, parallel check
  • GUI: Free/Pro tier — 3-connection limit, Pro gate on Monitor and Fleet
  • Lemon Squeezy payment integration — $99/year Pro subscription
  • Online license verification via Cloudflare Worker
  • Binary releases via litescope-dist + Homebrew tap

v0.1.0 2026-05-01

  • Initial release: diff, check, migrate, monitor, fleet CLI
  • GUI desktop app (Wails/Go + React)
  • Named connections sidebar