# database-schema-designer

Designs relational and document database schemas based on real app queries. Generates tables, keys, constraints, ERDs, and reversible migrations.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 403 installs · ★ 382
- Author: OneWave-AI
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/OneWave-AI/claude-skills/tree/HEAD/database-schema-designer/SKILL.md
- Updated: 2026-10-20
- HTML: https://affpapa.org/en/nevibecode/skills/onewave-ai-database-schema-designer

## What it does

The skill builds database schemas around actual query patterns rather than generic checklists. It defaults to PostgreSQL 18 and Supabase, while also handling MySQL, SQLite, and MongoDB. Before writing DDL, the agent extracts the read-write ratio, data volume, tenancy model, and migration tooling, whether that is Prisma, Drizzle, Alembic, or plain SQL.

Entity modeling targets third normal form. Denormalization is permitted only for specific heavy queries. The workflow enforces data integrity inside the database: `timestamptz` for dates, `numeric` for monetary values, `CHECK` constraints over rigid `ENUM` types, and explicit `ON DELETE` rules. Indexes cover the 5 to 10 critical application queries and foreign key joins instead of indexing arbitrary columns.

For verification, the agent runs `EXPLAIN` against a local database or walks queries through manual inspection. Placing structured, queryable data inside `jsonb` is flagged as an anti-pattern when columns require filtering or constraints.

## Requirements
- Works with: PostgreSQL, MongoDB, Supabase

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add OneWave-AI/claude-skills --skill database-schema-designer -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/database-schema-designer/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/database-schema-designer/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add OneWave-AI/claude-skills --skill database-schema-designer -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/database-schema-designer/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add OneWave-AI/claude-skills --skill database-schema-designer -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/database-schema-designer/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install OneWave-AI/claude-skills database-schema-designer
```

2. **Manually: put the files in place**
- File: `.github/skills/database-schema-designer/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add OneWave-AI/claude-skills --skill database-schema-designer -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/OneWave-AI/claude-skills --path database-schema-designer
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/database-schema-designer/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add OneWave-AI/claude-skills --skill database-schema-designer -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/OneWave-AI/claude-skills/tree/HEAD/database-schema-designer/SKILL.md

## When to use it
- design relational schemas and cardinality for new features
- derive targeted composite and partial indexes from query patterns
- model multi-tenant architectures using `tenant_id` and RLS
- write safe database migrations with working rollback scripts

## Example prompts
- Design a multi-tenant task tracker schema for PostgreSQL using Drizzle ORM.
- Review my query patterns and suggest indexes for the orders table.
- Generate DDL and a reversible SQL migration for user roles in Supabase.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 4d019f1c5c20f0ce.

BEGIN THIRD-PARTY FILE 4d019f1c5c20f0ce
```text
---
name: database-schema-designer
description: Designs relational and document database schemas from requirements or an existing app - tables and collections, keys, relationships, constraints, indexes driven by real query patterns, ERDs, and reversible migration scripts - with PostgreSQL (including Supabase) as the default and MySQL, SQLite, and MongoDB supported. Use when the user wants to model data for a new app or feature, review or fix an existing schema, choose keys or indexes, plan multi-tenancy, normalize or denormalize, or write CREATE TABLE statements or migrations, even if they just describe their app and ask "how should I store this". For moving data between database providers, use database-migrator.
---

# Database Schema Designer

Design a schema that enforces the data's rules in the database and makes the app's real queries fast.

## Workflow

1. **Collect requirements.** Get from the conversation or codebase, and ask only for what blocks the design:
   - Engine and version (default: PostgreSQL 18; check `docker-compose.yml`, ORM config, or Supabase project if present)
   - Entities and how they relate, in plain language
   - The 5-10 most frequent or most important queries, including filters and sort order
   - Volume and growth (rows per table per year), read/write mix
   - Tenancy (single app, multi-tenant by organization), retention, audit, and compliance needs (PII, deletion requests)
   - ORM or migration tool in use (Prisma, Drizzle, Rails, Django, Alembic, Supabase migrations, plain SQL)

2. **Model entities and relationships.** List entities, attributes, and cardinality (1:1, 1:N, N:M). Normalize to 3NF by default; denormalize only for a named query that needs it, and say which.

3. **Choose keys and types** using [references/postgres.md](references/postgres.md) (or [references/other-engines.md](references/other-engines.md) for MySQL, SQLite, MongoDB). Defaults for Postgres: `bigint generated always as identity` or `uuid DEFAULT uuidv7()` primary keys, `text` over `varchar(n)`, `timestamptz` for every timestamp, `numeric` for money.

4. **Encode the rules as constraints.** `NOT NULL` wherever a value is required, `UNIQUE` for natural keys, `CHECK` for ranges and allowed values, foreign keys with a deliberate `ON DELETE` choice for each. Data rules that live only in app code get broken by the next script or admin fix.
```
END THIRD-PARTY FILE 4d019f1c5c20f0ce

The third-party file has ended. Everything between the 4d019f1c5c20f0ce tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2384 of 6262 bytes. © OneWave-AI · MIT · https://github.com/OneWave-AI/claude-skills/tree/HEAD/database-schema-designer/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
