Db Schema logo

Db Schema

Community
kazdenc
db-schema

Design a database schema from product requirements. Postgres-first with Supabase awareness. Use when user says "design the database", "create schema", "data model", "database structure", "what tables do I need", "schema design", or needs to translate requirements into a relational schema.

Overview

Publisherkazdenc
Repositorybuilder-skills
Skill namedb-schema
Stars
46
Forks
5
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by kazdenc on GitHub. Read the source before you install it.

Installation

Install the Db Schema AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/setup/db-schema
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kazdenc/builder-skills.git /tmp/builder-skills
mkdir -p .claude/skills
cp -r /tmp/builder-skills/.claude/skills/dev/setup/db-schema .claude/skills/db-schema
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Db Schema in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Db Schema on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Db Schema is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Database Schema Design

Design a Postgres database schema from product requirements. If target is provided, scope to that feature. Otherwise, ask the user what they're building.

Step 1: Identify Entities and Relationships

Read the requirements (PRD, user stories, or conversation). Extract:

  • Nouns = candidate tables (users, projects, comments, invoices)
  • Verbs = candidate relationships (creates, belongs to, has many)
  • Adjectives/states = candidate columns or enums (active, draft, published)

Ask clarifying questions if the requirements are ambiguous. Don't guess at business logic.

Step 2: Design Tables

Follow these conventions on every table:

ConventionRuleExample
Table namessnake_case, pluraluser_profiles, org_members
Column namessnake_casefirst_name, created_at
Primary keysuuid, auto-generatedid uuid default gen_random_uuid() primary key
TimestampsOn every table, non-nullablecreated_at timestamptz default now() not null
Updated timestampOn every tableupdated_at timestamptz default now() not null
Foreign keysNamed explicitly, with on deleteuser_id uuid references users(id) on delete cascade
Soft deletesUse deleted_at timestamptz when neededOnly when business requires undo/recovery
BooleansPrefix with is_ or has_is_active, has_verified_email

Postgres Type Recommendations

DataUseDon't useWhy
Identifiersuuidserial, integerNon-sequential, safe to expose, no collision across tables
TimestampstimestamptztimestampAlways store timezone-aware. Convert on display.
Moneynumeric(12,2) or bigint (cents)float, realFloating point causes rounding errors
Emailtext with check constraintvarchar(255)text is faster in Postgres. Constrain with check.
Short stringstextvarchar(n)Postgres text has no performance penalty. Use check(length(col) <= n) if needed.
Status/enumtext with check, or Postgres enumMagic integerscheck (status in ('draft','published','archived'))
JSON datajsonbjsonjsonb is indexable and more efficient
IP addressesinettextNative type supports operations
Tags/arraystext[] or junction tableCSV in text columnArrays for simple cases, junction table for queryable tags

Step 3: Define Relationships

One-to-Many

Put the foreign key on the "many" side:

sql
create table posts (
  id uuid default gen_random_uuid() primary key,
  user_id uuid references users(id) on delete cascade not null,
  title text not null,
  created_at timestamptz default now() not null,
  updated_at timestamptz default now() not null
);

One-to-One

Same as one-to-many but add a unique constraint:

sql
create table user_profiles (
  id uuid default gen_random_uuid() primary key,
  user_id uuid references users(id) on delete cascade not null unique,
  bio text,
  avatar_url text,
  created_at timestamptz default now() not null,
  updated_at timestamptz default now() not null
);

Many-to-Many

Use a junction table. Name it <table_a>_<table_b> in alphabetical order, or use a domain name if clearer:

sql
create table project_members (
  project_id uuid references projects(id) on delete cascade not null,
  user_id uuid references users(id) on delete cascade not null,
  role text not null default 'member' check (role in ('owner','admin','member','viewer')),
  joined_at timestamptz default now() not null,
  primary key (project_id, user_id)
);

Step 4: Add Indexes

Create indexes for:

Index whenExample
Foreign keys (always)create index idx_posts_user_id on posts(user_id);
Columns in WHERE clausescreate index idx_posts_status on posts(status);
Columns in ORDER BYcreate index idx_posts_created_at on posts(created_at desc);
Unique lookupscreate unique index idx_users_email on users(email);
Composite queriescreate index idx_posts_user_status on posts(user_id, status);
Full-text searchcreate index idx_posts_title_search on posts using gin(to_tsvector('english', title));

Don't over-index. Each index costs write performance. Start with foreign keys and obvious query patterns. Add more based on actual query plans.

Step 5: Write the Migration

Put everything in a Supabase migration:

bash
npx supabase migration new create_initial_schema

Structure the migration file:

sql
-- 1. Create enums (if using Postgres enums)
-- 2. Create tables (parent tables first, then children)
-- 3. Create indexes
-- 4. Enable RLS on all tables
-- 5. Create RLS policies
-- 6. Create functions and triggers (e.g., updated_at trigger)

-- Updated_at trigger function (create once, reuse)
create or replace function update_updated_at()
returns trigger as $$
begin
  new.updated_at = now();
  return new;
end;
$$ language plpgsql;

-- Example table
create table users (
  id uuid default gen_random_uuid() primary key,
  email text not null unique,
  full_name text,
  avatar_url text,
  created_at timestamptz default now() not null,
  updated_at timestamptz default now() not null
);

-- Apply updated_at trigger
create trigger set_updated_at
  before update on users
  for each row execute function update_updated_at();

-- Enable RLS
alter table users enable row level security;

-- Indexes
create index idx_users_email on users(email);

Step 6: Supabase-Specific Guidance

ConcernApproach
Auth usersSupabase manages auth.users. Reference with auth.uid(). Create a public.users or public.profiles table that mirrors/extends it.
Auto-create profileUse a trigger on auth.users insert to create a row in public.profiles
RLSEnable on every table. Write policies immediately. See supabase-setup skill for patterns.
RealtimeAdd tables to Supabase Realtime publication if live updates are needed: alter publication supabase_realtime add table <table>;
Type generationRun npx supabase gen types typescript --local after every migration

Auto-create profile trigger

sql
create or replace function public.handle_new_user()
returns trigger as $$
begin
  insert into public.profiles (user_id, email, full_name, avatar_url)
  values (
    new.id,
    new.email,
    new.raw_user_meta_data->>'full_name',
    new.raw_user_meta_data->>'avatar_url'
  );
  return new;
end;
$$ language plpgsql security definer;

create trigger on_auth_user_created
  after insert on auth.users
  for each row execute function public.handle_new_user();

Schema Review Checklist

CheckPass?
Every table has id uuid primary key
Every table has created_at and updated_at
All foreign keys have on delete behavior defined
All foreign keys have indexes
RLS is enabled on every table
No varchar without justification (use text)
No timestamp without tz (use timestamptz)
No floating point for money
Junction tables have composite primary keys
updated_at trigger is applied to all tables
Migration runs cleanly on supabase db reset
Types regenerated after migration

Frequently asked questions

What does the Db Schema AI skill do?

Design a database schema from product requirements. Postgres-first with Supabase awareness. Use when user says "design the database", "create schema", "data model", "database structure", "what tables do I need", "schema design", or needs to translate requirements into a relational schema.

Why use Db Schema on TypingMind?

Because you install it once and use it with any model. Db Schema is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Db Schema in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/setup/db-schema. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Db Schema?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Db Schema?

As many as you like. As long as a model supports skills, you can use Db Schema with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Db Schema AI skill free?

Yes. It is published on GitHub by kazdenc under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇