Skip to content
Back to skills

Design Schema

ASecurity

Design complete database schemas with tables, relationships, constraints, and indexes for Supabase. Triggers when user describes data models, entities, or requests schema design.

  • 666 stars
  • 0 votes
  • 1 copy
  • 6 views
  • Added February 8, 2026
databasessqldatabasesecurity

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill design-schema --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Design Schema?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Design Schema
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-design-schema/badge)](https://www.skillsdirectory.com/skills/majiayu000-design-schema)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: design-schema
description: Design complete database schemas with tables, relationships, constraints, and indexes for Supabase. Triggers when user describes data models, entities, or requests schema design.
allowed-tools: Read, Write, Edit
---

# Schema Design Skill

Design comprehensive, normalized database schemas for Supabase applications.

## Purpose

Create well-structured database schemas following best practices for normalization, relationships, constraints, and indexing.

## When to Use

- User describes data requirements
- Requests database schema design
- Needs entity relationship modeling
- Asks about table structure
- Plans new feature requiring data storage

## Instructions

1. **Gather Requirements**
   - Identify all entities
   - Understand relationships
   - Determine data constraints
   - Plan for future growth

2. **Design Tables**
   - Choose appropriate column types
   - Add NOT NULL constraints
   - Define CHECK constraints
   - Include timestamps

3. **Map Relationships**
   - One-to-many with foreign keys
   - Many-to-many with junction tables
   - Self-referential if needed

4. **Add Indexes**
   - Primary keys (automatic)
   - Foreign keys
   - Frequently queried columns
   - Composite indexes for multi-column queries

5. **Implement RLS**
   - Enable on all tables
   - Create policies for each operation
   - Test policy effectiveness

6. **Generate Migration**
   - Complete SQL DDL
   - Include all constraints
   - Add helpful comments

## Example Output

```sql
-- Users and Posts Schema
-- =======================

CREATE TABLE public.users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  email TEXT UNIQUE NOT NULL,
  username TEXT UNIQUE NOT NULL,
  created_at TIMESTAMPTZ DEFAULT NOW() NOT NULL,

  CONSTRAINT username_length CHECK (char_length(username) >= 3)
);

CREATE TABLE public.posts (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  author_id UUID NOT NULL REFERENCES public.users(id) ON DELETE CASCADE,
  title TEXT NOT NULL,
  content TEXT NOT NULL,
  published BOOLEAN DEFAULT false,
  created_at TIMESTAMPTZ DEFAULT NOW() NOT NULL,

  CONSTRAINT title_length CHECK (char_length(title) >= 3)
);

CREATE INDEX idx_posts_author ON public.posts(author_id);
CREATE INDEX idx_posts_published ON public.posts(published, created_at DESC)
  WHERE published = true;

ALTER TABLE public.posts ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Published posts viewable by all"
  ON public.posts FOR SELECT
  USING (published = true);
```

## Output Format

1. Complete schema SQL
2. ER diagram description
3. Explanation of design decisions
4. Migration file

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.