Turso

From InugamiDev/ultrathink-oss · View interactive version

Turso is an AI agent skill from the GitHub repository InugamiDev/ultrathink-oss. > SQLite for the edge — libSQL database with embedded replicas and global distribution.

How to use this skill

Skill file

Turso

SQLite for the edge — libSQL database with embedded replicas and global distribution.

When to Use

Core Patterns

Client Setup

import { createClient } from "@libsql/client";

const turso = createClient({
  url: process.env.TURSO_DATABASE_URL!,
  authToken: process.env.TURSO_AUTH_TOKEN!,
});

// With embedded replica (reads from local SQLite file, writes to remote)
const turso = createClient({
  url: process.env.TURSO_DATABASE_URL!,
  authToken: process.env.TURSO_AUTH_TOKEN!,
  syncUrl: process.env.TURSO_DATABASE_URL!,  // remote for sync
  syncInterval: 60,  // sync every 60 seconds
});

Queries

// Read
const result = await turso.execute("SELECT * FROM users WHERE id = ?", [userId]);
const user = result.rows[0];

// Write
await turso.execute("INSERT INTO users (name, email) VALUES (?, ?)", [name, email]);

// Batch (atomic transaction)
await turso.batch([
  { sql: "INSERT INTO orders (user_id, total) VALUES (?, ?)", args: [userId, total] },
  { sql: "UPDATE users SET order_count = order_count + 1 WHERE id = ?", args: [userId] },
], "write");

// Interactive transaction
const tx = await turso.transaction("write");
try {
  await tx.execute("UPDATE accounts SET balance = balance - ? WHERE id = ?", [amount, from]);
  await tx.execute("UPDATE accounts SET balance = balance + ? WHERE id = ?", [amount, to]);
  await tx.commit();
} catch { await tx.rollback(); }

Key Features

CLI

turso db create mydb          # Create database
turso db shell mydb           # Interactive SQL shell
turso db tokens create mydb   # Generate auth token
turso db replicate mydb lhr   # Add replica in London
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.