Data Modeling 标志

Data Modeling

社区
MartinOlivero
data-modeling

当您要设计数据库架构、构建数据模型、选择数据库、规划迁移,或为 SaaS 设置多租户功能时,应使用此技能。触发短语包括“设计数据库”“为这些数据建模”“应该使用什么数据库”“为……设计架构”“多租户”“租户隔离”“添加索引”“如何迁移”“SQL 还是 NoSQL”“Postgres 架构”“行级安全”“RLS”。此技能默认采用 Postgres,安全地构建多租户数据模型,并严格遵循迁移和索引规范。

Add to TypingMind

概览

发布者MartinOlivero
代码仓库saas-builder
技能名称data-modeling
星标数
4
复刻数
2
附带文件
1
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 1 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 MartinOlivero 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Data Modeling AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/MartinOlivero/saas-builder/tree/main/skills/data-modeling
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MartinOlivero/saas-builder.git /tmp/saas-builder
mkdir -p .claude/skills
cp -r /tmp/saas-builder/skills/data-modeling .claude/skills/data-modeling
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Data Modeling,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Data Modeling。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Data Modeling 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

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)

  1. Is this multi-tenant (multiple orgs/customers sharing the app) or single-tenant?
  2. Is the data mostly relational (users, orders, invoices) or document-like/flexible?
  3. 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 SECURITY and FORCE ROW LEVEL SECURITY on 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 SUPERUSER nor BYPASSRLS — otherwise RLS is silently skipped and isolation is an illusion.
  • RLS is the backstop for the app-layer tenant_id checks in the auth skill — 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_at as timestamptz in 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), let insforge-cli apply migrations/RLS and insforge-debug diagnose 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 RESTRICT on 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 NOTHING is 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:

  1. A lost backend rebuilt from an export with no primary keys, truncated policies and no sequences.
  2. Stock at −420 because the only safeguard was a hidden button.
  3. 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".

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Data Modeling AI 技能有什么作用?

当您要设计数据库架构、构建数据模型、选择数据库、规划迁移,或为 SaaS 设置多租户功能时,应使用此技能。触发短语包括“设计数据库”“为这些数据建模”“应该使用什么数据库”“为……设计架构”“多租户”“租户隔离”“添加索引”“如何迁移”“SQL 还是 NoSQL”“Postgres 架构”“行级安全”“RLS”。此技能默认采用 Postgres,安全地构建多租户数据模型,并严格遵循迁移和索引规范。

为什么在 TypingMind 中使用 Data Modeling?

因为您只需安装一次,就能搭配任何模型使用。Data Modeling 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Data Modeling?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/MartinOlivero/saas-builder/tree/main/skills/data-modeling。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Data Modeling?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Data Modeling 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Data Modeling 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Data Modeling AI 技能免费吗?

是的。MartinOlivero 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇