sqlite-schema-design

A design and review guide for SQLite databases that synchronize through SQLite Sync. SQLite Sync replicates database changes between devices or databases, so tables must follow additional rules beyond ordinary SQLite design.

In plain words
What is it for?
Use it when adding or changing synchronized tables, choosing primary keys and defaults, handling foreign keys, or planning migrations for CloudSync-backed applications.
Why use it?
It prevents schema choices that can break synchronization, such as unstable identifiers or incompatible schema changes. It also helps separate synchronized data from local-only caches.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/fastrepl/anarlog/sqlite-schema-design
Any agent
npx skills add fastrepl/anarlog --skill sqlite-schema-design
Clone the repo
git clone --depth 1 https://github.com/fastrepl/anarlog

Made for: Claude Code, Codex.

Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,586 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00042 $0.01586
Opus 5 $0.00021 $0.00793
Sonnet 5 $0.00008 $0.00317
Haiku 4.5 $0.00004 $0.00159

Measured 2d ago against content hash 9ef2dc193d78, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sqlite-schema-design scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/sqlite-schema-design/SKILL.md · 222 lines

How it starts

The opening of the file, as written. The whole thing — 222 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Goal

Design tables that behave correctly under SQLite Sync's CRDT replication model.

This skill is specifically for CloudSync-backed schemas:

  • tables are initialized through cloudsync_init(...)
  • sync is enabled with cloudsync_enable(...)
  • identifiers should be generated with cloudsync_uuid()
  • schema changes must go through cloudsync_begin_alter(...) and cloudsync_commit_alter(...)
  • local and cloud databases must keep the same schema

Do not treat this as ordinary SQLite schema design. SQLite Sync imposes extra rules around keys, defaults, foreign keys, and schema evolution.

Workflow

1. Decide Whether The Table Is Synced

Before proposing DDL, classify the table:

  • synced application data: must satisfy SQLite Sync constraints
  • local-only cache or ephemeral state: should usually stay out of CloudSync

Only apply this skill to synced tables or to tables that may become synced soon.

2. Require A Stable, Globally Unique Primary Key

For synced tables:

  • always declare an explicit primary key
  • prefer TEXT PRIMARY KEY NOT NULL
  • generate ids with cloudsync_uuid()
  • do not use auto-incrementing integer ids

SQLite Sync docs explicitly recommend UUIDv7-style globally unique ids for CRDT workloads. Integer autoincrement ids are a bad fit because multiple devices can create rows independently.

CREATE TABLE document (
  id TEXT PRIMARY KEY NOT NULL DEFAULT (cloudsync_uuid()),
  workspace_id TEXT NOT NULL,
  title TEXT NOT NULL DEFAULT '',
  body TEXT NOT NULL DEFAULT '',
  archived INTEGER NOT NULL DEFAULT 0,
  created_at INTEGER NOT NULL DEFAULT (unixepoch()),
  updated_at INTEGER NOT NULL DEFAULT (unixepoch())
) STRICT;

If the environment cannot use a function call in DEFAULT, generate the id in application code, but still use cloudsync_uuid() as the canonical id strategy.

3. Make Inserts Merge-Safe With Real Defaults

SQLite Sync best practices call out a non-obvious CRDT constraint: merges can happen column-by-column, so missing values are much more dangerous than in a single-node SQLite app.

Read the full file on GitHub · 222 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 222 lines · 42 tokens per session scan A 9ef2dc193d78

Subscribe to this mod's changes

sqlite-schema-design is a skill published in the GitHub repository fastrepl/anarlog (9,219 stars, last pushed today), licensed MIT. It adds 42 tokens to every session and 1,586 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

shellx-host

ShellX host-session manifest. Use only when the current prompt or runtime metadata positively identifies this session as running inside ShellX, when ShellX host tools are advertised, or when the user explicitly asks about ShellX host APIs or surfaces. Do not use merely because this skill is installed, a project…

martinsbrezauckis/shellx · 89 tokens

design-language

Use when building, modifying, or fixing any frontend UI in the Asyar launcher — new components, new views, layout changes, styling decisions, new built-in features, visual bug fixes, and anything in settings or onboarding. Answers "what do I use here?" for fonts, colour, typography, spacing, motion, components, and…

Xoshbin/asyar · 72 tokens

architectural-integrity

Use before planning or implementing ANY feature, bug fix, refactor, or API change that touches Asyar's architecture — extension system, service layer, IPC contracts, Tauri commands, manifest contributions, or cross-layer data flow. Triggers on new features, new extension APIs, new services, bug fixes involving…

Xoshbin/asyar · 176 tokens

generated-files

Never hand-edit or hand-copy generated content. Use when touching permissions.rs, error.rs, AppError/SearchError variants, runtimes/catalog.fallback.json, any #[derive(specta::Type)] struct, any file with an AUTO-GENERATED banner (kinds.ts, gatedPermissions.ts, knownRuntimes.ts, bindings.ts, emoji data), or whenever…

Xoshbin/asyar · 95 tokens

dev-environment

Reference for the Asyar monorepo structure, SDK workspace linking, lockfile discipline, CI workflows, and release flow. Use this skill whenever working on anything related to pnpm workspace setup, the asyar-sdk dependency, lockfile errors, SDK or launcher version bumps, CI configuration, release workflow, or questions…

Xoshbin/asyar · 113 tokens

review-ipc

Audit IPC message contracts between extensions and the Asyar host. Use when adding a new SDK service, adding a new proxy method, changing a postMessage type string, or reviewing permission gate coverage.

Xoshbin/asyar · 43 tokens