Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

SurrealDB CLI

$ surreal Official Med Risk
SurrealDB · Database & Data · BSL-1.1 · macos / linux / windows

surreal is the single-binary Rust CLI for SurrealDB's multi-model (document, graph, relational, vector) database. It runs piped SurrealQL queries with --json, manages schema/data export and import, and starts embedded local instances via surreal start.

FCRS-1.0 Score
84 /100
Good
Medium Confidence
Zero-Friction Install
brew install surrealdb/tap/surreal
CLI vs MCP Decision CLI Preferred vs MCP

surreal pipes SurrealQL queries (--json), imports/exports .surql dumps, and runs ephemeral local dev databases directly without MCP.

Agent-Readiness Checklist

✓ JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 21 / 25

Supports --json on surreal sql, stdin piping for headless execution, and SURREAL_* env vars, though surreal sql enters a REPL if stdin is a TTY.

  • Supports --json and stdin-piped queries on surreal sql
Trust & Safety 19 / 25

Namespace/database scoping and env-var credentials help isolate targets, though surreal import and destructive SurrealQL lack a --dry-run flag.

  • Supports SURREAL_USER/SURREAL_PASS env vars; no --dry-run on import
Setup & Portability 14 / 15

Single fast Rust binary distributed via Homebrew tap and official install script for macOS, Linux, and Windows.

  • Single static Rust binary via brew install surrealdb/tap/surreal
Utility & Efficiency 14 / 15

Combines local server startup, SurrealQL execution, .surql export/import, and benchmarking in one binary.

  • Covers start, sql, export, import, and validate
Maintenance & Lineage 8 / 10

Official surrealdb/surrealdb CLI with rapid releases, though governed by BSL-1.1 rather than an OSI-approved license.

  • Official SurrealDB repo under BSL-1.1
Docs & Verifiability 8 / 10

Well-structured CLI documentation at surrealdb.com/docs/surrealdb/cli and built-in --help.

  • Official CLI docs at surrealdb.com

Security, Auth & Guardrails

Auth Modes
No Auth Env API Key
Credential Storage

Reads SURREAL_USER, SURREAL_PASS, SURREAL_ENDPOINT, SURREAL_NAMESPACE, and SURREAL_DATABASE environment variables.

Side Effects
Read-Only Local Write Remote Write Destructive
Cost & Quotas

CLI and core binary are BSL-1.1 (free for non-DBaaS production/dev); SurrealDB Cloud incurs usage fees.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# SurrealDB CLI (surreal) Agent Rules
- Pipe queries via stdin with `--json` (`echo "..." | surreal sql ... --json`) so `surreal` exits cleanly.
- Set `SURREAL_USER` / `SURREAL_PASS` via env vars rather than CLI flags.
- Verify `--ns` and `--db` flags before running `surreal import` or `REMOVE TABLE`.

Agent-Ready Command Recipes

Safe Read-Only Queries

Inspect database schema as JSON
echo "INFO FOR DB;" | surreal sql --endpoint http://localhost:8000 --ns test --db test --json

Pipes INFO FOR DB; into surreal sql and returns structured JSON schema definitions.

Export a SurrealDB namespace/database backup
surreal export --endpoint http://localhost:8000 --ns test --db test backup.surql

Dumps tables, records, and definitions to a portable .surql file.

Controlled Writes & Previews

Apply a SurrealQL schema/migration file
surreal import --endpoint http://localhost:8000 --ns test --db test schema.surql

Executes statements from schema.surql against the target namespace and database.

Strengths for Agents

  • + Single fast Rust binary supporting --json output and piped SurrealQL.
  • + Explicit --ns and --db targeting plus SURREAL_* environment variables.

Caveats & Pitfalls

  • ! Source-available BSL-1.1 license (restricts offering managed DBaaS) rather than Apache-2.0/MIT.
  • ! CLI subcommand layout evolved between v1/v2 (surreal sql vs surreal db sql).

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI