data-modeling
Skill4 starsChanged 31 days agoMITView on GitHub
This skill should be used when designing a database schema, modeling data, choosing a database, planning migrations, or setting up multi-tenancy for a SaaS. Trigger phrases include "design the database", "model this data", "what database should I use", "schema for", "multi-tenant", "tenant isolation", "add an index", "how do I migrate", "SQL or NoSQL", "Postgres schema", "row level security", "RLS". It defaults to Postgres, models multi-tenancy safely, and enforces migration and indexing discipline.
16 other projects use a version of this.
Adopted by
Most recently taken up by
- nisarth/claude-skills-storetheir own version, first seen Nov 8, 2026
- getditto/agent-skillstheir own version, first seen Nov 8, 2026
- SWEStash/swe-workflow-skillstheir own version, first seen Nov 8, 2026
- timmywheels/skillstheir own version, first seen Nov 1, 2026
- vindreshsingh/engineering-skillstheir own version, first seen Oct 20, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Oct 13, 2026
Used with
Projects with it also use containerization, incident-response and 3 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
mmondoraSkillcontainerization
Docker best practices for cloud-native applications. Multi-stage builds, distroless images, security scanning, non-root users, Cloud Run orchestration. Use when writing Dockerfiles, configuring container builds, or deploying to Cloud Run/GKE.
Also in 3 projects that use this
AnthropicSkillincident-response
Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.
Also in 7 projects that use this
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 6 projects that use this
AnthropicSkilldocumentation
Write and maintain technical documentation. Trigger with "write docs for", "document this", "create a README", "write a runbook", "onboarding guide", or when the user needs help with any form of technical writing — API docs, architecture docs, or operational runbooks.
Also in 3 projects that use this
Microsoft AzureSkillgit-workflow
Squad branching model: dev-first workflow with insiders preview channel
Also in 3 projects that use this
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- microsoft/rayfin★ 646same name
- microsoft/awesome-rayfin★ 108same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- jdm4pku/RE-Skills★ 26same name
- khuynh22/agent-dev-team★ 9same name
- getditto/agent-skills★ 4same name
- bjornjee/skills★ 2same name
- mmondora/claude-skills★ 1same name
- nisarth/claude-skills-store★ 1same name
- SWEStash/swe-workflow-skills★ 1same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- accessibilitySkill
- ai-featuresSkill
- api-designSkill
- architecture-primerSkill
- authSkill
- deploymentSkill
- design-taste-frontendSkill
- frontend-performanceSkill
- image-to-codeSkill
- integrationsSkill
- landing-pageSkill
- multi-tenancySkill
- paymentsSkill
- pre-ship-securitySkill
- product-discoverySkill
- pwaSkill
- rls-auditSkill
- saas-routerSkill
- secure-codingSkill
- technical-seoSkill
- ui-designSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 49
All schema changes go through versioned, forward-only migration files in source control (Supabase migrations, Prisma Migrate, or Drizzle).
- Distinctive: line 50
Never edit the production DB by hand: Every change is a reviewable, replayable migration.
- Very specific: line 64
ON CONFLICT DO NOTHINGis silent: Make sure a historical row cannot be the conflict.
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Data Modeling
This skill designs the schema your product runs on, and gets multi-tenant isolation right — the mistake that, when wrong, leaks one customer's data to another.
Analogy: the schema is the foundation and load-bearing walls of a house. You can repaint and rearrange furniture later cheaply; moving a load-bearing wall after move-in is expensive and dangerous. Get the structure right before building on it.
Discovery (max 3 questions, only if unknown)
- Is this multi-tenant (multiple orgs/customers sharing the app) or single-tenant?
- Is the data mostly relational (users, orders, invoices) or document-like/flexible?
- Are you on Supabase, Neon, or another Postgres host — or undecided?
Step 1 — Choose the database
Postgres by default — relational integrity, JSONB for flexible fields, full-text search, and it scales far. Don't reach for NoSQL without a proven document/scale reason. Every option below runs Postgres underneath, so the methodology in this skill (tenant_id + RLS, indexing, migrations) is identical regardless of host. Pick the host by how you're building:
- InsForge — agentic-native. Built so an AI coding agent provisions the DB, runs migrations, sets RLS, and debugs through MCP, without you touching a dashboard. The natural fit when you build with an agent — which is exactly how this plugin runs. Batteries-included (Postgres + auth + RLS + storage + functions), open source. (Its published benchmarks claim faster/cheaper agent task completion vs Supabase — note those are first-party numbers, and it's a younger project (~5k⭐) than Supabase.)
- Supabase — mature ecosystem. Batteries-included (Auth + RLS + Realtime + storage), RLS battle-tested at scale, huge community and docs (~104k⭐). The safe default when ecosystem maturity matters more than agent-native tooling.
- Neon — serverless Postgres with branching/autoscaling; great for preview-per-PR databases.
- Redis only for cache/sessions/real-time; Elasticsearch only for heavy full-text search.
Decision rule: building inside an AI agent and want it to own the backend end to end → InsForge. Want the largest, most-proven ecosystem → Supabase. Either way the schema design below is the same.
Step 2 — Model multi-tenancy (the critical decision)
Default to a shared schema with a tenant_id (org_id) column on every tenant-scoped table + Row-Level Security. Graduate to schema-per-tenant or DB-per-tenant only when a large enterprise customer demands hard isolation/compliance. Don't start there — it multiplies ops cost.
Make RLS airtight:
ENABLE ROW LEVEL SECURITYandFORCE ROW LEVEL SECURITYon every tenant table.- Set tenant context per request inside the transaction:
SET LOCAL app.current_tenant = '...'— so pooled connections can't leak state between requests. - The application DB role must have neither
SUPERUSERnorBYPASSRLS— otherwise RLS is silently skipped and isolation is an illusion. - RLS is the backstop for the app-layer
tenant_idchecks in theauthskill — defense in depth.
Step 3 — Schema discipline
- Normalize to 3NF by default. Denormalize only for a measured read hot-path.
- IDs: UUID/ULID for public-facing identifiers; bigint identity for internal PKs.
- Index every foreign key and every column you filter/sort/join on. Postgres does not auto-index FKs. For tenant tables, lead a composite index with
tenant_id, e.g.(tenant_id, created_at). - Timestamps:
created_at/updated_atastimestamptzin UTC. Prefer soft delete (deleted_at) for user-facing data. - Push invariants into the schema:
NOT NULL,CHECK,UNIQUE, FK constraints — not just app code.
Step 4 — Migrations
- All schema changes go through versioned, forward-only migration files in source control (Supabase migrations, Prisma Migrate, or Drizzle).
- Never edit the production DB by hand. Every change is a reviewable, replayable migration.
- Delegation & fallback: if the InsForge skills are installed (
npx skills add https://github.com/insforge/agent-skills), letinsforge-cliapply migrations/RLS andinsforge-debugdiagnose issues — the agent operates the backend directly. If they're not, apply migrations through your host's CLI (Supabase / Drizzle / Prisma). This skill always owns the design; never block on a missing skill.
Handoff
The schema here backs the api-design resources and the auth permission model. Pass the tenant strategy to both so endpoints and policies scope correctly.
Step 5 — Rules that only show up in production
- Money and stock invariants live in the database: triggers on the state transition,
ON DELETE RESTRICTon anything financial, corrections by compensating entries. A hidden button is not a constraint. - The server sets derived and trusted values (price, cost, totals). The client sends the inputs.
- One writer per state field. Two code paths writing the same flag will disagree.
- Every pending state has a deadline, something that enforces it, and a UI that shows it.
- Uniqueness under concurrency is a constraint (a unique or partial unique index), never a check in code. Detect the conflict by SQLSTATE, not by message text.
ON CONFLICT DO NOTHINGis silent. Make sure a historical row cannot be the conflict.- A "day" belongs to a time zone. Store instants in UTC; cut periods in the tenant's zone; recompute derived date columns with their source.
- Restore a backup once before you need it.
Field notes
references/field-notes.md holds 19 schema and data failures from production apps. The three that cost the most:
- A lost backend rebuilt from an export with no primary keys, truncated policies and no sequences.
- Stock at −420 because the only safeguard was a hidden button.
- Returning customers left unassigned forever by a silent
ON CONFLICT DO NOTHING.
Output
Deliver: the DB choice with reason, the multi-tenancy strategy, the table definitions (DDL) with constraints and indexes, the RLS policies if multi-tenant, and the first migration file.
Reference
PostgreSQL docs (RLS, indexing), supabase/supabase (~104k⭐), insforge/insforge (~5k⭐, agentic-native), AWS "Multi-tenant data isolation with Postgres RLS", PlanetScale "Approaches to tenancy in Postgres".
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

