database-design

database-design is a skill for Claude Code, Codex from chaunsin/agent-skills. It costs 111 tokens per session (2,085 once invoked), scanned A, original, Apache-2.0.

A relational database design guide for turning business requirements into tables, fields, relationships, constraints, indexes, and database changes. Relational databases store related data in structured tables; examples include MySQL and PostgreSQL.

In plain words
What is it for?
Use it to model business data, choose keys and relationships, design schemas and indexes, write DDL, and plan structural migrations.
Why use it?
It reduces unclear data models, duplicated data, weak integrity rules, and indexes or migrations chosen without regard to real queries.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to model business data, choose keys and relationships, design schemas and indexes, write DDL, and plan structural migrations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chaunsin/agent-skills/database-design
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add chaunsin/agent-skills --skill database-design
Clone the repo
git clone --depth 1 https://github.com/chaunsin/agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for database-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/chaunsin/agent-skills/database-design/github.svg)](https://agentmods.dev/skills/chaunsin/agent-skills/database-design)
Your own site
<a href="https://agentmods.dev/skills/chaunsin/agent-skills/database-design"><img src="https://agentmods.dev/badge/skills/chaunsin/agent-skills/database-design/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for database-design

Your own site · 80×15
<a href="https://agentmods.dev/skills/chaunsin/agent-skills/database-design"><img src="https://agentmods.dev/badge/skills/chaunsin/agent-skills/database-design.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 111 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,085 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00111 $0.02085
Opus 5.5 $0.00044 $0.00834
Sonnet 5.5 $0.00022 $0.00417
Haiku 4.5 $0.00011 $0.00209

Measured 23d ago against content hash ecfa7afe9be9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

database-design scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 23d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/database-design/SKILL.md · 90 lines

How it starts

The opening of the file, as written. The whole thing — 90 lines — stays where its author put it; the contents beside it link to each section on GitHub.

关系型数据库建模与建表

一、技能目标与职责

本技能负责将业务需求转化为可维护、数据完整、性能合理的关系型数据库模型和物理表结构。工作范围包括需求分析、领域建模、表与字段设计、主键与约束、索引、事务并发、特殊业务数据、架构扩展、数据库兼容及迁移。

适用于 MySQL、PostgreSQL 等关系型数据库。逻辑模型尽量保持数据库无关;物理 DDL 必须依据目标数据库产品、版本及存储引擎适配。

二、核心设计原则

  1. 业务正确优先:模型必须准确表达业务实体、关系、状态和生命周期,不得自行编造业务规则。
  2. 默认规范化:逻辑设计默认以第三范式(3NF)为基线,避免重复事实和不必要冗余;有明确业务或性能依据时才反规范化,并说明数据来源、更新机制及一致性保障。
  3. 数据完整性:优先使用主键、唯一、非空、检查约束及适当的外键表达可由数据库保证的规则。禁用物理外键时,必须说明应用层校验、事务、补偿或巡检方案。
  4. 职责清晰:不得为了减少表数量,把职责、生命周期或访问模式明显不同的数据强行合并。
  5. 命名统一:标识符默认使用小写 snake_case,仅使用 ASCII 字母、数字和下划线;避免保留字、模糊命名和同义字段多套命名。
  6. 类型准确:字段类型、长度、精度、NULL 和默认值必须符合业务语义及数据范围。金额不得使用浮点类型进行精确记账。
  7. 索引由查询驱动:根据真实查询条件、排序、关联、数据分布和执行计划设计索引,不设置固定索引数量上限。
  8. 避免过度设计:不得无依据地引入冗余字段、位图、多态关联、分区、分库分表、读写分离或复杂缓存。
  9. 显式处理假设:关键信息缺失时提出待确认事项;非关键缺失可采用合理假设,但必须标注,不得将假设伪装成已知业务事实。

三、执行流程

按照以下顺序完成设计,不要在未理解业务关系前直接生成复杂 DDL。

  1. 确认上下文:识别数据库产品、版本、存储引擎、现有命名规范、部署形态及迁移工具。若未知,明确标注,并避免使用未经确认的专有语法。
  2. 分析需求:识别业务实体、数据归属、实体关系、唯一性、状态流转、读写模式、并发、数据保留及安全要求。
  3. 建立逻辑模型:划分领域和实体,明确 1:1、1:N、N:N 或多态关系,确定数据权威来源及生命周期。
  4. 设计物理结构:确定表、字段、主键、类型、NULL、默认值、注释、约束和关联策略。
  5. 选择 ID 策略:常规单库默认采用数值型自增主键;分布式生成或多写入节点场景按需评估 Snowflake、UUIDv7 等有序 ID。详细规则见 references/id-strategy.md。
  6. 设计索引与访问路径:使用实际或预期 SQL 推导索引;重要查询应说明索引服务的查询模式。
  7. 评估特殊要求:仅在业务需要时设计软删除、乐观锁、账务流水、多租户、分区、分库分表、读写分离及高可用。
  8. 生成并审查 DDL:按目标数据库版本生成表、索引、约束及注释;检查兼容性、数据完整性、并发风险和迁移影响。
  9. 验证并交付:能够连接目标数据库时执行验证;不能执行时,只能说明静态审查结果,不得声称已实际验证。

四、渐进式披露:按需读取参考文件

不要默认读取全部参考文件。 先根据当前任务判断需要的知识,再只读取相关文件;一个任务涉及多个主题时才组合读取。

当前任务 按需读取
业务领域、范式、表/字段、关系、NULL、软删除、约束 references/modeling-and-schema.md
主键、自增、Snowflake、UUIDv7、分布式 ID、分片键 references/id-strategy.md
MySQL 类型、DDL、InnoDB、时间、索引和版本差异 references/mysql.md
PostgreSQL 类型、DDL、Identity、UUID、索引和版本差异 references/postgresql.md
索引、联合索引、执行计划、分页、IN/EXISTS references/indexing-and-query.md
事务、锁、并发、UPSERT、幂等 references/transactions-and-concurrency.md
金额、资产、账务、库存、积分、发放与状态机 references/business-data.md
触发器使用、编写、数据库差异、测试与迁移 references/triggers.md
多租户、服务边界、分区、分库分表、集群、在线迁移 references/architecture-and-migration.md

Read the full file on GitHub · 90 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 23d ago Changed · +2 lines · +15 tokens per session ecfa7afe9be9
  2. 25d ago First seen · 88 lines · 96 tokens per session scan A 7814f65b92cb

Subscribe to this mod's changes

database-design is a skill published in the GitHub repository chaunsin/agent-skills (2 stars, last pushed 12d ago), licensed Apache-2.0. It adds 111 tokens to every session and 2,085 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-07.

Related

database-design compared with skills from other repositories

database-design next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
database-designchaunsin/agent-skillsSkill212d agoApache-2.0A111Claude Code, Codex
mongodbmongodb/agent-skillsSkill211todayApache-2.0A218Claude Code, Codex
yida-data-managementopenyida/openyidaSkill234todayMITA91Claude Code, Codex
yida-aggregate-tableopenyida/openyidaSkill234todayMITA71Claude Code, Codex
yida-db-seq-fixopenyida/openyidaSkill234todayMITA73Claude Code, Codex
mongodb-qe-size-estimationmongodb/agent-skillsSkill211todayApache-2.0A52Claude Code
doris-repo-reviewapache/doris-skillsSkill526d agoApache-2.0A200Claude Code, Codex