Designs a data model and generates paired forward/rollback SQL migrations in one pass, staged under docs/features/{slug}/migrations/ for later promotion. Greenfield-first with brownfield and drift-only modes.
Ships in sdlc. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
End-to-end runner for the persistence cut: data model + migrations + drift check in one pass. Greenfield-first by default; brownfield delta as --mode brownfield. Output is shippable — full .up.sql + .down.sql, not a plan — but staged under docs/features/<slug>/migrations/, never written into the live migrations/ tree. implement-tasks promotes the staged pair into the repo's live migrations/ (with the real timestamp / sequence value the convention assigns at promote-time) only when the feature is actually being built. This is deliberate: generate-data-model is a design stage several steps before implement-tasks, so a stray migrate up (a teammate's loop, CI, a deploy) must not be able to apply a half-designed schema to a real database.
Unlike the rest of the SDLC toolkit (which mirrors the upstream pipeline's content under course names), generate-data-model is a deliberate partial mirror. It keeps the course's opinionated DB defaults — created_at-only audit columns, hard delete, no CHECK / TRIGGER / business DEFAULT, SQL-first migrations, timestamp-prefixed idempotent filenames, "DB as dumb storage" — and does not adopt the upstream stack-agnostic "detect-and-follow the repo's DB philosophy" stance. From the upstream pipeline it borrows only three mechanisms: (1) staged migrations written to the feature folder and promoted later by implement-tasks; (2) a drift-check that keeps the data model in sync with PRD + SAD; (3) reading docs/architecture-map.md as the convention source for where persistence + migrations live. (This divergence is also recorded in the toolkit README / CHANGELOG.)
Backend Lead.
complete-sequence-diagrams so the skill knows every table the runtime needs./sdlc:generate-data-model <slug> — explicit invocation./sdlc:generate-data-model <slug> --mode brownfield — analyze existing migrations/ and propose a delta./sdlc:generate-data-model <slug> --drift-only — just compare the domain layer against the current schema; no generation.data-model.md exists AND every entity in it has a corresponding pair of staged migration files.<slug> — same as for PRD / SAD.docs/features/<slug>/PRD.md — entities live in §4 user-story acceptance criteria.docs/features/<slug>/sad.md — §6.4 ER section provides the initial relationships.sdlc:write-prd <slug> or sdlc:architecture-design <slug>.sad.md §6 — each writes/reads <entity> note is an index candidate (one index per query, justified).internal/modules/<...>/domain/* or stack-equivalent) — drift detection only.docs/architecture-map.md (from sdlc:map-architecture) — read its §Migrations / persistence section to learn where the live migrations/ tree lives and which migration tool the repo uses, instead of re-scanning from scratch. The map gives module layout + migration location; the course's DB defaults below are NOT overridden by it. For drift detection specifically, explorer still reads the actual domain layer (the map gives layout; drift needs the real struct/field source). Re-scan only if the map is absent or stale.These defaults are baked into the skill and into the baseline .claude/rules/migrations.md the skill writes on first run. They are course-opinionated and intentional — the skill does NOT defer to a repo's differing DB philosophy. It flags any divergence from the repo's existing convention in the report so the team can decide, but the defaults below are the house style this skill applies.
| Topic | Default | Why |
|---|---|---|
| Migration filename | YYYYMMDDhhmmss_<verb>_<entity>.up.sql (timestamp-prefixed) | Two parallel feature branches won't collide on 000034_. |
| Idempotency in DDL | CREATE TABLE IF NOT EXISTS, CREATE INDEX IF NOT EXISTS, ON CONFLICT DO NOTHING for seeds | Re-running a partially-applied migration does not error. |
| Audit columns | created_at TIMESTAMPTZ NOT NULL DEFAULT now() only — no updated_at | Immutable-first: updated_at is opt-in per entity, only when the entity is genuinely mutable AND the PRD requires it. Otherwise changes go through an audit table or event log. |
| Delete strategy | Hard delete (+ audit table if business requires history) | No deleted_at, no status-column for delete. DB stays simple; history is a separate concern. |
| PK | UUID v7, generated app-side | Cursor pagination, no insert-sequence contention. |
| Naming | plural snake_case (users, goal_progress) | Postgres community standard. |
| Indexes | One per real query (from the sequences). Existing-table → CREATE INDEX CONCURRENTLY always. | Each index has a write cost; CONCURRENTLY avoids long write locks. |
| Migration authoring | SQL-first — raw .up.sql / .down.sql, no ORM / no migration DSL | The migration is the contract; it reads as plain SQL. |
| Breaking changes | Auto-decompose to 3-step expand → backfill → contract | Zero-downtime by default. |
| New NOT NULL on existing table | Auto-decompose: add nullable → backfill → set NOT NULL | Default zero-downtime path. |
| String columns | VARCHAR(N) bounded; TEXT only for URLs / long descriptions | Schema-as-documentation; bounds drive validation. |
| JSONB | Only for semantically opaque payload (settings, metadata, polymorphic block.payload) | Structured fields → first-class columns. |
| Forbidden | CHECK, TRIGGER, DEFAULT '<business value>', sequence-as-PK | "DB as dumb storage" — business logic lives in code, only UNIQUE / NOT NULL / FK / indexes / DEFAULT now() for timestamps. |
| Multi-DB (replica, sharding) | Out of scope | Single-DB only. |
| Partitioning, materialized views | Out of scope | Perf optimization, not contract. |
Prereq check (hard). test -f docs/features/<slug>/PRD.md && test -f docs/features/<slug>/sad.md → exit ≠ 0 = refuse with a pointer to which prereq is missing.
Rules bootstrap. If .claude/rules/migrations.md is absent in the repo root, copy ./templates/rules-migrations-baseline.md → .claude/rules/migrations.md and tell the user «I wrote a baseline rules file; edit it if your team disagrees with any default.» Reporting this bootstrap is mandatory.
Read the architecture map for migration location (borrowed mechanism — read-only). Read docs/architecture-map.md (from sdlc:map-architecture) first — its §Migrations / persistence section tells you where the live migrations/ tree lives and which migration tool the repo uses (e.g. golang-migrate's transaction-per-file wrapper). This is a promote-time hint for implement-tasks, not a license to write into the live tree here. The map also gives module layout, saving a re-scan. The course DB defaults above are NOT overridden by the map — if the repo's existing convention differs (e.g. it uses sequential filenames or updated_at), apply the course defaults and flag the divergence in the audit report so the team can decide. Re-scan with explorer only if the map is absent or stale.
Read prereqs in this order:
a. PRD §4 — extract entity candidates from acceptance criteria.
b. sad.md §6.4 — the initial ER stub (often <!-- TBD: relationships -->).
c. sad.md §6 sequences — each Note over API, DB: writes <table.column> becomes a query requirement → an index candidate.
d. (Optional) the domain layer (internal/modules/<...>/domain/* or stack-equivalent) — if present, build a struct-vs-DDL map for drift detection (the explorer agent reads the real source).
e. (Brownfield only) the live migrations/*.up.sql — parse the current schema offline (no live DB connection).
Aggregate roots. Ask the user (or infer from PRD acceptance criteria): which aggregate roots own what? Lessons aggregate ContentBlocks; Tenant aggregates QuotaConfig. Without explicit aggregates the FK graph turns into a hairball.
PK strategy. UUID v7 app-side by default (course default). Confirm with the user only if a PRD acceptance criterion demands a different PK (e.g. a lookup slug as PK).
Columns + constraints per entity, applying the course defaults:
VARCHAR(N) for bounded strings (choose N from PRD validation, e.g. title: maxLength: 200 → VARCHAR(200)); TEXT only for long descriptions / URLs.JSONB only for opaque payloads (one-line justification in the Notes column).created_at TIMESTAMPTZ NOT NULL DEFAULT now(). No updated_at unless the entity is genuinely mutable AND the PRD requires it (surface this explicitly — never add updated_at silently).CHECK, no TRIGGER, no business DEFAULT — UNIQUE / NOT NULL / FK / DEFAULT now() only.<!-- TBD --> where honestly undecided.Indexes per query. Each sequence note writes/reads <table.column> becomes one index candidate; discard candidates with no concrete query; print a "Query it serves" justification column. No "just in case" indexes.
Write docs/features/<slug>/data-model.md from ./templates/data-model.md:
Query it serves filled.
Validate the erDiagram per ../_shared/mermaid-check.md (render-parse with mmdc if available, else the structural lint — valid cardinality glyphs + type name attribute lines; fix before continuing — never commit a broken diagram).Generate migration files — STAGED in the feature folder, never the live tree (borrowed mechanism). Write the pairs into docs/features/<slug>/migrations/ with a feature-local timestamp-prefixed name (<YYYYMMDDhhmmss>_create_<entity>.up.sql + matching .down.sql) that preserves intra-feature order. The SQL is full and shippable and follows every course default (SQL-first, idempotent, created_at-only, hard delete, no CHECK/TRIGGER); only the location differs from a live migration. Never write into the repo's live migrations/ tree here. implement-tasks promotes these staged pairs into the live migrations/ (re-stamping the timestamp at promote-time so the live sequence stays correct, in feature-local order) when it runs the migration task. The SQL content rules are unchanged:
<entity> .up.sql + .down.sql per entity (or per small aggregate). CREATE TABLE IF NOT EXISTS / CREATE INDEX IF NOT EXISTS everywhere; ON CONFLICT DO NOTHING on seeds.--mode brownfield): diff vs the parsed existing schema; produce ALTERs only.CREATE INDEX: use CONCURRENTLY AND warn that the file must contain only that one statement if your migration tool wraps each file in a transaction (e.g. golang-migrate).Seeds (3 buckets).
<timestamp>_bootstrap_<thing>.up.sql, deterministic hardcoded UUID v7 (e.g. 00000000-0000-7000-8000-000000000001).<timestamp>_seed_<table>.up.sql with INSERT ... ON CONFLICT DO NOTHING (idempotent — re-runs are safe).migrations/. Generate them in the form the repo uses (factory functions in internal/testfixtures/<entity> or stack-equivalent), documented under "Test fixtures" in data-model.md.[email protected], user-<uuid>@example.test, Test User.Drift detection (always; --drift-only short-circuits to here) — borrowed mechanism, keeping the model in sync with PRD + SAD. Two checks:
field-without-column / column-without-field / type-mismatch / nullability-mismatch; auto-propose fix migrations under docs/features/<slug>/migrations/_drift/ (staged, for the user to review — same staging discipline as the main migrations).data-model.md against PRD §4 entity acceptance criteria + sad.md §6.4 ER — flag any entity/relationship in the PRD/SAD with no table, and any table with no PRD/SAD origin. Record both in the audit report.Breaking changes — 3-step decomposition. If a rename / drop / re-type is described:
backfill-<column>.md companion).Self-check (4 mandatory, course-owned). For every staged file:
plural snake_case tables, <timestamp>_<verb>_<entity> filenames.REFERENCES other_table(id) has a CREATE INDEX on the FK column.CHECK (, CREATE TRIGGER, DEFAULT ' followed by a non-now() business literal. Fail with line numbers.
Any failure → fix or surface to the user (no silent commit).Audit report docs/features/<slug>/_audit/data-model-<date>.md:
docs/features/<slug>/migrations/<timestamp>_* paths) + data-model.md. State plainly: «migrations are staged — not yet in the live migrations/ tree; implement-tasks promotes them (re-stamping the timestamp at promote-time)».000003_* naming; I wrote timestamps per the course default — see the Defaults table» or «repo has updated_at elsewhere; this feature is immutable so I omitted it»)._drift/*.sql proposals) + model-vs-spec.<!-- TBD --> in data-model.md with file:line.Propose commit + handoff. Commit feat(<slug>): data-model.md + staged migrations. Then emit the stage-handoff block per ../_shared/handoff.md — What I did (the design doc + the staged migration pairs, plus the staged-not-live note) + Review (docs/features/<slug>/data-model.md, staged docs/features/<slug>/migrations/) + Run next (/clear, then /sdlc:api-forge <slug>).
updated_at (overriding the immutable-first default)? Surfacing this is mandatory; the skill never adds updated_at silently.data-model.md exists with ER + every entity + every index carrying a query justification; the erDiagram parses..up.sql + .down.sql pair exists under docs/features/<slug>/migrations/ (staged, timestamp-prefixed names) — nothing was written into the live migrations/ tree (that's implement-tasks's promotion step). The SQL follows the course defaults (SQL-first, idempotent, created_at-only, hard delete, no CHECK/TRIGGER/business-DEFAULT)._drift/*.sql, plus model-vs-spec) if drift was detected.migrations/ tree at design time. That drops a half-designed, runnable schema where a stray migrate up (CI, a teammate's loop, a deploy) can apply it before the feature is built or reviewed — and grabs a sequence slot early. Stage under docs/features/<slug>/migrations/; implement-tasks promotes it (re-stamped) when the code that needs it is actually being written.DEFAULT 'pending'). Only DEFAULT now() for timestamps; the rest in app code.VARCHAR(N).updated_at silently. Immutable-first; updated_at is opt-in per entity, surfaced and justified.example.test.000034_. Use timestamps..up.sql / .down.sql is the contract.rules/migrations.md and forgetting to tell the user. Report it when it happens.→ ./templates/data-model.md — output structure for the design doc.
→ ./templates/rules-migrations-baseline.md — baseline .claude/rules/migrations.md copied at step 2 when missing.
→ ../_shared/mermaid-check.md — validate the erDiagram after writing it.
→ ../_shared/handoff.md — the stage-handoff block emitted at the end (step 16).
User: "data model for course-lesson-mvp"
Skill behavior:
test -f docs/features/course-lesson-mvp/PRD.md && test -f docs/features/course-lesson-mvp/sad.md→ OK..claude/rules/migrations.mdmissing → bootstrapped from baseline. Reported to user.- Reads
docs/architecture-map.md§Migrations → live tree isbeer-lms-api/migrations/, tool is golang-migrate (transaction-per-file). Records this as a promote-time hint; does NOT write there.- Reads PRD §4 (entities: Lesson, ContentBlock, MediaBlob, AuditEvent), sad.md §6.4 (ER stub: Lesson ||--o{ ContentBlock), §6 sequences (5 flows — index on
lessons.course_idfor listLessons; oncontent_blocks.lesson_idfor getLesson with blocks).- Aggregate roots: Lesson aggregates ContentBlock; MediaBlob is referenced (signed URL in
block.payload).- PK: UUID v7 app-side.
- Types:
title VARCHAR(200)(from PRD ACmaxLength: 200),slug VARCHAR(120) UNIQUE(course_id, slug),status VARCHAR(32)(enum-in-app),block.payload JSONB(polymorphic — ADR-0001),published_at TIMESTAMPTZ NULL, allcreated_at TIMESTAMPTZ NOT NULL DEFAULT now(). Noupdated_at. NoCHECK/TRIGGER.- Indexes:
idx_lessons_course_id(listLessons),idx_blocks_lesson_id(getLesson),idx_lessons_published_per_course WHERE status='published'(partial — listPublishedLessons from US-4).- Writes
docs/features/course-lesson-mvp/data-model.md(ER + 3 entity tables + indexes table).erDiagramvalidated per mermaid-check.- Writes 4 staged migration pairs under
docs/features/course-lesson-mvp/migrations/:20260523120000_create_lessons.up.sql/.down.sql,20260523120001_create_content_blocks.{up,down}.sql,20260523120002_create_media_blobs.{up,down}.sql,20260523120003_create_audit_events.{up,down}.sql. All idempotent. Nothing written intobeer-lms-api/migrations/—implement-taskspromotes these later.- Seeds: none required. Test fixtures: writes
beer-lms-api/internal/testfixtures/lesson.gowithNewLesson,NewContentBlockfactories. PII guard satisfied.- Drift: domain structs not yet written → schema-vs-source skipped; model-vs-spec → all 4 PRD entities have a table, no orphan tables.
- No breaking changes (greenfield).
- Self-check: 4/4 pass — naming OK, every
.downreverses its.up, FK indexes present (idx_blocks_lesson_id), no forbidden features.- Audit report
_audit/data-model-2026-05-23.md: lists the staged migration paths; notes «staged, not live —implement-taskspromotes»; flags «timestamp naming differs from the repo's existing sequential000003_seed_admin.up.sql— course default, see Defaults table»; no drift; 1 TBD (block.payloadmarked<!-- TBD: lock with ADR-0001 -->).- Commit
feat(course-lesson-mvp): data-model.md + staged migrations; emits the stage-handoff block → next/sdlc:api-forge course-lesson-mvp.
What SKILL.md sets; muted values are Claude Code's defaults
inheritmediumThree short reads, in order
data-modeling, sql-migrations, sdlc, schema-design, database-conventions
/sdlc:generate-data-modelfrom sdlc
npx claudepluginhub genkovich/sdlc --plugin sdlc24 skills in this plugin
/api-forgeUse to derive the API contract for a feature — an OpenAPI 3.1 document at docs/features/{slug}/contracts/openapi.yaml plus a drift/sync report (api-sync-report.md with an explicit Verdict: PASS | PASS (with deferrals) | FAIL and a 5-point drift checklist), the right contract artifact per surface (events.md for async, cli.md for CLI, public-api.md for library/SDK), and — on the HTTP path, first run only — a baseline .claude/rules/openapi.md so later code follows the same API conventions. Triggers on "api for {slug}", "openapi for {slug}", "API contract for {slug}", "lock the interface for {slug}", "events for {slug}", "/sdlc:api-forge {slug}", "контракт API для {slug}", "OpenAPI для {slug}", "опиши ендпоінти". The contract is never hand-written: it is a derived function of data-model.md (typed fields + constraints), sad.md §6 sequence diagrams (error branches, async actors), and PRD.md acceptance criteria. Hard gate: docs/features/{slug}/PRD.md. data-model.md is recommended but optional — without it the skill runs in scenario B (PRD + sequences only) and fills unresolved_origins in the sync report. Renamed from define-api in v3.3.0; the legacy name is kept as a deprecation wrapper.
/architecture-designUse to produce a Software Architecture Document for a feature — Arc42 12 sections + C4 L1/L2 inline + ADRs spawned on a blast-radius gate — once PRD.md and CONTEXT.md exist. The feature's target surface(s) are chosen here (the first §4 decision → SAD frontmatter target_surfaces, read by every downstream stage). Drafts §1–§12 in-memory, batch-validates each section Socratically (4-state machine), spawns an ADR only when a decision crosses the blast-radius threshold (irreversible / multi-module / has legitimate alternatives), writes each resolved section + its ADRs atomically, then runs a clean-context critic before finalizing. Brownfield: reads docs/architecture-map.md (re-scans only if absent/stale). Triggers on "architecture for {slug}", "design architecture for {slug}", "SAD for {slug}", "arc42 for {slug}", "C4 context+container for {slug}", "/sdlc:architecture-design {slug}", "спроектуй архітектуру {slug}", "SAD для {slug}", "архітектурний документ {slug}". Hard-refuse if docs/features/{slug}/PRD.md is missing. Triggers: /sdlc:architecture-design {slug}. Output: docs/features/{slug}/sad.md + adr/NNNN-*.md./break-tasksUse to break a designed feature into atomic, ≤1-day tasks with a dependency graph, a per-task Definition of Done, and a machine-readable tasks.json that the implement-tasks engine consumes. Triggers on "task breakdown for {slug}", "break down tasks for {slug}", "tasks for {slug}", "plan the work for {slug}", "sprint plan for {feature}", "stage 13 for {slug}", "/sdlc:break-tasks {slug}". Reads PRD.md + sad.md + Accepted ADRs (+ data-model + openapi if present), writes docs/features/{slug}/tasks/{_epic,tracker,<task>}.md AND docs/features/{slug}/tasks/tasks.json. Tracker export to any issue tracker is optional and tool-neutral. Hard-refuses if PRD.md or sad.md or an Accepted ADR is missing. Stories LINK to upstream artefacts (PRD AC §, SAD §6, data-model, openapi), they do not duplicate them.
/clarify-prdUse to run an ambiguity sweep over a written PRD.md and close every under-specified point before glossary or architecture proceeds — so two engineers can't reasonably build different things from the same PRD. Triggers on "/sdlc:clarify-prd {slug}", "clarify {slug}", "find ambiguities in {slug}", "is the PRD ready", "sharpen the PRD", "прояснити PRD", "знайди неоднозначності {slug}", "чи готова специфікація". Re-reads the PRD, dispatches a clean-context devil's-advocate subagent to list where the PRD forks, then for each ambiguity runs AskUserQuestion to RESOLVE it (tighten §1/§5/§6 in place) or DEFER it (→ §8 Open questions with owner+due). Output: an updated docs/features/{slug}/PRD.md with every ambiguity resolved or deferred — none dangling. Hard-refuse if PRD.md is missing./classify-sizeUse to classify a feature into XS/S/M/L/XL and write docs/features/{slug}/.size so later skills know how much of each artifact to produce. Triggers on "classify size", "feature size", "is this XS or M for {slug}", "size {slug}", "/sdlc:classify-size {slug}", "класифікуй розмір {slug}", "який розмір фічі", "XS чи M". Asks four AskUserQuestion (PR count / time / new module-API-migration / breaking changes), maps to a size class via the shared size matrix, confirms with the user, and writes the one-line .size file. Syncs with PRD.md frontmatter feature_size: if present (warns on conflict). Output: docs/features/{slug}/.size + (opt.) PRD frontmatter update./complete-sequence-diagramsUse to add Mermaid sequenceDiagram blocks to the SAD's runtime view (sad.md §6) — one per critical flow, showing how a request moves between generic participants with happy + error paths. Triggers on "complete sequences for {slug}", "sequence diagram for {slug}", "draw the runtime flow", "add a sequence to the SAD", "/sdlc:complete-sequence-diagrams {slug}", "діаграми послідовності {slug}", "sequence для {slug}", "намалюй потік {slug}". Reads sad.md §5 for participants, drafts each flow from templates/seq-flow.md with generic participants, walks them Socratically one flow at a time, writes confirmed blocks into sad.md §6 — they inform data-model indexes downstream — and closes with the US/AC → flow coverage table written as the last block of §6 (`### Coverage: US/AC → flows`). Hard-refuse if sad.md is missing → run /sdlc:architecture-design first. Single-flow mode: /sdlc:complete-sequence-diagrams {slug} --flow {name}.Other plugins' skills for the same job