SurrealGuard infers the type of every SurrealQL statement and reports contract violations — unknown fields, kind mismatches, bad graph traversals — with fully typed results in Rust and TypeScript.
Cross-kind comparisons order by kind instead of failing. Coercions succeed silently. A misspelled field just returns NONE. Those are exactly the places bugs hide — so SurrealGuard checks each construct's contract, statically.
Real diagnostics from the actual engine. Pick a query — SurrealGuard checks it against the schema and sets out each statement's inferred response type in full, below the query.
The real SurrealGuard engine, compiled to WebAssembly, running in your browser — edit anything.
query! runs the analyzer at compile time and generates the result type. A wrong table or field is a cargo check error — no codegen step, no language server, no runtime schema fetch.
One typed db.query that extends the SurrealDB SDK, plus reactive live-query adapters for Next.js and Svelte 5. The row type is always inferred from the query text — dynamic strings degrade to unknown[] and still run.
Agents like Claude Code already lean on tsc and cargo check to know their edits compile. SurrealGuard gives them the same signal for SurrealQL — run surrealguard check in the loop and every unknown table, missing field, or type mismatch comes back as a structured, byte-precise finding to fix.
Point the agent at your project once. From then on it runs the CLI on every change and reads the results — no editor integration required, works in any harness.
surrealguard check --json → code, severity, message, help & byte range per findingsurrealguard generate → typed query results, so downstream field access is checked tooThe same analyzer powers a CLI, a language server, a Rust proc-macro, and a set of TypeScript packages.
SELECT, the six mutations, RELATE, graph traversals, transactions, DEFINE/REMOVE/ALTER, LIVE/KILL — every statement lowers to a typed AST and is analyzed.
Response kinds as upstream surrealdb_types::Kind: object literals, IF/ELSE unions, record links, graph edges, function returns, closures, subqueries.
One code per contract across eight families — schema refs, types, graph, statement misuse, functions, parameters, lints, version compat. Rust-analyzer-style messages with help: fixes and note: spans.
Every $param is exported with the kind and value domain its uses imply — UPDATE user SET age = $age → age: int.
Every finding carries an exact byte range — squiggles land on the right token, even inside a query embedded in a host file.
Diagnostics for .surql and SurrealQL embedded in TypeScript, Svelte, Vue, and Astro — plus inlay type hints, hover on context params and table fields, greyed-out dead code, and live [lints] levels. Runs in Zed.
query! macroCompile-time checked, typed SurrealQL. The compiler is the checker — no external step; results as nameless typed structs.
A typed db.query, a reactive query core, and Next.js + SvelteKit adapters with live queries and SSR handled.
JSON diagnostics, llms.txt, AGENTS.md, and compile-time errors make SurrealGuard a first-class tool for AI agents and CI.
Run the CLI with npx surrealguard — zero install, no toolchain. The engine, Rust SDK, macros, and language server are published on crates.io; the TypeScript packages on npm; a Zed extension brings live diagnostics to your editor.
npx surrealguard initnpx surrealguard checknpx surrealguard generatecargo install surrealguardcargo add surrealguard-rsnpm i @surrealguard/clientDrewRidley/zed-surrealZed extension repo
At runtime, and permissively — cross-kind comparisons order by kind, coercions succeed, missing fields return NONE. SurrealGuard checks each construct's contract statically, so those silent behaviors become errors you see before shipping.
No. You write normal SurrealQL. In Rust you wrap it in query!("…"); in TypeScript you pass a literal to db.query("…") (or run surrealguard generate for standalone types). Dynamic strings still work — they just aren't typed.
No. It analyzes your .surql schema and queries statically. The Rust macro reads your schema/ or migrations/ directory at compile time and checks against it.
SurrealDB discards spans before producing its AST, so it can't power tooling. SurrealGuard parses with tree-sitter into a typed, span-carrying AST and runs all analysis on that.
The engine, CLI, LSP, Rust macros, and TypeScript packages are built and tested. The first public release is in preparation — follow along on GitHub.