Agent skill
design-schema
Design complete database schemas with tables, relationships, constraints, and indexes for Supabase. Triggers when user describes data models, entities, or requests schema design.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/design-schema
SKILL.md
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
-
Gather Requirements
- Identify all entities
- Understand relationships
- Determine data constraints
- Plan for future growth
-
Design Tables
- Choose appropriate column types
- Add NOT NULL constraints
- Define CHECK constraints
- Include timestamps
-
Map Relationships
- One-to-many with foreign keys
- Many-to-many with junction tables
- Self-referential if needed
-
Add Indexes
- Primary keys (automatic)
- Foreign keys
- Frequently queried columns
- Composite indexes for multi-column queries
-
Implement RLS
- Enable on all tables
- Create policies for each operation
- Test policy effectiveness
-
Generate Migration
- Complete SQL DDL
- Include all constraints
- Add helpful comments
Example Output
-- 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
- Complete schema SQL
- ER diagram description
- Explanation of design decisions
- Migration file
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?