/better-duck-skills:better-duck-taurifrom better-duck-skills
Tauri v2 plugin exposing embedded DuckDB to the webview as a local analytics engine. Register in tauri::Builder, call load/close/select/execute commands from JS/TS via @better-duck/tauri, configure backends and security policies.
Ships in better-duck-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A Tauri v2 plugin that exposes better-duck
(embedded DuckDB) to the webview as a local analytics engine — not just a CRUD bridge. The Rust
side registers the plugin on tauri::Builder with a chosen backend; the frontend talks to it through
the @better-duck/tauri npm package, which wraps a fixed set of invoke commands.
Status is beta: query / analytics / migration / security features are implemented and tested; the
arrow (Arrow IPC) command and Android CI are the pending edges.
Sibling skills: duckdb (SQL dialect + types you will write through this plugin), better-duck-core
(the Rust driver underneath), better-duck-diesel (the Diesel ORM backend), and better-duck
(the top-level crate map).
backend-core (default) builds on better-duck-core;
backend-diesel builds on better-duck-diesel (an r2d2 pool of DuckDbConnection + Diesel
embed_migrations!). The webview command surface is identical either way — both engines
implement the same DuckBackend trait, so JS code never changes.#[tauri::command] and runs DuckDB
work on a blocking task so the async runtime is never blocked.Policy (mandatory) and declarative per-capability
scope entries, both enforced before the backend runs.Rust (src-tauri/Cargo.toml + your builder):
[dependencies]
better-duck-tauri = { version = "0.1.0-beta.8", features = ["backend-core"] }
tauri::Builder::default()
.plugin(better_duck_tauri::core::init()) // simplest; or ::diesel::init()
.run(tauri::generate_context!())?;
Grant permissions in src-tauri/capabilities/*.json (default allows load/close/select only;
writes and raw SQL are opt-in):
{ "permissions": ["better-duck-tauri:default", "better-duck-tauri:allow-execute"] }
Frontend (@better-duck/tauri):
import Database from '@better-duck/tauri'
const db = await Database.load('duckdb:analytics.db') // or 'duckdb::memory:'
await db.execute('CREATE TABLE t (id INTEGER, name VARCHAR)')
await db.execute('INSERT INTO t VALUES ($1, $2)', [1, 'ada'])
const rows = await db.select('SELECT * FROM t WHERE id > $1', [0]) // [{ id: 1, name: 'ada' }]
await db.close()
Connection strings: duckdb:<path> opens a file, duckdb::memory: (or empty) opens in-memory, and
a bare path works too — the plugin strips the duckdb: prefix to resolve the DuckDB path.
Every method on the JS Database class maps to one Rust command (plugin:better-duck-tauri|<name>).
Parameters bind as positional $1, $2, … from the values array.
| JS method | Command | Does |
|---|---|---|
Database.load(path) | load | Open + register a connection; runs pending migrations |
db.close() | close | Drop the connection (→ bool existed) |
db.select(sql, values?) | select | Read query → array of JSON row objects |
db.execute(sql, values?) | execute | Write/DDL → { rowsAffected } |
db.loadExtension(name) | load_extension | INSTALL+LOAD a DuckDB extension |
db.import(table, src, fmt) | import | CREATE TABLE … AS SELECT * FROM read_*() (parquet/csv/json) |
db.export(sql, path, fmt) | export | COPY (…) TO path |
db.appendRows(table, rows) | append_rows | Bulk INSERT of JSON object rows |
db.tables() / db.columns(t) | tables / columns | Introspect main schema |
db.explain(sql) | explain | EXPLAIN plan rows |
db.stream(sql, onBatch, values?, chunk?) | stream | Chunked rows over a Channel → total count |
db.interrupt() | interrupt | Cancel the in-flight stream (→ bool) |
db.checkpoint(force?) | checkpoint | Flush WAL (FORCE CHECKPOINT when force) |
db.revert() | revert | Run the last migration's Down (→ reverted version) |
db.queryArrow(sql, values?) | query_arrow | Arrow IPC bytes (needs the arrow feature) |
JSON row shape: values map to JSON with full type coverage. Precision-sensitive scalars (HUGEINT,
DECIMAL, UUID, BIT, BIGNUM) serialize as strings, BLOB as a byte array, composites
(LIST/STRUCT/MAP/UNION/ENUM) as arrays/objects, temporals as ISO-8601 strings.
| You need to… | Read |
|---|---|
Add the Rust dep + JS package, register core vs diesel, use every command, decode Arrow IPC | references/register-and-frontend.md |
| Define migrations, control ordering, understand startup + crash-safe backup | references/migrations.md |
Lock down an untrusted webview: capabilities, permissions, scope entries, Policy | references/security.md |
Compare backend-core vs backend-diesel, back up, and tune checkpoint strategies | references/backends-and-checkpoint.md |
better_duck_tauri::Error (UnknownConnection / Denied / Backend / Tauri),
serialized to the webview as a plain string. The JS invoke promise rejects with that string.select is filesystem-read-capable. DuckDB SELECT can reach disk through table functions
(read_csv_auto, read_parquet, glob, …), which the leading-keyword deny_risky_statements
filter does not catch. For an untrusted webview, pair select with read_only(true) and/or a
connection allow-list — see references/security.md.backend-core nor backend-diesel is a
compile error.on_connect hooks are the place to register UDFs or LOAD extensions so every opened
connection carries them (see better-duck-core / better-duck-macros for the UDF side).query_arrow returns the raw IPC body via tauri::ipc::Response; without the arrow feature
the command returns a backend error.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
6 skills in this plugin
/better-duckOverview and task router for the better-duck DuckDB driver for Rust. Use when working with the better-duck / better-duck-core / better-duck-macros / better-duck-diesel / better-duck-tauri crates, when choosing a Cargo feature flag, or when deciding which API or crate fits a task (opening a connection, querying, parameter binding, bulk insert, columnar access, user-defined functions, Diesel ORM, or a Tauri plugin). Routes to the per-crate skills for depth./better-duck-coreRust API guide for the better-duck-core crate (the embedded DuckDB driver published as better-duck): opening connections, executing SQL, iterating rows and values, parameter binding, bulk insert, columnar chunks, transactions, pooling, async, and Arrow/Polars interop. Use when writing Rust against better-duck-core — Connection, execute, execute_with, execute_with_named, DuckResult / DuckValue, Appender, fetch_chunk, TableDescription, Database — or when choosing a Cargo flag feature = "chrono|decimal|arrow|polars|columnar|udf|async|pool|time|uuid" (plus json / parquet / icu for bundled extensions, and derive). For DuckDB SQL and engine behavior use the duckdb skill; for the UDF and data-derive macros use better-duck-macros./better-duck-dieselThe Diesel 2.3 ORM backend for DuckDB, built on better-duck. Use when working with the `better-duck-diesel` crate: establishing a `DuckDbConnection`, defining a `table!` schema, running INSERT/SELECT/UPDATE/DELETE/RETURNING or transactions through Diesel, mapping Rust types to DuckDB column types, or reaching DuckDB-only SQL that Diesel core omits via `use better_duck_diesel::dsl::*;` (ILIKE/SIMILAR TO/GLOB/regex operators; string, numeric, regex, date/time, JSON, list and map functions; general/statistical/approximate/bit aggregates). Also covers calling your `#[duckdb_*]` UDFs through the DSL with no raw SQL (`feature = "udf"`), spatial `ST_*` functions (`feature = "spatial"`), ORM-emitting data derives (`feature = "derive"`), and r2d2 pooling. Triggers: `better-duck-diesel`, Diesel + DuckDB, `DuckDbConnection`, `better_duck_diesel::dsl`, `feature = "udf"|"derive"|"spatial"`.npx claudepluginhub nimdeveloper/better-duck --plugin better-duck-skills