libsql
libSQL — a fork of SQLite with replication, HTTP API, and embedded replicas (used by Turso). Use when you need embedded SQLite with remote sync, an edge-compatible database, or a Turso cloud database. Covers the @libsql/client SDK, local/in-memory/cloud connections, embedded replicas, batch queries, and transactions.
What this skill does
# libSQL
## Overview
libSQL is a fork of SQLite that adds replication, HTTP API access, and embedded replicas. It is the database engine behind Turso. Use the `@libsql/client` SDK to connect to local SQLite files, in-memory databases, or Turso cloud databases with the same API.
## Installation
```bash
npm install @libsql/client
# or
bun add @libsql/client
```
## Connection Modes
### Local SQLite File
```typescript
import { createClient } from "@libsql/client";
const db = createClient({
url: "file:local.db",
});
```
### In-Memory (testing)
```typescript
const db = createClient({
url: ":memory:",
});
```
### Turso Cloud
```typescript
const db = createClient({
url: process.env.TURSO_DATABASE_URL!, // libsql://your-db.turso.io
authToken: process.env.TURSO_AUTH_TOKEN!, // Generated from Turso CLI
});
```
### Embedded Replica
Local SQLite file that syncs from a remote Turso database. Reads hit the local file (fast), writes go to the remote and sync back:
```typescript
const db = createClient({
url: "file:local-replica.db", // Local replica path
syncUrl: process.env.TURSO_DATABASE_URL!, // Remote Turso URL
authToken: process.env.TURSO_AUTH_TOKEN!,
syncInterval: 60, // Auto-sync every 60 seconds
});
// Manual sync
await db.sync();
```
### HTTP Mode (Edge)
For edge environments where native SQLite bindings are not available:
```typescript
const db = createClient({
url: process.env.TURSO_DATABASE_URL!, // Use https:// URL for HTTP mode
authToken: process.env.TURSO_AUTH_TOKEN!,
});
// @libsql/client automatically uses HTTP when a remote URL is provided
```
## Basic Queries
```typescript
import { createClient } from "@libsql/client";
const db = createClient({ url: "file:app.db" });
// Execute DDL
await db.execute(`
CREATE TABLE IF NOT EXISTS posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
body TEXT,
slug TEXT UNIQUE NOT NULL,
created_at INTEGER DEFAULT (unixepoch())
)
`);
// Insert
await db.execute({
sql: "INSERT INTO posts (title, body, slug) VALUES (?, ?, ?)",
args: ["Hello World", "First post content", "hello-world"],
});
// Select all
const result = await db.execute("SELECT * FROM posts ORDER BY created_at DESC");
console.log(result.rows); // Row[]
console.log(result.columns); // string[]
// Select with parameters
const post = await db.execute({
sql: "SELECT * FROM posts WHERE slug = ?",
args: ["hello-world"],
});
console.log(post.rows[0]); // First row
// Update
await db.execute({
sql: "UPDATE posts SET title = ? WHERE id = ?",
args: ["Updated Title", 1],
});
// Delete
await db.execute({
sql: "DELETE FROM posts WHERE id = ?",
args: [1],
});
```
## Batch Queries
Execute multiple statements in a single round trip:
```typescript
// All statements in a batch run atomically (like a transaction)
const results = await db.batch([
{
sql: "INSERT INTO posts (title, slug) VALUES (?, ?)",
args: ["Post 1", "post-1"],
},
{
sql: "INSERT INTO posts (title, slug) VALUES (?, ?)",
args: ["Post 2", "post-2"],
},
"SELECT COUNT(*) as total FROM posts",
]);
console.log(results[2].rows[0]); // { total: 2 }
```
## Transactions
```typescript
import { createClient } from "@libsql/client";
const db = createClient({ url: "file:app.db" });
// Interactive transaction
const tx = await db.transaction("write");
try {
await tx.execute({
sql: "INSERT INTO accounts (user_id, balance) VALUES (?, ?)",
args: [1, 1000],
});
await tx.execute({
sql: "INSERT INTO accounts (user_id, balance) VALUES (?, ?)",
args: [2, 500],
});
// Transfer
await tx.execute({
sql: "UPDATE accounts SET balance = balance - ? WHERE user_id = ?",
args: [100, 1],
});
await tx.execute({
sql: "UPDATE accounts SET balance = balance + ? WHERE user_id = ?",
args: [100, 2],
});
await tx.commit();
console.log("Transfer complete");
} catch (err) {
await tx.rollback();
console.error("Transfer failed:", err);
}
```
Transaction modes:
- `"write"` — read-write transaction
- `"read"` — read-only transaction (faster on replicas)
- `"deferred"` — SQLite deferred transaction
## Result Row Access
```typescript
const result = await db.execute("SELECT id, title, created_at FROM posts");
// Access by column name
for (const row of result.rows) {
console.log(row.id, row.title, row.created_at);
}
// Column metadata
console.log(result.columns); // ["id", "title", "created_at"]
// Last insert ID
const insert = await db.execute({
sql: "INSERT INTO posts (title, slug) VALUES (?, ?)",
args: ["New Post", "new-post"],
});
console.log(insert.lastInsertRowid); // bigint
console.log(insert.rowsAffected); // number
```
## Setting Up Turso
```bash
# Install Turso CLI
curl -sSfL https://get.tur.so/install.sh | bash
# Login
turso auth login
# Create database
turso db create my-app-db
# Get connection URL
turso db show my-app-db --url
# → libsql://my-app-db-yourname.turso.io
# Create auth token
turso db tokens create my-app-db
# → eyJhbGciOi...
# List databases
turso db list
# Open shell
turso db shell my-app-db
```
## Environment Setup
```bash
# .env
TURSO_DATABASE_URL=libsql://my-app-db-yourname.turso.io
TURSO_AUTH_TOKEN=eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...
```
```typescript
// src/db.ts — singleton client
import { createClient } from "@libsql/client";
if (!process.env.TURSO_DATABASE_URL) {
throw new Error("TURSO_DATABASE_URL is required");
}
export const db = createClient({
url: process.env.TURSO_DATABASE_URL,
authToken: process.env.TURSO_AUTH_TOKEN,
});
```
## Full Example: Blog API
```typescript
import { createClient } from "@libsql/client";
const db = createClient({
url: process.env.TURSO_DATABASE_URL!,
authToken: process.env.TURSO_AUTH_TOKEN!,
});
// Initialize schema
await db.execute(`
CREATE TABLE IF NOT EXISTS posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
slug TEXT UNIQUE NOT NULL,
body TEXT NOT NULL DEFAULT '',
published INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL DEFAULT (unixepoch())
)
`);
// Create
async function createPost(title: string, slug: string, body: string) {
const result = await db.execute({
sql: "INSERT INTO posts (title, slug, body) VALUES (?, ?, ?) RETURNING *",
args: [title, slug, body],
});
return result.rows[0];
}
// Read
async function getPosts(publishedOnly = true) {
const sql = publishedOnly
? "SELECT * FROM posts WHERE published = 1 ORDER BY created_at DESC"
: "SELECT * FROM posts ORDER BY created_at DESC";
const result = await db.execute(sql);
return result.rows;
}
// Update
async function publishPost(id: number) {
await db.execute({
sql: "UPDATE posts SET published = 1 WHERE id = ?",
args: [id],
});
}
// Delete
async function deletePost(id: number) {
await db.execute({
sql: "DELETE FROM posts WHERE id = ?",
args: [id],
});
}
```
## Guidelines
- Always use parameterized queries with `args` — never string-concatenate SQL.
- Use `batch()` for multiple related inserts/updates to reduce round trips.
- Prefer `transaction("write")` for operations that must be atomic.
- Use embedded replicas when you need fast reads and can tolerate eventual consistency.
- Call `db.sync()` manually after writes when using embedded replicas for immediate read consistency.
- Use `":memory:"` for tests — fast and isolated.
- Store `TURSO_DATABASE_URL` and `TURSO_AUTH_TOKEN` in environment variables, never in code.
- `lastInsertRowid` is a `bigint` — convert with `Number()` when needed.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.