Home › Turso / libSQL › Turso / libSQL AGENTS.md

Turso / libSQL AGENTS.md

AGENTS.md for apps on Turso (libSQL/SQLite at the edge): client setup, embedded replicas, migrations, and SQLite rules.

AGENTS.mdTurso / libSQL

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

AGENTS.mdDownload  
# AGENTS.md: Turso (libSQL)

## Setup
- Client: `createClient({ url: process.env.TURSO_DATABASE_URL!, authToken: process.env.TURSO_AUTH_TOKEN })` from `@libsql/client` (`/web` in edge runtimes). Created once and reused.
- Local dev uses a file DB (`file:local.db`) or `turso dev`; tests use `:memory:` or a temp file.
- Embedded replicas (`syncUrl` + local file) for read-heavy servers; call `client.sync()` on a schedule, and remember writes go to the primary.

## SQL (it's SQLite)
- Parameterized statements only: `client.execute({ sql: "select * from users where id = ?", args: [id] })`.
- Group related writes in `client.batch([...], "write")` or an interactive `transaction("write")`; keep transactions short.
- Types: SQLite is loosely typed. Use `STRICT` tables for new schemas, `INTEGER` primary keys, ISO-8601 `TEXT` or unix `INTEGER` for times (pick one and stick to it).
- Turn on foreign keys (`PRAGMA foreign_keys = ON` if not default) and declare them.
- Index columns used in `WHERE`/`JOIN`/`ORDER BY`; check with `EXPLAIN QUERY PLAN`.
- `ALTER TABLE` is limited; complex changes use the create-copy-rename pattern in a migration.

## Migrations
Through the ORM in use (Drizzle `dialect: "turso"`, Prisma adapter) or numbered SQL files. Never run destructive SQL on the production database from the agent.

## Done
Typecheck and tests pass against a local libSQL database.

More: all Turso / libSQL rules · all AGENTS.md rules

Related rules

PostgreSQL schema & SQL AGENTS.md

AGENTS.md for working on PostgreSQL 16+ schemas and SQL: safe migrations, indexes, constraints, and query plans.

AGENTS.mdPostgreSQL

Supabase AGENTS.md

AGENTS.md for Supabase projects: local CLI workflow, migrations, Row Level Security, generated types, and Edge Functions.

AGENTS.mdSupabase

Convex backend rules

Cursor rules for Convex backends: schema, validated queries/mutations/actions, indexes, and auth checks.

CursorConvex

Drizzle ORM rules

Cursor rules for Drizzle ORM with Postgres or SQLite: schema files, drizzle-kit migrations, and type-safe queries.

CursorDrizzle ORM

Firebase (modular SDK) rules

Cursor rules for Firebase web apps with the modular v11+ SDK, Firestore security rules, and emulator tests.

CursorFirebase

MongoDB Windsurf rules

Windsurf rules for MongoDB 8 apps with the Node.js driver: schema design, indexes, aggregation, and transactions.

WindsurfMongoDB

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.