name: reddb
description: Use RedDB (the AI-first multi-model database) effectively. Covers the 7 data models on one engine, 6 query languages incl. SQL/Cypher/Gremlin/SPARQL/NL/ASK, HTTP/gRPC/embedded transports, AI providers, migrations, VCS-for-data, eventual consistency, vectors, and geo. Invoke when the user mentions RedDB, red CLI, @reddb-io/* packages, the .rdb file format, or asks "how do I X in RedDB".
RedDB
RedDB is one engine, 7 data models, 6 query languages. The mental model that prevents 90% of mistakes:
A collection is the named logical container. Rows, documents, graph nodes/edges, vectors, KV entries, time-series points, queue messages are shapes you store inside collections.
userscan be a row collection;eventscan be document;configcan be KV. A collection is not a folder containing tables — it is the table (or doc store, or graph, …).
If you forget this, you'll write CREATE DATABASE / USE foo SQL that doesn't exist here.
When the user asks you to do something with RedDB:
Identify the transport before writing any code:
- Embedded — Rust API
RedDB::open("data.rdb"), or JS via@reddb-io/sdk(spawns a localredbinary over stdio). - Server — HTTP on
:8080, gRPC on:5055, RedWire (Postgres-compatible) on:5050. Hit viacurl,psql,@reddb-io/client, or any Postgres driver. - Agent / MCP —
red mcpexposes RedDB as an MCP tool to LLMs.
Same
.rdbfile format across all three. The user's choice is usually implicit in what they already have running — don't migrate them unprompted.- Embedded — Rust API
Pick the query language by user intent, not by habit:
- Tabular / aggregation / joins → SQL.
- Path traversal, neighborhood queries → Cypher or Gremlin.
- Semantic / "find similar" →
SEARCH SIMILAR TEXT(vectors). - Cross-model entity lookup →
SEARCH CONTEXTorFROM ANY. - Natural-language Q&A grounded in data →
ASK(RAG built-in; cites sources). - The engine auto-detects the language from the first tokens — don't wrap it.
Before recommending a feature, verify it exists in the user's version. Run:
red --version(ornpx @reddb-io/cli@latest version)curl -s localhost:8080/statsto confirm the server is up and which features are compiled in.- For SQL grammar specifically, check
docs/reference/sql-1-0-x.mdin the reddb repo if the user has it cloned.
Default to safe parameters, not string interpolation:
curl -X POST localhost:8080/query -d '{ "query": "SELECT * FROM hosts WHERE critical = $1", "params": [true] }'In JS SDK:
db.query('SELECT * FROM users WHERE id = $1', userId). Never concatenate user input into SQL — RedDB supports$1-style positional binding everywhere.For "how do I do X" requests, consult the reference files in this skill:
CHEATSHEET.md— one-screen reference for every model, every transport, every common operation. Read this first.COLLECTIONS.md— deep dive on every user-facing model (Tables, Append-Only, Documents, KV, Cache, Graphs, Vectors, Time-Series, Hypertables, Continuous Aggregates, Queues WORK/FANOUT, Events, Metrics) plus indexes and probabilistic structures. Read when the user is choosing or combining models.TYPES.md— the full type system, standard + native (network, geo, locale, financial includingMoney/AssetCode, identity, visual, security:Secret/Password, cross-model*Reftypes). Read when designing a schema or whenever the user has fields like email/IP/money/passwords.INFRASTRUCTURE.md— embedded, server, server-in-Docker, primary + replica. Includes bind contract, vault, maintenance scheduler, commit policies (local/remote_wal/ack_n/quorum), writer lease, replica state machine. Read when the user is deploying or operating RedDB.AI.md— embeddings (WITH AUTO EMBED+/ai/embeddingswith 3 modes), inferences (/ai/promptwith templates),ASKand every knob (STRICT,STREAM,CACHE TTL,LIMIT,DEPTH, fallback chains), credentials/vault (env vars,/ai/credentials,red_configlayout, resolution chain), provider matrix incl. Anthropic embeddings policy and the in-progresslocalprovider (candle, feature-gated bylocal-models). Read whenever AI or embeddings come up.RECIPES.md— full end-to-end patterns (RAG, audit log, queue worker, vector search with filters, migrations, backups, CDC, …). Read when the cheatsheet line isn't enough.
Never invent SQL. If a user asks for syntax you're unsure about, say so and either (a) point them to the docs, or (b) try the simplest valid form and verify against
redoutput. RedDB extends SQL in specific places (WITH TTL,WITH CONTEXT INDEX,WITH EXPAND GRAPH,DOCUMENT,EDGE,APPEND ONLY,HYPERTABLE,MIGRATION,ASK) — don't paste Postgres-isms that don't apply (CREATE EXTENSION,SCHEMA,RETURNING *may or may not exist on the user's version).Respect destructive-action rules.
ROLLBACK MIGRATION,DROP COLLECTION,red restore, anything against afile://or production server — confirm with the user before running. RedDB's VCS-for-data makes most things reversible, but only if the user knows you ran them.
Killer features worth knowing about
ASK 'question'— one statement, full RAG. Searches every model, builds context, calls an LLM, returns a cited answer.USING <provider>to swap,STRICT ONto refuse uncited answers,CACHE TTL '5m'to memoize.SEARCH CONTEXT 'value' FIELD field DEPTH n— find every row/doc/node/vector that mentions a value, across models.FROM ANY— SQL pseudo-table that returns the cross-model union ranked by_score.- VCS-for-data — every migration is a commit;
ROLLBACK MIGRATIONis a revert. Don't write rollback scripts. WITH TTL <n> <unit>— auto-expire rows (s,m,h,d). Works onINSERT.WITH AUTO EMBED (col) USING <provider>— auto-vectorize on insert.- 6 reducers for eventual consistency —
Sum/Max/Min/Count/Average/Lastwith async consolidation. POST to/ec/<collection>/<field>/add. - Postgres-wire compatible on
:5050— you can connect withpsql,pgx,node-postgres, etc. Useful when the user already has a Postgres driver.
When to not reach for RedDB features
- The user already has Postgres + a working extension (PostGIS, pgvector). Don't propose a migration unless asked.
- They need ACID-tight multi-statement transactions across replicas — RedDB has transactions but the durability story for distributed setups is younger than Postgres'. Verify guarantees in
docs/operations/rto-rpo.md. - High-cardinality OLAP with windowing functions all day — RedDB does it, but ClickHouse is purpose-built.
File layout when you're poking around a user's install
data.rdb— main storedata.rdb-dwb— double-write buffer (don't delete)data.rdb-hdr/data.rdb-meta— shadow copies for crash recoverywal.log— write-ahead log~/.config/reddb/— credentials, default provider, named connections (seered connect)
Reference files in this skill
CHEATSHEET.md— fast lookup of every model & syntax shape.COLLECTIONS.md— deep dive on every user-facing model + indexes + probabilistic structures.TYPES.md— full type system, standard + native (incl.Money,Secret,Password,*Ref).INFRASTRUCTURE.md— embedded, server, Docker, primary + replica, commit policies, writer lease.AI.md— embeddings, inferences, ASK, credentials/vault, provider matrix, local-model status.RECIPES.md— end-to-end patterns.recipes/— one file per recipe when they're long enough to deserve it.
When you cite something to the user, link to the file under plugins/reddb/skills/reddb/ so they can read more.