sqlite-schema-review

Reviews SQLite schema and migration changes by verifying semantics claims against a scratch database.

2|Updated Jul 18, 2026
One-click install
npx skills add https://github.com/Arasz/ai-badger --skill sqlite-schema-review-arasz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlite-schema-review
Source: https://github.com/Arasz/ai-badger/tree/main/features/common/skills/sqlite-schema-review
Command: npx skills add https://github.com/Arasz/ai-badger --skill sqlite-schema-review-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? SQLite migration reviews routinely accept incorrect semantics claims from plans, PRs, and docs — such as bare ON CONFLICT DO NOTHING supposedly swallowing FK/CHECK errors, or last_insert_rowid staying valid after a swallowed insert — leading to broken migrations, wrong-row reads, and bricked databases. This Skill forces every semantics claim to be verified against a scratch database before approval. ## Core Features & Use Cases - Empirically verified semantics catalog: Nine scratch-DB-confirmed rules covering ON CONFLICT DO NOTHING scope, last_insert_rowid staleness, trigger fire-time failures, UNIQUE-index NULL semantics, expression/partial index conflict targets, and NOT IN dedupe safety. - Migration review checklist: Structured checks for migration placement vs early returns, trigger cleanup on dedupe DELETEs, global vs bucket-scoped re-reads, first-open concurrency with BEGIN IMMEDIATE, FK pragma interplay, and tombstone reasoning. - Scratch-verification recipe: A 5-minute procedure for spinning up a throwaway SQLite database to test any semantics claim before trusting it. - Use Case: A PR adds CREATE UNIQUE INDEX IF NOT EXISTS plus a dedupe migration to a storage layer. Use this Skill to catch that IF NOT EXISTS still throws on a violating table, that the dedupe DELETE must run on open rather than in raw DDL, and that the post-DO-NOTHING re-read is scoped too narrowly — then report numbered MUST-FIX findings with file:line evidence. ## Quick Start Review the SQLite migration and schema changes in this pull request, verifying every semantics claim against a scratch database and reporting numbered findings with severities.

Frequently Asked Questions about sqlite-schema-review

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review SQLite migration changes safely?

Review SQLite migrations by verifying every semantics claim against a scratch database rather than trusting the plan, PR, or docs. Check migration placement against early returns, trigger cleanup on dedupe DELETEs, and concurrency handling with BEGIN IMMEDIATE and busy_timeout.

Does ON CONFLICT DO NOTHING swallow all SQLite errors?

No, bare ON CONFLICT DO NOTHING only swallows UNIQUE and PRIMARY KEY conflicts. NOT NULL, CHECK, and foreign key violations still throw IntegrityError even with DO NOTHING, so real errors surface loudly.

Why does last_insert_rowid return the wrong row after INSERT OR IGNORE?

last_insert_rowid goes stale after a swallowed insert, returning the previous successful rowid on that connection or 0 on a fresh one. Switch insert-then-read patterns to a business-key re-read once DO NOTHING is added.

Does CREATE UNIQUE INDEX IF NOT EXISTS skip violating tables?

No, IF NOT EXISTS only skips when the index already exists; it still throws on a table containing duplicate rows. Deduplication must run on open before index creation, never in raw DDL, or a violating database bricks on every open.

How do SQLite UNIQUE indexes treat NULL values?

UNIQUE indexes treat NULLs as distinct, while GROUP BY treats NULLs as equal. A dedupe-then-index migration deletes NULL-key duplicates but the new index admits future NULL-key duplicates unless no insert path produces NULL keys.

Why does a SQLite trigger fail only at fire time?

CREATE TRIGGER does not validate column references at creation time, so a body referencing a missing column is created successfully and fails when fired. A migration DELETE firing such a trigger rolls back the entire migration.