/valtown:sqlite-storagefrom Val Town
Provides SQLite storage for structured data using parameterized queries, transactions, and val-scoped vs organization-scoped databases.
Ships in Val Town. 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.
Val Town provides built-in SQLite via the std/sqlite module. Reach for it whenever a val needs relational or structured persistent data. For simple key/value data, prefer std/blob instead.
import { sqlite } from "https://esm.town/v/std/sqlite/main.ts";
await sqlite.execute(`CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE
)`);
await sqlite.execute({
sql: "INSERT INTO users (name, email) VALUES (?, ?)",
args: ["Alice", "[email protected]"],
});
const result = await sqlite.execute("SELECT * FROM users");
// result.rows = [{ id: 1, name: "Alice", email: "[email protected]" }]
Use sqlite.batch for atomic multi-statement transactions — all succeed or all roll back:
await sqlite.batch([
{ sql: "INSERT INTO users (name, email) VALUES (?, ?)", args: ["Bob", "[email protected]"] },
{ sql: "UPDATE users SET name = ? WHERE id = ?", args: ["Robert", 2] },
]);
The import path determines which database you get. Both expose the same @libsql/client API (execute, batch) and return rows as keyed objects (Record<string, unknown>[]):
std/sqlite/main.ts — val-scoped database, isolated to this val. The default for new vals, and what you almost always want.std/sqlite/global.ts — organization-scoped database, shared across every val owned by the same account. (Your personal account counts as its own organization here, so this database is shared across all of your vals.)Do not switch an existing val between these import paths — it changes which database the val reads and writes.
When using the sqlite_execute or sqlite_batch tools to query a val owned by an organization (not your personal account), pass the org handle as the org parameter so the call hits the right database. Example: { sql: "SELECT * FROM users", org: "some-org" }. This only matters for the tool calls — code inside the val itself reads from its own database automatically.
args field) for any value derived from user input. Never interpolate strings into SQL.CREATE TABLE IF NOT EXISTS so schema setup is idempotent across val restarts.ALTER TABLE ... ADD COLUMN. Wrap in try/catch if the migration may run against an already-updated table.Full API docs: https://docs.val.town/reference/std/sqlite/usage/
What SKILL.md sets; muted values are Claude Code's defaults
11 skills in this plugin
/blob-storageUse when a val needs simple key/value persistence — JSON documents, cached responses, uploaded files, or binary assets. Covers the std/blob API, listing and deleting keys, account-global or val scoping, and storage limits./client-side-jsUse when a val needs to ship JavaScript that runs in the browser — React apps, vanilla DOM scripts, canvas/games, htmx/Alpine, or any client-side module beyond a single inline snippet. Explains how Val Town serves transpiled .ts/.tsx/.jsx modules with no build step, how the browser resolves their imports, and how to load third-party deps./create-skillUse when the user wants to persist a preference, skill, or knowledge. Use when it would aid future val development to store a memory of how best to build something.claude plugin install valtown@claude-plugins-officialOther plugins' skills for the same job