turso-drizzle
БесплатноБез исполняемых скриптовНе проверенTurso is a hosted SQLite-compatible (libSQL) database and Drizzle ORM is a type-safe TypeScript query builder; together they give typed SQLite in production…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Turso + Drizzle ORM
Overview
Turso is a managed database built on libSQL (a SQLite fork) that you reach over libsql:// URLs with an auth token. Drizzle ORM talks to it through the @libsql/client driver and the drizzle-orm/libsql adapter; drizzle-kit generates and applies migrations. Checked against drizzle-orm 0.45.4, drizzle-kit 0.31.11 and @libsql/client 0.18.0 (October 2026); Drizzle 1.0 is only on the beta and rc tags (not latest), so pin the stable 0.x line unless the user asks for the beta.
Turso's own newer engine ships separate packages (@tursodatabase/database, @tursodatabase/sync, @tursodatabase/serverless). For a remote libSQL database with an ORM, Turso's docs still point to @libsql/client, which is what this skill uses.
Instructions
Install
npm install drizzle-orm @libsql/client
npm install -D drizzle-kit tsx
Create the database (Turso CLI)
brew install tursodatabase/tap/turso # macOS; Linux: use the install script from docs.turso.tech/cli/installation
turso auth login
turso db create orders-prod
turso db show orders-prod --url # libsql://orders-prod-<org>.turso.io
turso db tokens create orders-prod # prints the auth token
On Linux the docs offer curl -sSfL https://get.tur.so/install.sh; download and read the script before running it rather than piping it into a shell. Put the values in .env (never commit it):
TURSO_DATABASE_URL=libsql://orders-prod-acmeshop.turso.io
TURSO_AUTH_TOKEN=paste-the-output-of-turso-db-tokens-create
Client
// src/db/client.ts
import { createClient } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import * as schema from "./schema";
const client = createClient({
url: process.env.TURSO_DATABASE_URL!,
authToken: process.env.TURSO_AUTH_TOKEN,
});
export const db = drizzle(client, { schema });
// equivalent shorthand: drizzle({ connection: { url, authToken }, schema })
TURSO_DATABASE_URL=file:local.db works with the same code for local development and tests, with no token.
Schema
// src/db/schema.ts
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { relations } from "drizzle-orm";
export const users = sqliteTable("users", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name").notNull(),
email: text("email").notNull().unique(),
role: text("role", { enum: ["admin", "user", "guest"] }).notNull().default("user"),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.$defaultFn(() => new Date()),
});
export const posts = sqliteTable("posts", {
id: integer("id").primaryKey({ autoIncrement: true }),
title: text("title").notNull(),
slug: text("slug").notNull().unique(),
published: integer("published", { mode: "boolean" }).notNull().default(false),
authorId: integer("author_id")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.$defaultFn(() => new Date()),
});
export const usersRelations = relations(users, ({ many }) => ({ posts: many(posts) }));
export const postsRelations = relations(posts, ({ one }) => ({
author: one(users, { fields: [posts.authorId], references: [users.id] }),
}));
export type User = typeof users.$inferSelect;
export type NewUser = typeof users.$inferInsert;
SQLite has no native boolean or date type: mode: "boolean" and mode: "timestamp" map them onto integers (timestamps are stored in seconds).
drizzle-kit and migrations
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
schema: "./src/db/schema.ts",
out: "./drizzle",
dialect: "turso",
dbCredentials: {
url: process.env.TURSO_DATABASE_URL!,
authToken: process.env.TURSO_AUTH_TOKEN,
},
});
drizzle-kit does not read .env by itself: export the variables, use node --env-file=.env, or import dotenv/config at the top of the config.
npx drizzle-kit generate # write SQL migration files from schema changes
npx drizzle-kit migrate # apply them to the database
npx drizzle-kit push # sync schema directly, no files (development only)
npx drizzle-kit studio # browse data in Drizzle Studio
Queries
import { and, count, desc, eq, like } from "drizzle-orm";
import { db } from "./db/client";
import { posts, users } from "./db/schema";
const [author] = await db
.insert(users)
.values({ name: "Alice Novak", email: "[email protected]" })
.returning();
await db.insert(users)
.values({ name: "Alice Novak", email: "[email protected]" })
.onConflictDoUpdate({ target: users.email, set: { name: "Alice N." } });
const admins = await db
.select({ id: users.id, name: users.name })
.from(users)
.where(and(eq(users.role, "admin"), like(users.email, "%@acmeshop.dev")))
.orderBy(desc(users.createdAt)
Установить turso-drizzle в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл turso-drizzle?
Turso is a hosted SQLite-compatible (libSQL) database and Drizzle ORM is a type-safe TypeScript query builder; together they give typed SQLite in production. Use when setting up Turso with Drizzle, defining a Drizzle SQLite schema, running drizzle-kit migrations against a Turso database, connecting from Cloudflare Workers or other edge runtimes, or reading from an embedded replica.
Как установить скилл turso-drizzle?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл turso-drizzle запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic