skills/council/architect/schema-design/SKILL.md
Use when designing or modifying database schemas with migration plans. Covers entity definition, relationship mapping, normalization trade-offs, indexing strategies, and RLS policies. Do not use for API endpoint contracts (use api-design) or codebase analysis (use codebase-context).
npx skillsauth add dtsong/my-claude-setup schema-designInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Design relational database schemas with normalization trade-offs, migration plans, and indexing strategies. Produces migration-ready SQL that can be applied directly to the database.
No user-provided values are used in commands or file paths. All inputs are treated as read-only analysis targets.
Read current schema files, migration history, or ORM models. List all existing tables with their columns, types, constraints, and relationships. Note any existing indexes and RLS policies.
From the feature requirements and interview output, determine what new data needs to be stored. List candidate entities and their purpose.
For each new entity, define:
Define all relationships between entities:
Default to 3NF. For each denormalization decision, document:
Drive index choices from query patterns:
If using Supabase or row-level security:
Write executable SQL:
Compaction resilience: If context was lost during a long session, re-read the Inputs section to reconstruct what system is being analyzed, check the Progress Checklist for completed steps, then resume from the earliest incomplete step.
# Schema Design: [Feature Name]
## Entity Overview
| Entity | Purpose | New/Modified |
|--------|---------|-------------|
| ... | ... | ... |
## Entity Definitions
### [entity_name]
| Column | Type | Nullable | Default | Constraints |
|--------|------|----------|---------|-------------|
| id | uuid | NO | gen_random_uuid() | PK |
| ... | ... | ... | ... | ... |
## Relationships
[ASCII diagram] users 1──N posts posts N──M tags (through: post_tags)
## Index Strategy
| Table | Index | Columns | Type | Rationale |
|-------|-------|---------|------|-----------|
| ... | ... | ... | ... | ... |
## Denormalization Decisions
| What | Why | Consistency Strategy |
|------|-----|---------------------|
| ... | ... | ... |
## RLS Policies
| Table | Operation | Policy | Using |
|-------|-----------|--------|-------|
| ... | ... | ... | ... |
## Migration SQL
### Up
```sql
-- New tables
CREATE TABLE ...
-- Indexes
CREATE INDEX ...
-- RLS
ALTER TABLE ... ENABLE ROW LEVEL SECURITY;
CREATE POLICY ...
DROP POLICY ...
DROP INDEX ...
DROP TABLE ...
## Quality Checks
- [ ] Every entity has a primary key
- [ ] Foreign keys reference existing or newly created tables
- [ ] Indexes support the identified query patterns
- [ ] Migration is reversible (Down section undoes Up completely)
- [ ] RLS policies cover all access patterns (SELECT, INSERT, UPDATE, DELETE)
- [ ] Timestamp columns (created_at, updated_at) are present on mutable entities
- [ ] CASCADE behavior is explicitly defined for all foreign keys
- [ ] No orphan tables (every table is reachable via relationships or has a documented reason for isolation)
## Evolution Notes
<!-- Observations appended after each use -->
development
Use when the council needs to surface organizational knowledge buried across multiple internal sources (wikis, design docs, ADRs, past tickets, postmortems, chat archives, code repos). Plans where to look, what to cross-reference, and how to synthesize findings into evidence the council can act on. Do not use for external market research (use competitive-analysis), library evaluation (use library-evaluation), or technology trend assessment (use technology-radar).
testing
Use to convert a Word .docx file to PDF and/or verify its page count. Triggers on: converting docx to pdf, rendering a document, checking how many pages a docx produces, or asserting a page-count constraint (e.g. a resume must stay 2 pages). Wraps LibreOffice headless conversion.
development
Security audit checklist for web applications. Use when reviewing, auditing, or hardening a web app's security posture. Covers rate limiting, auth headers, IP blocking, CORS, security middleware, input validation, file upload limits, ORM usage, and password hashing. Triggers on requests like "review security", "harden this app", "security audit", "check for vulnerabilities", or when building/reviewing API endpoints.
development
Interactive wizard to craft effective prompts using Claude Code best practices