Best for
- Use when adding synced tables, changing synced columns, or planning CloudSync-safe migrations.
fastrepl/anarlog/.agents/skills/sqlite-schema-design/SKILL.md
Design or review schemas for `crates/cloudsync` using SQLite Sync constraints, not generic SQLite advice. Use when adding synced tables, changing synced columns, or planning CloudSync-safe migrations.
Decision brief
Design tables that behave correctly under SQLite Sync's CRDT replication model.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/fastrepl/anarlog --skill ".agents/skills/sqlite-schema-design"Inspect the Agent Skill "sqlite-schema-design" from https://github.com/fastrepl/anarlog/blob/760f9e44dbf8ae5b0172d69da0e8abd3204198df/.agents/skills/sqlite-schema-design/SKILL.md at commit 760f9e44dbf8ae5b0172d69da0e8abd3204198df. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Before proposing DDL, classify the table:
When reviewing a CloudSync schema, ask:
Design tables that behave correctly under SQLite Sync's CRDT replication model.
Before proposing DDL, classify the table:
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.
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 91/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 9,176 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Design tables that behave correctly under SQLite Sync's CRDT replication model.
This skill is specifically for CloudSync-backed schemas:
cloudsync_init(...)cloudsync_enable(...)cloudsync_uuid()cloudsync_begin_alter(...) and cloudsync_commit_alter(...)Do not treat this as ordinary SQLite schema design. SQLite Sync imposes extra rules around keys, defaults, foreign keys, and schema evolution.
Before proposing DDL, classify the table:
Only apply this skill to synced tables or to tables that may become synced soon.
For synced tables:
TEXT PRIMARY KEY NOT NULLcloudsync_uuid()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.
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.
For synced tables:
NOT NULL column should have a meaningful DEFAULTGood:
title TEXT NOT NULL DEFAULT ''
archived INTEGER NOT NULL DEFAULT 0
sort_order INTEGER NOT NULL DEFAULT 0
Bad:
title TEXT NOT NULL
archived INTEGER NOT NULL
without defaults on a synced table.
The getting-started docs require the local synced database and the SQLite Cloud database to share the same schema.
When designing or reviewing a schema:
If a field is only needed locally, it likely belongs in a separate non-synced table.
SQLite Sync best practices explicitly warn that foreign keys can interact poorly with CRDT replication.
Use foreign keys on synced tables only when the integrity guarantee is worth the operational cost.
If you keep them:
DEFAULT, that default must be NULL or reference an actually valid parent row'root' unless that parent row is guaranteed to exist everywherePrefer ownership patterns that tolerate out-of-order arrival between related rows.
SQLite Sync best practices advise minimizing triggers because they make replicated writes harder to reason about.
For synced tables:
If a trigger is unavoidable, review it as part of the replication design, not as a local SQLite convenience.
The introduction docs emphasize row-level security and multi-tenant access patterns.
That changes uniqueness design:
Prefer:
UNIQUE (workspace_id, slug)
over:
slug TEXT UNIQUE
when data is tenant-scoped.
Schema changes for synced databases are not ordinary ALTER TABLE work. Use:
cloudsync_begin_alter('table_name')cloudsync_commit_alter('table_name')Design implications:
When reviewing a migration plan, reject any synced-table schema change that skips the CloudSync alter flow.
SQLite Sync already exposes its own metadata and helpers:
cloudsync_siteid()cloudsync_db_version()cloudsync_version()cloudsync_is_enabled()Do not duplicate these concepts as app-managed columns on synced tables unless there is a very specific product requirement.
The API set includes network setup and sync transport functions such as:
cloudsync_network_init(...)cloudsync_network_set_token(...)cloudsync_network_set_apikey(...)cloudsync_network_sync(...)cloudsync_network_has_unsent_changes()These matter operationally, but they are not substitutes for sound schema design.
Do not design tables that assume:
Assume offline creation, delayed delivery, retries, and independent merges.
Unless the user explicitly asks otherwise:
TEXT PRIMARY KEY NOT NULLcloudsync_uuid()STRICT tablesDEFAULT on every non-key NOT NULL columnWhen reviewing a CloudSync schema, ask:
cloudsync_begin_alter / cloudsync_commit_alter?Frequently asked questions
Design tables that behave correctly under SQLite Sync's CRDT replication model.
The source record exposes this install command: npx skills add https://github.com/fastrepl/anarlog --skill ".agents/skills/sqlite-schema-design". Inspect the command and pinned source before running it.
Alternatives
prowler-cloud/prowler
PostgreSQL indexing best practices for Prowler: index design, partial indexes, partitioned table indexing, EXPLAIN ANALYZE validation, concurrent operations, monitoring, and maintenance. Trigger: When creating or modifying PostgreSQL indexes, analyzing query performance with EXPLAIN, debugging slow queries, reviewing index usage statistics, reindexing, dropping indexes, or working with partitioned table indexes. Also trigger when discussing index strategies, partial indexes, or index maintenance
oaustegard/claude-skills
Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre
HKUDS/Vibe-Trading
Create, modify, and optimize quantitative trading strategies, then backtest and evaluate them.
vasilyu1983/AI-Agents-public
Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.