From c10e169806f1aeea268d01da7e94cf62800ca895 Mon Sep 17 00:00:00 2001 From: Parfii-bot Date: Tue, 21 Apr 2026 20:46:32 +0800 Subject: [PATCH] feat(skills): /schema-design 5-phase pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hub-and-spoke skill that converts "I need a database for app X" into a designed relational schema + first migration + optional seed. Pipeline (5 phases, 9 AskUserQuestion calls total, pure-click after intake): - Phase 1 — batched DB/ORM/scale/style/migration-control click - Phase 2 — entity list + relations matrix (auto-junction tables) - Phase 3 — generate DDL with indexes, FKs, constraints; review/revise loop - Phase 4 — scaffold migrations/ + first timestamped migration + kei-migrate wiring - Phase 5 — optional seed (smoke / rich / test fixtures / skip) Cross-refs the five db-* blocks + the kei-migrate Rust primitive added in commits f884891 and df85792 on this branch. Emits ENV-VAR NAMES only for DATABASE_URL (RULE 0.8 secrets SSoT). Every file ≤ 121 LOC. --- skills/schema-design/SKILL.md | 115 ++++++++++++++++++++ skills/schema-design/phase-1-intake.md | 92 ++++++++++++++++ skills/schema-design/phase-2-entities.md | 82 ++++++++++++++ skills/schema-design/phase-3-schema.md | 115 ++++++++++++++++++++ skills/schema-design/phase-4-migrations.md | 121 +++++++++++++++++++++ skills/schema-design/phase-5-seed.md | 92 ++++++++++++++++ 6 files changed, 617 insertions(+) create mode 100644 skills/schema-design/SKILL.md create mode 100644 skills/schema-design/phase-1-intake.md create mode 100644 skills/schema-design/phase-2-entities.md create mode 100644 skills/schema-design/phase-3-schema.md create mode 100644 skills/schema-design/phase-4-migrations.md create mode 100644 skills/schema-design/phase-5-seed.md diff --git a/skills/schema-design/SKILL.md b/skills/schema-design/SKILL.md new file mode 100644 index 0000000..6957495 --- /dev/null +++ b/skills/schema-design/SKILL.md @@ -0,0 +1,115 @@ +--- +name: schema-design +description: Hub-and-spoke pipeline that converts "I need a database for app X" into a designed relational schema, a generated first migration, and optional seed/fixture data — via pure-click decisions across five phases. Emits SQL DDL, a kei-migrate-shaped migrations directory, and a library/ORM pick; never writes production secrets. +argument-hint: +--- + +# Schema-Design — Relational Schema & Migration Pipeline (index) + +You are converting "I need a database for app X" into a concrete, reviewable +design: chosen DB + ORM, entity list + relations, SQL DDL with indexes and +FKs, a scaffolded migrations directory with the first migration, and (if +asked) seed data for tests and dev. Every decision is a click; the only +typed inputs are the one-line app description in Phase 1 and the entity +list in Phase 2. + +This skill does NOT run migrations or touch production. It produces files +under `db/schema.sql`, `migrations/_init.sql` (+ `.down.sql`), and +optionally `db/seed.sql`. Applying them is a separate command (`kei-migrate +up`), owned by the project's code-implementer. + +The skill reads the five database blocks heavily — every phase references +at least one of them: + +- `_blocks/db-postgres.md` — PG 17 patterns, indexing, pooling. +- `_blocks/db-sqlite.md` — single-node / edge pragmas. +- `_blocks/db-sqlx.md` — Rust query + migration flow. +- `_blocks/db-drizzle.md` — TS schema-first ORM. +- `_blocks/db-migration-hygiene.md` — universal up/down + checksum rules. + +Primitive used for scaffolding: `_primitives/_rust/kei-migrate` (universal +Postgres / SQLite / MySQL migration runner — create + up + down + status). + +--- + +## Pipeline overview (5 phases, ≥5 AskUserQuestion calls) + +| Phase | File | Purpose | AskUserQuestion | +|---|---|---|---| +| 1 | [phase-1-intake.md](phase-1-intake.md) | DB, ORM, scale, style, migration control | 5× (batched) | +| 2 | [phase-2-entities.md](phase-2-entities.md) | Entity list + relations matrix | 1× | +| 3 | [phase-3-schema.md](phase-3-schema.md) | Generate DDL + indexes + FKs + constraints; review/revise | 1× | +| 4 | [phase-4-migrations.md](phase-4-migrations.md) | Scaffold `migrations/` + first migration + kei-migrate wiring | 1× | +| 5 | [phase-5-seed.md](phase-5-seed.md) | Optional seed + test fixtures | 1× | + +Minimum AskUserQuestion count across a full session: **9** (5 in Phase 1 + +1 each in Phases 2–5). Exceeds the ≥5 hub-and-spoke contract. + +--- + +## Variables the pipeline produces + +| Name | Set in | Meaning | +|---|---|---| +| `INTAKE` | Phase 1 | one-paragraph app description (verbatim) | +| `DB` | Phase 1 | Postgres / SQLite / MySQL | +| `ORM` | Phase 1 | none (raw SQL) / Drizzle / SQLx / Prisma / SQLAlchemy | +| `SCALE` | Phase 1 | solo-prototype / team-dev / production-multi-replica | +| `STYLE` | Phase 1 | schema-first (SQL → types) / code-first (types → SQL) | +| `MIGCTL` | Phase 1 | manual / auto-on-deploy / hybrid (manual prod, auto dev) | +| `ENTITIES` | Phase 2 | list of entities + fields + relations matrix | +| `DDL` | Phase 3 | generated SQL (tables, indexes, FKs, constraints) | +| `MIGDIR` | Phase 4 | path of migrations dir + first migration filenames | +| `SEED` | Phase 5 | seed-data plan (or "skipped") | + +--- + +## Final report (emit after Phase 5) + +``` +=== SCHEMA-DESIGN REPORT === +App: ... +DB / ORM: + (style: