generate-data-model
БесплатноБез исполняемых скриптовНе проверенUse to design the data model AND generate the actual forward + rollback migrations in one pass — shippable SQL, not a plan. Greenfield-first: reads PRD §4…
от genkovich★ 17 звёзд на GitHubОб этом скилле
Skill: generate-data-model
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.
Why this differs from a pure mirror
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.)
Owner
Backend Lead.
When to use
- "data model for
", "schema for ", "generate migrations for ". - After PRD + sad.md §6.4 (ER stub) + at least the critical sequences exist. Run after
complete-sequence-diagramsso the skill knows every table the runtime needs. /sdlc:generate-data-model <slug>— explicit invocation./sdlc:generate-data-model <slug> --mode brownfield— analyze existingmigrations/and propose a delta./sdlc:generate-data-model <slug> --drift-only— just compare the domain layer against the current schema; no generation.- Skip if
data-model.mdexists AND every entity in it has a corresponding pair of staged migration files.
Inputs
<slug>— same as for PRD / SAD.- Gate (hard refuse if missing):
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.- If either is missing: STOP, suggest
sdlc:write-prd <slug>orsdlc:architecture-design <slug>.
- Optional: the sequence diagrams in
sad.md §6— eachwrites/reads <entity>note is an index candidate (one index per query, justified). - Optional: the domain layer (
internal/modules/<...>/domain/*or stack-equivalent) — drift detection only. - Convention source (borrowed mechanism):
docs/architecture-map.md(fromsdlc:map-architecture) — read its §Migrations / persistence section to learn where the livemigrations/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,explorerstill 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.
Defaults (the opinionated, course-owned set — preserved, NOT detected)
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 inser |
Установить generate-data-model в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл generate-data-model?
Use to design the data model AND generate the actual forward + rollback migrations in one pass — shippable SQL, not a plan. Greenfield-first: reads PRD §4 (entity acceptance criteria) + sad.md §6.4 ER + the sequence diagrams, then writes docs/features/{slug}/data-model.md plus paired *.up.sql / *.down.sql migrations STAGED under docs/features/{slug}/migrations/ (NOT the live migrations/ tree — implement-tasks promotes them when the feature is actually built) and an audit report. Brownfield delta via --mode brownfield; drift-only via --drift-only. Keeps the course's opinionated DB conventions (created_at-only audit, hard delete, no CHECK/TRIGGER/business-default, SQL-first, timestamp-named idempotent migrations, "DB as dumb storage"). Hard-refuse if PRD.md or sad.md is missing. Triggers on "data model for {slug}", "schema for {slug}", "generate migrations for {slug}", "DB design + migration", "/sdlc:generate-data-model {slug}", "модель даних для {slug}", "схема для {slug}", "згенеруй міграції". Triggers: /sdlc:generate-data-model {slug}. Output: docs/features/{slug}/data-model.md + staged docs/features/{slug}/migrations/.
Как установить скилл generate-data-model?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл generate-data-model запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic