CLI & Desktop Studio
Run interactive queries, administer Raft clusters, manage keys and backups with spyd CLI and SpydStudio.
In addition to the Embedded Web Studio built directly into spyd-server at /studio, SpydDB provides two standalone client tools: spyd (an interactive terminal shell and multi-database CLI) and spyd-studio (a native desktop workbench).
1. Installing spyd Globally#
Install spyd (and the spyd-cli alias) via any of four public channels:
# 1. One-line curl installer (Linux & macOS, verifies SHA-256 checksum)
curl -fsSL https://spyddb-docs.netlify.app/install.sh | sh
# 2. Cargo (crates.io or from repository)
cargo install spyd-cli --locked
# 3. Homebrew (macOS & Linux)
brew install spydotech/tap/spyd
# 4. npm (downloads the verified native binary for your platform)
npm install -g @spyddb/cliEnable shell tab-completion (Bash, Zsh, Fish, PowerShell, Elvish):
spyd completions bash > ~/.local/share/bash-completion/completions/spyd
spyd completions zsh > ~/.zfunc/_spyd2. Full-Screen Interactive Terminal UI (spyd)#
Run spyd with no arguments in an interactive terminal to launch the full-screen workbench (ratatui + crossterm). If no saved credentials exist for the active target, spyd opens the centered Connections & Encrypted Vault modal so you can pick a saved profile, paste a token/password (masked and encrypted into vault.enc), connect to any external database URL, or open an in-memory SQLite scratchpad. Set SPYD_PLAIN=1 (or pipe stdin/stdout) to use the plain line mode instead.
Key workspace features:
- Top status bar & welcome canvas: displays the active engine badge (
spyddb,postgres,mongodb,mysql,sqlite), target host, active profile, database,๐ vaultindicator, andTXtransaction badge. - Collapsible Connections & Schema sidebar (
Ctrl+B): lists saved multi-DB profiles and live tables/collections with right-aligned column counts (17 cols). PressTabto focus the sidebar,โ/โto select an item,Enterto switch profiles or preview rows (/rows <name> 20), anddto describe a table (/describe <name>). - Floating
/slash command palette: typing/opens a filterable command popup above the composer (โ/โnavigate,Tabcomplete,Enterrun). - Floating Connections & Vault modal (
Ctrl+Por/profile): switch between saved SpydDB, PostgreSQL, MongoDB, MySQL, and SQLite profiles (Enter), delete profiles and purge their vault secrets (d), or create new connections with masked secret storage (n). - Wide table panning & Record Card view (
Ctrl+E): tables wider than the terminal show a live horizontal scrollbar (cols 1โ96/194). Pan withโ/โ(when the input box is empty),Shift+โ/โ,Ctrl+โ/โ,Alt+โ/โ, trackpad horizontal scroll, orShift + Mouse Wheelโ or pressCtrl+E(/expanded) to switch immediately to vertical Record Cards with zero horizontal cutoff. - Zero-truncation JSON trees & enriched
/stats: nested JSON objects (/cluster,/format json, JSON query columns, and nested/statssections such aspool) render as syntax-highlighted indented trees with automatic byte, microsecond, UTC timestamp, and duration annotations./statsadds metric descriptions and a latency distribution histogram. - Inline ML explanations: results containing
ml_explain(...)JSON automatically render a TreeSHAP feature attribution waterfall below the result table. - Resilient idle connections: both SpydWire TLS and PostgreSQL/PGWire sessions transparently reconnect if the server closes an idle socket.
| Slash Command | Alias | Purpose |
|---|---|---|
/help | \?, F1 | Open the floating command & keyboard shortcut reference |
/connect <url|db> | \c | Switch database or connect live to SpydDB, Postgres, MongoDB, MySQL, or SQLite |
/profile [name] | Ctrl+P | Open the Connections & Vault modal or switch live to [name] |
/save <name> | โ | Save the active connection to config.toml and encrypt its secret in vault.enc |
/delete-profile <name> | โ | Remove a saved profile and purge its encrypted vault secret |
/conninfo | \conninfo | Show active engine, target, database, profile, vault status, and format |
/dbs, /tables, /views, /indexes, /roles, /streams | \l, \dt, \dv, \di, \du, \ds | Introspect databases, collections/tables, views, indexes, roles, and streams |
/describe <name> | \d | Show fields, types, and indexes for a collection, view, or role |
/rows <name> [limit] | /peek | Preview rows using the active engine's native syntax (` |
/explain <stmt> / /analyze <stmt> | โ | Show execution plan or run explain analyze |
/events <coll> [limit] | โ | Stream live committed SSE row changes into the viewport (Esc or Ctrl+C stops cleanly) |
/cluster, /extensions, /health, /stats | โ | Inspect cluster topology/HLC/leases/locks/fleet, WASM extensions, health, and telemetry |
/format <fmt>, /expanded, /timing, /output [file], /run <file> | \format, \x, Ctrl+E, \timing, \o, \i | Output formatting (table, expanded, json, ndjson, csv, tsv, yaml), timing, and script execution |
/begin, /commit, /rollback | \begin, \commit, \rollback | Explicit multi-statement transaction control (shows TX badge in the header) |
/refresh, /clear, /history, /quit | \refresh, Ctrl+L, \history, Ctrl+Q, \q | Reload schema completions, clear viewport, show history path, or exit |
Keyboard Shortcuts#
| Shortcut | Action | Shortcut | Action |
|---|---|---|---|
/ | Open floating slash command palette | Ctrl+P | Open Connections & Encrypted Vault modal |
Ctrl+B | Toggle Connections & Schema sidebar | Ctrl+E | Toggle vertical Record Card view |
Tab / โ | Accept hint, complete command, or focus sidebar | Shift+Enter / Alt+Enter | Insert newline in multi-line query |
PgUp / PgDn / Wheel | Scroll output vertically | โ/โ, Shift+โ/โ, Ctrl+โ/โ | Pan wide tables horizontally |
F1 | Open Help modal | Ctrl+L / Ctrl+Q | Clear viewport / Quit spyd |
3. Encrypted Multi-Database Profiles & Secret Vault#
spyd stores unlimited named connections across SpydDB, PostgreSQL, MongoDB, MySQL, and SQLite with strict separation between metadata and credentials:
- Metadata (
~/.config/spyddb/config.toml, mode0600): stores target URLs, TLS CA/mTLS paths, usernames, and default databases. Any password embedded in a connection URL (postgres://user:pass@host/db) is automatically stripped and percent-decoded before saving so raw secrets never touchconfig.toml. - Encrypted Vault (
~/.local/state/spyddb/vault.enc, mode0600): stores SpydDB tokens and external database passwords encrypted with AES-256-GCM-SIV, a fresh CSPRNG 96-bit nonce per write, and associated dataspyd-cli-vault-v1. Key material and decrypted buffers are zeroized on drop. - Fail-closed permissions & optional passphrase: before reading
vault.encorvault.key,spydchecks file permissions (OpenSSH-style) and refuses to open files accessible by group or others (chmod 600required). SetSPYD_VAULT_PASSPHRASEto mix a user passphrase into the derived vault key via SHA-256.
# Save a SpydDB profile (token encrypted in vault.enc; omitted from config.toml)
spyd --url spydwires://127.0.0.1:5433 --http https://127.0.0.1:8080 \
--ca tls/ca.crt --server-name localhost --token "$SPYD_TOKEN" config set local
# Save PostgreSQL and MongoDB profiles (URL passwords automatically moved to vault.enc)
spyd --url "postgres://alice:secret@db.internal:5432/orders?sslmode=require" config set prod-pg
spyd --url "mongodb+srv://app:secret@cluster.example.net/catalog" config set prod-mongo
# List profiles with engine and vault badges, switch default, or delete (purges vault secret)
spyd config list
spyd config use local
spyd config delete prod-mongo4. Universal Database Connectivity (SpydDB Native + Postgres, MongoDB, MySQL, SQLite)#
spyd is native to SpydDB โ covering SpydQL, SQL, live SSE event tailing, cluster administration, backups, security, and observability โ and also connects directly to external databases using the exact same shell, profiles, /tables//describe//dbs introspection, /connect hot-swapping, and output formats (table, expanded, json, ndjson, csv, tsv, yaml).
| Engine | Target URL Schemes | Capabilities |
|---|---|---|
| SpydDB (Native) | spydwire://, spydwires://, http(s)://, grpc(s)://, embedded:<dir> | Full SpydQL/SQL, SCRAM/token/mTLS, SSE events, cluster, backup, audit, keys, extensions, apm, alerts, slo |
| PostgreSQL | postgres://, postgresql:// | Native tokio-postgres + rustls TLS, parameterized SQL, transactions, Ctrl-C cancel, /tables//views//indexes//describe//dbs |
| MongoDB | mongodb://, mongodb+srv:// | Native Rust driver + rustls, db.<coll>.find/findOne/insertOne/insertMany/updateOne/deleteOne/aggregate/countDocuments, show dbs, show collections, raw JSON commands |
| MySQL / MariaDB | mysql://, mysqls:// | Pure Rust + rustls TLS, parameterized SQL, transactions, /tables//views//describe//dbs |
| SQLite | sqlite://path/to.db, sqlite::memory: | Bundled SQLite (zero external libs), transactions, /tables//views//indexes//describe//dbs |
# Query PostgreSQL, MongoDB, MySQL, or SQLite directly with the same CLI
spyd --url postgres://alice@127.0.0.1:5432/orders sql "SELECT id, total FROM orders LIMIT 10" -o json
spyd --url mongodb://127.0.0.1:27017/shop sql 'db.orders.find({"status": "paid"}).limit(10)'
spyd --url mysql://root@127.0.0.1:3306/shop sql "SHOW TABLES"
spyd --url sqlite://local.db sql "SELECT * FROM products ORDER BY id"Cross-Database Copy & Migration (spyd copy)#
Stream rows from PostgreSQL, MongoDB, MySQL, SQLite, or another SpydDB instance directly into a SpydDB collection with optional schema inference (--create-collection) and idempotent conflict upserts (--upsert-on):
spyd copy postgres://alice@127.0.0.1:5432/shop spydwires://127.0.0.1:5433 \
--query "SELECT id, email, total FROM orders ORDER BY id" \
--into orders \
--create-collection \
--upsert-on id \
--batch-size 5005. Global Flags, Scripting & Subcommands#
| Flag / Env Var | Purpose |
|---|---|
-P, --profile / SPYD_PROFILE | Select saved connection profile (spyd config list/set/use/delete) |
--url / SPYD_URL | Target endpoint (SpydDB, Postgres, MongoDB, MySQL, or SQLite) |
--http / SPYD_HTTP_URL | SpydDB HTTP API endpoint for admin, search, events, extensions, backup, and APM subcommands |
-d, --database / SPYD_DATABASE | Target database name |
--cluster / SPYD_CLUSTER | Linked remote cluster to proxy requests to (X-Spyd-Cluster) |
--token / SPYD_TOKEN, -U/--user, --auth | Bearer token, SCRAM-SHA-256, password, or cached session (spyd login / spyd logout) |
--ca, --server-name, --cert, --key | TLS CA verification and mutual TLS client credentials (SPYD_CA, SPYD_CERT, SPYD_KEY) |
-o, --output / SPYD_OUTPUT | Output format: table (default on TTY), expanded, json, ndjson, csv, tsv, yaml (--no-header) |
Scripting, Consistency Headers, Live SSE & Operational Subcommands#
spyd sql supports inline statements, -p <JSON> parameters ($1, $2, ...), --file, --continue-on-error, --single-transaction, --timing, and HTTP consistency headers (--idempotency-key, --if-match, --read-hlc):
# Parameterized query from file with timing & idempotency key
spyd sql -f report.spydql -p '"acme"' -p '100' --timing --idempotency-key req-001
# Tail live committed row changes over SSE (with optional Last-Event-ID cursor resume)
spyd events -c orders -e insert -e update --include-before
# Stream query results to gzipped NDJSON
spyd export "events | where created_at >= now() - 7d" --to weekly.ndjson.gz --gzip --overwrite| Subcommand Group | Capabilities Covered |
|---|---|
spyd health / whoami / stats / catalog [name] | Health check (works on SpydDB and external DBs), identity, engine stats, schema catalog browser |
spyd events | Live SSE row-change subscription (/v1/events/subscribe) with --collection, --event, --where, --from cursor resume |
spyd copy | Cross-DB streaming copy from Postgres, MongoDB, MySQL, SQLite, or SpydDB into SpydDB |
spyd extensions list | install | drop | Manage signed .spydext WebAssembly extensions |
spyd query active / cancel <query_id> | List running queries and cancel a query ID online |
spyd search / suggest | Cross-collection BM25 search and prefix autocomplete |
spyd db list | create | drop | Logical database lifecycle management |
spyd backup list | create | verify | archive-wal | restore | Online base backups, verification, WAL archiving, and PITR restore (--into <db>) |
spyd keys rotate-column | retire-column | rotate-storage | retire-storage | Online encryption key rotation |
spyd audit verify | Verify SHA-256 hash-chain integrity of the audit log |
spyd cluster ... | topology, node, shard, insert, query, raft, tx, link, ccr, dr, catalog, leases, locks, hlc, fleet, security-sync |
spyd replication ... | Primary/standby streaming status, follow, lease renewal, fencing, and promote |
spyd alerts ... & spyd slo ... | Notification channels (webhook, Slack, PagerDuty), threshold/burn-rate rules, evaluate/events, SLO management |
spyd apm ... & spyd otlp ... | Inspect APM services/traces, configure sampling/synthetics, or push OTLP JSON/protobuf payloads |
spyd config ... & spyd completions <shell> | Multi-DB connection profile manager (config.toml metadata + AES-256-GCM-SIV vault.enc secrets) and shell completions |
CLI Exit Codes#
| Code | Meaning | Code | Meaning |
|---|---|---|---|
0 | Success | 4 | Resource or profile not found |
1 | Server or query execution error | 5 | Connection or TLS failure |
2 | CLI usage / invalid flag syntax | 130 | Interrupted (SIGINT) |
3 | Authentication failure |
6. Native Desktop Workbench (spyd-studio)#
For local development and air-gapped administration without a browser, spyd-studio delivers a native GUI desktop client connecting both to remote spyd-server instances and local embedded sandbox directories.
spyd-studio # standard launch
spyd-studio --demo # launch with a seeded local sandbox
spyd-studio --telemetry # open straight to live engine telemetry