Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

database-engineer

БесплатноБез исполняемых скриптовНе проверен

SQLite database expertise for migrations, multi-tenant patterns, transactional safety, FTS5 virtual tables, and schema evolution. Use this skill for ANY work…

lza6от lza6★ 19 звёзд на GitHub

Об этом скилле

Database Engineer

SQLite-domain specialist for migrations and data integrity.

Core Mission

Migrations are integration code. Most "data" bugs aren't algorithmic — they're contract bugs between schema, importer, and verifier. This skill exists because P4 (the VNX one-shot consolidation migrator) consumed 5 fix-forward rounds before converging, and the bugs were almost entirely SQLite/multi-tenant gotchas a generalist would miss.

The specific recurring failure-modes are catalogued in references/bug-taxonomy.md with concrete VNX examples. Read it before writing any migration code.

When to Use

  • Writing or editing files under schemas/migrations/
  • Touching _import_table, _compare_counts, or any code that ATTACHes / SELECTs / INSERTs across tenant boundaries
  • Designing UNIQUE constraints or primary keys for any table that will hold multi-project rows
  • Adding JOIN or correlated-subquery code that scans tables ≥10k rows
  • Debugging a migration that "completed" but produced wrong row counts
  • Operator complains "stuck at 100% CPU for hours" — likely O(N×M) (see references/sqlite-fts5-gotchas.md)
  • Any code that calls INSERT OR IGNORE or INSERT OR REPLACE

STEP 0 — Foundational Check (Mandatory)

BEFORE proposing any design, fix, or implementation:

  1. Consult relevant ADRs in docs/governance/decisions/. Special attention to:

    • ADR-005 (NDJSON audit ledger as primary observability)
    • ADR-007 (multi-tenant project_id stamping; composite keys for central state DBs)
    • ADR-010 (subprocess adapter as canonical Claude routing) List any ADR that applies to the task and how it constrains your solution.
  2. Consult relevant memory in ~/.claude/projects/<your-project>/memory/MEMORY.md — particularly entries about past architectural incidents.

  3. Check P4-style incident docs in claudedocs/ for analogous failures (e.g., 2026-05-09-p4-migration-architecture-lessons.md for multi-tenant migration patterns).

  4. State your foundational read aloud at the start of your response. Example: "ADR-007 applies: new tabel X needs composite PK over project_id. Per P4 §4.2, single-column UNIQUE is a smell. Memory adr-007-multitenant-composite-keys confirms."

Skipping STEP 0 is a process violation, not a shortcut. The FUT-1 chain (2026-05-28) burned 6 codex rounds because ADR-007 was not consulted at design time.

Decision Protocol

Before writing migration code, walk through references/migration-defense-checklist.md (loaded explicitly when needed; checklist is reproduced inline below for fast access).

When asked to fix a "data missing" or "data wrong" bug, the first investigative step is EXPLAIN QUERY PLAN on the failing query and .indexes on the related tables. Two-thirds of the bugs in the P4 history were diagnosable this way in under five minutes once anyone thought to look.

1. SQLite Mechanics

Journal modes

SQLite supports two journal modes operators commonly hit: DELETE (rollback journal as a sibling file <db>-journal) and WAL (<db>-wal + <db>-shm). Never copy a DB file mid-write without one of:

  • sqlite3.Connection.backup(dest) — handles both modes correctly, locks briefly, copies all pages including in-flight ones
  • BEGIN IMMEDIATE; .dump | sqlite3 newfile; COMMIT; — slower but produces SQL text
  • For WAL specifically: PRAGMA wal_checkpoint(TRUNCATE) flushes the WAL into the base file, then a normal file copy is consistent

shutil.copy2(src, dst) of a WAL DB is not safe: committed state may live in -wal and the copy will be partial. R2 of P4 hit this; fixed by switching to Connection.backup().

Hot journal recovery

If a writer process is killed mid-transaction, the journal/WAL file remains. The next process to open the DB reads it and replays/rolls back. This is automatic but has two implications:

  1. After SIGTERM/SIGKILL of a migrator, open the DB once (e.g. sqlite3 <db> "SELECT 1;") before inspecting it. Otherwise the file size you see includes the in-flight transaction's pages and reads can be confusing.
  2. Pre-snapshot files (<db>.presnap.*) created by _snapshot_central are belt-and-suspenders on top of journal recovery, useful when the rollback semantics need to span multiple migrations rather than a single transaction. Don't delete them while a migrator is alive.

FTS5 virtual tables

FTS5 is a separate physical store with its own segments. Schema-altering it usually means drop + recreate + re-INSERT-from-temp-table. There is no ALTER TABLE … ADD COLUMN for FTS5 vtabs; column changes require rebuild. See references/sqlite-fts5-gotchas.md for the rebuild pattern and the perf trap that almost shipped in P4 round 4.

ATTACH DATABASE for multi-source migrations

Read-only attach uses a URI:

con.execute("ATTACH DATABASE ? AS src", (f"file:{src_path}?mode=ro",))

The mode=ro flag is critical — without it, the attach opens a write connection that briefly modifies the so

Полный SKILL.md на GitHub

Установить database-engineer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Write
Edit
MultiEdit
Bash
Grep
Glob

Вложенные файлы

references/bug-taxonomy.mdreferences/multi-tenant-patterns.mdreferences/p4-postmortem-summary.mdreferences/sqlite-fts5-gotchas.md

FAQ

Что делает скилл database-engineer?

SQLite database expertise for migrations, multi-tenant patterns, transactional safety, FTS5 virtual tables, and schema evolution. Use this skill for ANY work involving schema changes, data migrations, INSERT/UPSERT semantics, FTS5 rebuilds, transaction rollback design, multi-tenant data isolation, or SQLite performance tuning. Triggers include: writing migration SQL, modifying `_import_table`-style importers, designing UNIQUE/PK constraints, adding indexes for JOINs, debugging "rows missing" / "wrong count" / "stuck for hours" symptoms in SQLite-backed systems.

Как установить скилл database-engineer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл database-engineer запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить database-engineer с