database-designer
БесплатноЗапускает вложенные скриптыНе проверенAnalyse an existing SQL schema for normalization and constraint gaps, recommend indexes from query patterns, and generate forward/rollback migrations. Use…
Об этом скилле
Database Designer
The agent analyses an existing relational schema for normalization, constraint, naming and type problems, recommends indexes for the queries that actually run, and generates forward and rollback migrations between two schema versions. To design a new schema from product requirements (ERDs, RLS, ORM models), use engineering/database-schema-designer instead.
When to Use
- Reviewing a schema (DDL or JSON) before or after a change.
- Choosing or pruning indexes for a known set of queries.
- Turning a schema diff into a migration with rollback and validation queries, optionally zero-downtime (expand-contract).
- Choosing between database engines for a workload (reference only).
Clarify First
Before designing or migrating, 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.
- Task: schema analysis/ERD, index optimization, or migration generation (selects
schema_analyzer.pyvsindex_optimizer.pyvsmigration_generator.py). - Engine: PostgreSQL or MySQL (drives the DDL dialect; for choosing an engine, see the selection reference).
- Schema input & query patterns: the DDL/JSON schema and the queries to optimize for (the input the tools analyze; index recommendations depend on the query patterns).
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
- Analyse the current schema with
schema_analyzer.py(DDL or JSON). Read the findings as candidates: the transitive-dependency check matches column-name prefixes (user_id,user_email) and can flag unrelated columns, so confirm each before proposing a split. - Index with
index_optimizer.py, which needs the schema as JSON plus the query patterns (assets/sample_query_patterns.jsonshows the shape). Columns already covered by a primary key, a unique constraint or an existing index prefix are not recommended again. Validate each recommendation withEXPLAINon real data before creating it. - Migrate with
migration_generator.py --current old.json --target new.json. Review every HIGH-risk step (drops, type changes) and use--zero-downtimefor large or busy tables. Run the migration on a copy, then run the rollback, before it goes near production. - Verify that the analyzer's high-severity count went down and the generated rollback restores the original schema.
Quick Start
python3 scripts/schema_analyzer.py --input assets/sample_schema.sql --output-format text # 11 tables, 14 FKs
python3 scripts/schema_analyzer.py --input assets/sample_schema.sql --erd-only # Mermaid ERD
python3 scripts/index_optimizer.py --schema assets/sample_schema.json --queries assets/sample_query_patterns.json --analyze-existing
python3 scripts/migration_generator.py --current assets/sample_schema.json --target assets/sample_schema_target.json --format sql
Tools Overview
| Tool | What it does | Key flags |
|---|---|---|
scripts/schema_analyzer.py |
Parse DDL (CREATE TABLE, inline and table-level REFERENCES, CREATE INDEX) or JSON; report 1NF-BCNF smells, missing PK/FK/NOT NULL/CHECK, VARCHAR(255) defaults, naming; Mermaid ERD |
--input, `--output-format json |
scripts/index_optimizer.py |
Recommend single, composite and covering indexes from query patterns; order composite columns by selectivity; flag redundant and overlapping indexes | --schema, --queries, --analyze-existing, --min-priority 1-4, `--format json |
scripts/migration_generator.py |
Diff two JSON schemas into ordered steps with forward and rollback SQL, risk level and validation queries | --current, --target, `--format json |
Exit codes: 0 report produced, 2 bad input (missing file, invalid JSON, no tables found).
Anti-Patterns
Mistake: Creating every index the optimizer suggests.
Why it happens: Each recommendation looks reasonable on its own.
Instead: Indexes cost write throughput and storage. Create the ones that serve frequent or slow queries, confirm with EXPLAIN, and drop the redundant ones --analyze-existing finds.
Mistake: Running a generated DROP COLUMN or type change directly on a large production table.
Why it happens: The SQL is ready to paste.
Instead: Use expand-contract (--zero-downtime): add, backfill, switch reads, then drop in a later release. Rehearse the rollback first.
Mistake: Normalising everything the analyzer flags. Why it happens: Normal forms look like correctness. Instead: Denormalised columns can be deliberate (snapshots of a price at order time, read models). Keep them when they are intentional and say why.
Установить database-designer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл database-designer?
Analyse an existing SQL schema for normalization and constraint gaps, recommend indexes from query patterns, and generate forward/rollback migrations. Use when reviewing DDL, tuning indexes, or diffing two schema versions.
Как установить скилл database-designer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл database-designer запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic