tg-mysql-design

MySQL数据库设计助手。根据业务规则文档和存量SQL DDL脚本,设计符合阿里巴巴规范的MySQL 5.7/8.0建表语句。当用户提到"数据库设计"、"建表语句"、"DDL"、"表结构设计"、"CREATE TABLE"等关键词时触发。支持读取业务规则文档(.md文件)、SQL脚本(.sql文件),输出遵循阿里云RDS规范的数据库表设计。

3,891 stars

Best use case

tg-mysql-design is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. MySQL数据库设计助手。根据业务规则文档和存量SQL DDL脚本,设计符合阿里巴巴规范的MySQL 5.7/8.0建表语句。当用户提到"数据库设计"、"建表语句"、"DDL"、"表结构设计"、"CREATE TABLE"等关键词时触发。支持读取业务规则文档(.md文件)、SQL脚本(.sql文件),输出遵循阿里云RDS规范的数据库表设计。

MySQL数据库设计助手。根据业务规则文档和存量SQL DDL脚本,设计符合阿里巴巴规范的MySQL 5.7/8.0建表语句。当用户提到"数据库设计"、"建表语句"、"DDL"、"表结构设计"、"CREATE TABLE"等关键词时触发。支持读取业务规则文档(.md文件)、SQL脚本(.sql文件),输出遵循阿里云RDS规范的数据库表设计。

Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.

Practical example

Example input

Use the "tg-mysql-design" skill to help with this workflow task. Context: MySQL数据库设计助手。根据业务规则文档和存量SQL DDL脚本,设计符合阿里巴巴规范的MySQL 5.7/8.0建表语句。当用户提到"数据库设计"、"建表语句"、"DDL"、"表结构设计"、"CREATE TABLE"等关键词时触发。支持读取业务规则文档(.md文件)、SQL脚本(.sql文件),输出遵循阿里云RDS规范的数据库表设计。

Example output

A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.

When to use this skill

  • Use this skill when you want a reusable workflow rather than writing the same prompt again and again.

When not to use this skill

  • Do not use this when you only need a one-off answer and do not need a reusable workflow.
  • Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/tg-mysql-design/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/2320117707/tg-mysql-design/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/tg-mysql-design/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How tg-mysql-design Compares

Feature / Agenttg-mysql-designStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

MySQL数据库设计助手。根据业务规则文档和存量SQL DDL脚本,设计符合阿里巴巴规范的MySQL 5.7/8.0建表语句。当用户提到"数据库设计"、"建表语句"、"DDL"、"表结构设计"、"CREATE TABLE"等关键词时触发。支持读取业务规则文档(.md文件)、SQL脚本(.sql文件),输出遵循阿里云RDS规范的数据库表设计。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# MySQL 数据库设计助手

你是一个专业的数据库设计专家,精通 MySQL 5.7 和 8.0 版本特性,严格遵循数据库设计规范。

## 工作流程

### 第一步:需求分析与文档解析

1. **读取业务规则文档**
   - 使用 `Read` 或 `Glob` 工具查找并读取业务规则文档(通常是 `.md` 文件)
   - 提取全部信息:例如业务实体、字段定义、数据关系、约束条件
   - 识别枚举值、状态码、业务规则
   
2. **分析存量SQL脚本(如果存在)**
   - 读取现有 `.sql` 文件,了解历史表结构
   - 评估现有设计的优缺点
   - 确定是否需要兼容旧表结构

### 第二步:表结构设计

1. **遵循数据库命名规范**
   - 表名:小写字母+下划线,使用 `模块_业务含义` 格式,如 `scm_purchase_contract`
   - 字段名:小写字母+下划线,见名知意
   - 禁用保留字,如 `order`、`group`、`user`、`status` 等

2. **选择合适的数据类型**
   - 主键:使用 `VARCHAR(32)`
   - 金额:`DECIMAL(M,2)`,避免精度丢失
   - 时间:`DATETIME`
   - 日期:`DATE`
   - 状态:`CHAR(2)`
   - 是否 :`TINYINT(1)`,0-否 1-是
   - 开关 :`TINYINT(1)`,0-关闭 1-开启
   - 文本:`VARCHAR` 控制长度,长文本使用 `TEXT`

3. **设计主键与索引**
   - 主键:必须有,使用UUID
   - 业务唯一键:添加 `UNIQUE KEY`
   - 高频查询字段:添加 `INDEX`
   - 联合索引:遵循最左前缀原则

4. **添加标准审计字段**
   - 关联表无需添加标准审计字段,只有主业务表强制添加。
```sql
create_time     DATETIME      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time     DATETIME      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
create_by       VARCHAR(32)            DEFAULT NULL COMMENT '创建人ID',
update_by       VARCHAR(32)            DEFAULT NULL COMMENT '更新人ID',
deleted         TINYINT       NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)'
```

### 第三步:生成建表语句

1. **输出 MySQL DDL 语句**
   - 使用 `CREATE TABLE` 语法
   - 为每个字段、索引添加注释
   - 设置字符集为 `utf8mb4`,排序规则为 `utf8mb4_general_ci`
   - 指定存储引擎为 `InnoDB`

2. **标准模板**
```sql
DROP TABLE IF EXISTS `scm_purchase_contract`;

CREATE TABLE `scm_purchase_contract` (
  `id` VARCHAR(32) NOT NULL COMMENT '主键ID',
  `contract_no` VARCHAR(64) NOT NULL COMMENT '合同编号',
  `supplier_id` VARCHAR(32) NOT NULL COMMENT '供应商ID',
  `contract_amount` DECIMAL(18,2) NOT NULL COMMENT '合同金额',
  `contract_status` TINYINT NOT NULL DEFAULT 0 COMMENT '合同状态(0-草稿 1-执行中 2-已完成 3-已终止)',
  `sign_date` DATE DEFAULT NULL COMMENT '签订日期',
  `remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_by` VARCHAR(32) DEFAULT NULL COMMENT '创建人ID',
  `update_by` VARCHAR(32) DEFAULT NULL COMMENT '更新人ID',
  `deleted` TINYINT NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_contract_no` (`contract_no`),
  KEY `idx_supplier_id` (`supplier_id`),
  KEY `idx_contract_status` (`contract_status`),
  KEY `idx_sign_date` (`sign_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='采购合同主表';
```

### 第四步:输出SQL脚本

## 数据库设计规范要点

### 命名规范
- 【强制】表名、字段名必须使用小写字母或数字,禁止使用数字开头
- 【强制】表名不使用复数名词
- 【强制】禁用保留字(如 `desc`、`order`、`group` 等)
- 【强制】主键索引名为 `pk_字段名`,唯一索引名为 `uk_字段名`,普通索引名为 `idx_字段名`
- 【强制】关联表要以`_rela`结尾,如`scm_purchase_contract_rela`
- 【强制】表名要求模块名强相关,如系统采用`sys`作为前缀,项目管理模块采用`pm`作为前缀等。

### 表设计规范
- 【强制】使用 `InnoDB` 存储引擎
- 【强制】使用 `utf8mb4` 字符集
- 【强制】表必须有主键
- 【强制】禁止使用外键,应用层保证数据一致性
- 【推荐】字段数限制在 20 以内

### 字段设计规范
- 【强制】使用 `VARCHAR` 代替 `CHAR`
- 【强制】使用 `NOT NULL` 并设置默认值
- 【强制】金额必须使用 `DECIMAL` 类型
- 【强制】时间类型使用 `DATETIME` 或 `TIMESTAMP`
- 【推荐】枚举值使用 `CHAR(2)`,需维护枚举类映射
- 【推荐】大文本使用 `TEXT` 类型
- 【推荐】IP 地址使用 `VARCHAR(39)`(支持 IPv6)
- 【强制】在不同的库或表中,要保证所有存储相同数据的列名和列类型必须一致
- 【强制】必须把字段定义为NOT NULL并设默认值,避免NULL值带来的问题

### 索引设计规范
- 【强制】区分度高的字段适合建索引(唯一值越多越好)
- 【强制】不在低区分度字段建索引(如性别)
- 【强制】不在 `WHERE`、`ORDER BY` 不涉及的字段建索引
- 【推荐】联合索引字段数不超过 5 个
- 【推荐】遵循最左前缀原则
- 【推荐】覆盖索引优先

## 示例

**用户输入:**
```
我需要设计一个销售合同管理表,业务规则如下:
- 合同编号唯一,格式:HT+年月日+4位流水号
- 包含客户、合同金额、签订日期、合同状态
- 状态:草稿/执行中/已完成/已终止
- 需要记录创建人和更新人
```

**助手输出:**
```sql
DROP TABLE IF EXISTS `sm_sales_contract`;

CREATE TABLE `sm_sales_contract` (
  `id` VARCHAR(32) NOT NULL COMMENT '主键ID',
  `contract_no` VARCHAR(64) NOT NULL COMMENT '合同编号',
  `customer_id` VARCHAR(32) NOT NULL COMMENT '客户ID',
  `contract_amount` DECIMAL(18,2) NOT NULL COMMENT '合同金额',
  `contract_status` TINYINT NOT NULL DEFAULT 0 COMMENT '合同状态(0-草稿 1-执行中 2-已完成 3-已终止)',
  `sign_date` DATE NOT NULL DEFAULT CURRENT_DATE COMMENT '签订日期',
  `remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_by` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '创建人ID',
  `update_by` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '更新人ID',
  `deleted` TINYINT NOT NULL DEFAULT 0 COMMENT '逻辑删除标识(0-未删除 1-已删除)',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_contract_no` (`contract_no`),
  KEY `idx_customer_id` (`customer_id`),
  KEY `idx_contract_status` (`contract_status`),
  KEY `idx_sign_date` (`sign_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='销售合同主表';
```

## 注意事项

1. **版本兼容性**
   - MySQL 8.0 支持函数索引、降序索引、不可见索引
   - 如需兼容 5.7,避免使用新特性

2. **性能优化**
   - 避免过度索引,每个表的索引数量不超过 5 个
   - 大字段(TEXT/BLOB)单独拆表
   - 考虑分表策略(按时间、按业务)

3. **安全性**
   - 敏感字段加密存储
   - 软删除代替硬删除
   - 审计日志完整性

4. **扩展性**
   - 预留扩展字段
   - JSON 字段用于非结构化数据(MySQL 5.7+)
   - 考虑未来分库分表可能性

Related Skills

Presentation Mastery — Complete Slide Design & Delivery System

3891
from openclaw/skills

You are a Presentation Architect. You help build presentations that persuade, inform, and move people to action. You cover the full lifecycle: audience analysis → narrative structure → slide design → delivery coaching → post-presentation follow-up.

Content & Documentation

ui-designer

3891
from openclaw/skills

Design beautiful interfaces using 16+ design systems including Material You, Fluent Design, Apple HIG, Ant Design, Carbon Design, Shopify Polaris, Minimalism, Glassmorphism, Neo-Brutalism, Neumorphism, Skeuomorphism, Claymorphism, Swiss Design, and Atlassian Design. Expert in Tailwind CSS, color harmonics, component theming, and accessibility (WCAG).

UI Design & Prototyping

instructional-design-cn

3891
from openclaw/skills

培训课程大纲设计、效果评估、内部分享材料生成

Workflow & Productivity

designer-intelligence-station

3891
from openclaw/skills

设计师情报收集工具。监控 40 个公开信息源(AI/硬件/手机/设计),6 维筛选标准 v2.0(基于 120+ 条行为分析),生成结构化日报/周报。仅抓取公开内容,不登录、不提交表单、不绕过付费墙。支持依赖自动检测和安装。

Data & Research

SendTradeSignal

3891
from openclaw/skills

A specialized tool for sending quantitative trading signals to the FMZ platform via HTTP API.

Finance & Trading

design-inspiration-collector

3891
from openclaw/skills

多平台设计灵感收集技能。当用户需要设计参考、UI灵感、视觉创意时触发。用户提出设计方向(如"医疗App"、"移动端UI"、"金融Dashboard"等),技能负责:(1) 使用Tavily搜索Behance、Dribbble、Pinterest三个平台的相关内容 (2) 整理内容并附上链接 (3) 生成腾讯文档,文档命名为"关键词+日期时间"格式 (4) 发送文档链接给用户 (5) 推荐其他相关方向(不带链接)。触发词:找灵感、收集灵感、设计参考、UI参考、视觉灵感、设计趋势、Behance、Dribbble、Pinterest。

crm-antdesign-admin-spec

3891
from openclaw/skills

Design, structure, review, and generate B2B CRM or admin pages using an Ant Design-style system with page taxonomy, reusable layout rules, token guidance, component mapping, and AI-generation constraints. Use when the user wants a CRM/admin dashboard, statistics page, AI analytics page, list page, customer page, or configuration/tool page that must stay implementation-friendly and visually consistent.

design-style

3891
from openclaw/skills

Use this skill when the user asks to build, create, design, develop, or improve ANY frontend interface, web page, UI component, or visual element. This includes: - Building landing pages, websites, web apps, dashboards, portfolios, or any web interface - Creating UI components (buttons, forms, cards, navbars, modals, etc.) - Designing pages with React, Vue, Next.js, Svelte, or any frontend framework - Adding styling or improving visual design of existing components - Implementing specific design aesthetics (modern, dark, minimalist, brutalist, etc.) - User mentions "frontend", "UI", "UX", "design", "interface", "web design", or "styling" - User asks for "beautiful", "modern", "professional", "clean", or any aesthetic adjective - User requests help with CSS, Tailwind, styled-components, or any styling approach This skill automatically retrieves the appropriate design system prompt (Neo-brutalism, Modern Dark, Bauhaus, Cyberpunk, Material, etc.) to help create visually distinctive, production-grade frontend code instead of generic UI. IMPORTANT: Trigger this skill proactively for ANY frontend/UI work, not just when design style is explicitly mentioned.

Ant Design 组件库 (antd)

3891
from openclaw/skills

## 描述

vaccine-design-orchestrator

3891
from openclaw/skills

Use this skill when the user wants to evaluate a new nanoparticle vaccine candidate, redesign a computational screening workflow, define gate criteria, or produce a Go/Hold/Kill decision.

skill_creator_design

3891
from openclaw/skills

生成定制化的设计项目 Skill(含 SKILL.md + references/),为用户的设计过程提供从需求定义到 交付的持续引导。触发场景:用户表达想做设计相关工作("我想设计 X""做个 X 的方案" "帮我设计一个 X""出个设计""改版 X""重新做一下 X""想想 X 怎么做""design X" "redesign X"),或要求生成设计规划、设计 skill("创建设计项目""generate a design skill" "帮我规划一下这个设计")。涵盖产品设计、交互设计、体验设计、信息架构、视觉方案等。 安装本 skill 即表明用户倾向于系统化设计管理——遇到设计意图时优先触发,而非直接进入 即时头脑风暴。

ad-designer

3891
from openclaw/skills

Generate marketing ad images using Nano Banana Pro (Gemini 3 Pro Image). Accepts campaign-planner creative briefs, reads brand bible for visual style, constructs marketing-optimized prompts, and produces platform-ready images at correct aspect ratios. Supports 1:1, 9:16, 16:9, 4:5 formats. Includes self-review loop to catch hallucinated logos, wrong text, and quality issues. Draft-first workflow (1K fast iteration, 4K final). Outputs to /tmp/marketing/assets/images/.