database-schema-designer
БесплатноЗапускает вложенные скриптыНе проверенDesign a new relational schema from product requirements: tables, ORM models, RLS, indexes, migrations and an ERD. Use when modelling a new feature, adding…
от borghei★ 1 250 звёзд на GitHubОб этом скилле
Database Schema Designer
The agent turns product requirements into a normalized relational schema with the cross-cutting columns, constraints, Row-Level Security, indexes, migrations and generated types the application needs, for PostgreSQL, MySQL or SQLite with Drizzle, Prisma, TypeORM or Alembic.
Core Capabilities
- Schema design from requirements — extract entities/relationships from natural language, apply 1NF–3NF normalization, add timestamps/soft-delete/audit/versioning, generate complete DDL.
- Migration planning — forward and rollback migrations, zero-downtime patterns for large tables, column additions/type changes/backfills across Drizzle, Prisma, TypeORM, Alembic, and raw SQL.
- Index strategy — composite, partial, covering, and GIN/GiST indexes mapped to query patterns; bloat detection and maintenance.
- Type generation — TypeScript interfaces + Zod schemas and Python dataclasses + Pydantic models from the DB schema (enums as string unions).
- Security — Row-Level Security for multi-tenant isolation, column-level PII encryption, audit logging with before/after JSON snapshots.
When to Use
- Designing tables for a new feature
- Checking a schema you are designing for missing indexes and conventions (for deep analysis of an existing schema and index tuning, use
engineering/database-designer) - Adding multi-tenancy to a single-tenant schema
- Planning a breaking schema migration
- Generating ERD documentation for a service
Clarify First
Before designing the schema, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.
- Requirements or existing DDL: the entities/relationships in natural language, or the schema to review (the source the design is derived from).
- Engine & ORM: PostgreSQL/MySQL/SQLite and Drizzle/Prisma/TypeORM/Alembic (sets the migration and type-generation output format).
- Cross-cutting needs: multi-tenancy/RLS, soft deletes, audit trails, or temporal data (determines which patterns and policies are generated).
Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.
Workflow
- Model. List the entities, their relationships and cardinalities from the requirements; normalize to 3NF, then denormalize only where a read path needs it and say why.
- Add the cross-cutting columns each table needs:
id,created_at,updated_at, and where requireddeleted_at,organization_id,version.- Primary keys: UUIDv7 (time-ordered, so B-tree inserts stay local) stored in the native
uuidtype, or CUID2 where IDs are generated in the app. PostgreSQL 18+ can generate UUIDv7 withuuidv7(). Use integer identity keys only for internal tables whose IDs never leave the database.
- Primary keys: UUIDv7 (time-ordered, so B-tree inserts stay local) stored in the native
- Write the DDL or ORM schema, with a foreign-key index on every FK column, partial indexes for soft-deleted tables, and RLS policies for multi-tenant tables (see
references/schema-design-and-security.md). - Validate with
schema_validator.pyand fix every error; then render the ERD witherd_generator.pyand check that it matches the requirements. - Migrate. For a change to an existing schema, diff the two DDL versions with
migration_diffr.py, review the forward and rollback SQL, and use the zero-downtime patterns inreferences/indexes-and-migrations.mdfor large tables.
Quick Start
python3 scripts/schema_validator.py assets/sample_schema_v1.sql # warnings only (exit 0)
python3 scripts/schema_validator.py assets/sample_schema_v2.sql # new table without FK indexes (exit 1)
python3 scripts/migration_diffr.py assets/sample_schema_v1.sql assets/sample_schema_v2.sql # forward + rollback SQL
python3 scripts/erd_generator.py assets/sample_schema_v2.sql # Mermaid ERD
Tools Overview
| Tool | What it does | Key flags | Exit codes |
|---|---|---|---|
scripts/schema_validator.py <file.sql> |
Missing PK, sequential PK, FK without index, nullable FK, missing timestamps, soft deletes without a partial index, tables with no index, naming | --json, --strict (warnings fail too) |
0 clean, 1 errors (or warnings with --strict), 2 bad input |
scripts/migration_diffr.py <old.sql> <new.sql> |
Added/removed tables and columns, type and nullability changes, index changes, with rollback | --json, --no-rollback, -o <file> |
0 no differences, 1 differences found, 2 bad input |
scripts/erd_generator.py <file.sql> |
Mermaid erDiagram with PK/FK markers and a table summary |
-o <file.mmd>, --json |
0, 2 bad input |
Anti-Patterns
Mistake: Exposing sequential integer IDs in URLs and APIs.
Why it happens: SERIAL is the default in most tutorials.
Instead: Use UUIDv7 or CUID2 for any
Установить database-schema-designer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл database-schema-designer?
Design a new relational schema from product requirements: tables, ORM models, RLS, indexes, migrations and an ERD. Use when modelling a new feature, adding multi-tenancy or soft deletes, or writing Drizzle/Prisma/Alembic schemas.
Как установить скилл database-schema-designer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл database-schema-designer запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic