Token导航 LogoToken导航TokenDH.com
前端设计只读github未标认证来源可访问clear审计通过

database-designer数据库设计师

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

333

周安装

14

GitHub Stars

16

下载量

116
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:database-designer(数据库设计师)
来源仓库:https://github.com/shining319/claude-code-single-person-workflow
仓库路径:skills/database-designer
安装命令:
npx skills add https://github.com/shining319/claude-code-single-person-workflow --skill database-designer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/shining319/claude-code-single-person-workflow --skill database-designer

简介

可生成生产就绪的完整数据库模式文档与可视化 ER 图。

  • 遵循无物理外键、字段大小合理、命名规范等设计原则。
  • 输出包含 SQL 脚本、注释说明及 DrawDB 兼容图表文件。
  • 需用户提供详细需求描述并确认目标数据库类型方可启动流程。
  • database-designer 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Database Designer

Design complete, production-ready database schemas based on user requirements. Generate comprehensive documentation, SQL scripts, and visual ER diagram files compatible with DrawDB.

Core Design Principles

Before starting any design, always read references/design-principles.md to understand:

  • No physical foreign keys (logical relationships only)
  • Realistic field sizes based on actual usage
  • Minimal, strategic index design
  • Mandatory comments on all tables and fields
  • Default system fields (id, timestamps, soft delete)
  • snake_case naming conventions

Workflow

Step 1: Understand Requirements

Gather information about the database design:

  1. Database type: MySQL 8.0 (default), PostgreSQL, SQL Server, etc.
  2. Business domain: E-commerce, blog, CRM, ERP, etc.
  3. Core entities: What are the main tables needed?
  4. Key features: What functionality should the database support?
  5. Special requirements: Any specific constraints or preferences?

If the user provides minimal information, intelligently infer missing details based on common business scenarios and best practices documented in references/design-examples.md.

Key inference scenarios:

  • User says "design a user table" → Infer: username, password, email, phone, status
  • User says "e-commerce system" → Infer: user, product, order, order_detail tables
  • User says "blog system" → Infer: user, article, comment, tag, article_tag tables

Step 2: Load Reference Documentation

Based on the design requirements, load appropriate references:

  • Always load: references/design-principles.md for core design rules
  • For format generation: references/drawdb-formats.md for JSON/DBML specifications
  • For examples: references/design-examples.md for similar system designs

Step 3: Design Database Schema

Create complete table structures following these guidelines:

Table Design Checklist

For each table:

  • ✅ Add default system fields (unless user specifies otherwise):

- id BIGINT AUTO_INCREMENT PRIMARY KEY - created_at DATETIME DEFAULT CURRENT_TIMESTAMP - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP - is_deleted TINYINT(1) DEFAULT 0

  • ✅ Design business fields with realistic sizes:

- username: VARCHAR(50) - email: VARCHAR(100) - phone: VARCHAR(20) - title: VARCHAR(200) - description: TEXT - See references/design-principles.md for complete size standards

  • ✅ Add appropriate constraints:

- NOT NULL for required fields - DEFAULT values for optional fields - UNIQUE for fields requiring uniqueness (but not as foreign keys)

  • ✅ Add COMMENT to every table and field (in Chinese)
  • ✅ Do NOT create physical FOREIGN KEY constraints

Index Design Strategy

For each table, analyze and create indexes for:

  1. WHERE clause fields: Fields frequently used in filtering
  2. JOIN fields: All xxx_id foreign key fields
  3. ORDER BY / GROUP BY fields: Sorting and grouping fields
  4. Unique constraints: email, phone, order_no, etc. → UNIQUE indexes

Index naming conventions:

  • Ordinary index: idx_field_name or idx_field1_field2
  • Unique index: uk_field_name

Index limits:

  • Maximum 5 indexes per table (unless user requests more)
  • Only create indexes that directly support business queries

Relationship Design

Identify logical relationships between tables:

  1. One-to-Many (1:N): Most common

- Example: user (1) → order (N) - Implementation: Add user_id in order table - DrawDB: many-to-one relationship

  1. One-to-One (1:1): For table splitting

- Example: user (1) → user_profile (1) - Implementation: Add user_id UNIQUE in user_profile table - DrawDB: one-to-one relationship

  1. Many-to-Many (N:N): Requires junction table

- Example: article (N) ↔ tag (N) - Implementation: Create article_tag junction table with article_id + tag_id - DrawDB: Two many-to-one relationships

Step 4: Generate Outputs

Create all required output files:

4.1 Comprehensive Design Document (Markdown)

Create a single, well-structured Markdown file containing:

Structure:

# [Project Name] 数据库设计文档

## 1. 数据库概览
- 数据库类型
- 字符集
- 核心表数量
- 主要功能模块

## 2. 表结构设计

### 2.1 [Table Name]
**表名**: table_name
**说明**: Table description

**字段列表**:
| 字段名 | 类型 | 允许空 | 默认值 | 说明 |
|--------|------|--------|--------|------|
| id | BIGINT | NO | | Primary key |
| ... | ... | ... | ... | ... |

**索引列表**:
| 索引名 | 类型 | 字段 |
|--------|------|------|
| uk_email | UNIQUE | email |
| idx_username | INDEX | username |

### 2.2 [Next Table]
...

## 3. 表关系说明
- table1 → table2 (1:N): Description
- table3 ↔ table4 (N:N): Description via junction table

## 4. 索引策略说明
Explain the rationale behind index design decisions

4.2 SQL Script

Create executable SQL script with:

-- Database: project_name
-- Generated: YYYY-MM-DD

-- Drop tables if exists (in reverse dependency order)
DROP TABLE IF EXISTS `table3`;
DROP TABLE IF EXISTS `table2`;
DROP TABLE IF EXISTS `table1`;

-- Create tables (in dependency order)
CREATE TABLE `table1` (
  `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Comment',
  ...
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_field` (`field`),
  KEY `idx_field` (`field`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Table comment';

CREATE TABLE `table2` (
  ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Table comment';

4.3 DrawDB JSON Format

Generate DrawDB-compatible JSON file following references/drawdb-formats.md:

Critical Format Requirements:

  • Table IDs: Use random 21-character strings (e.g., "_KV5MtPf2m4sI7Inu8pat")
  • Field IDs: Use random 21-character strings (e.g., "B8rPRTDtOv9oD2Gp4bhWL")
  • Index IDs: Use numeric increments starting from 0 (across ALL tables)
  • Relationship IDs: Use random 21-character strings
  • Field type: Include complete type definition (e.g., "VARCHAR(100)", not separate type and size)
  • No size field: Type info is embedded in the type string
  • Index fields: Use field name strings, NOT field IDs (e.g., ["email"] not [1])
  • Coordinates: Use floating-point numbers for x/y positions

ID Generation:

import random
import string

def generate_id():
    chars = string.ascii_letters + string.digits + '_-'
    return ''.join(random.choice(chars) for _ in range(21))

Layout Strategy:

  • Use grid layout: x = (index % 3) * 450 + 50, y = floor(index / 3) * 400 + 50
  • Rotate through predefined colors: ["#6360f7", "#bc49c4", "#ffe159", "#89e667", "#ff9159", "#59d9ff", "#ff5959", "#a0a0a0"]

Relationship Generation:

  • Generate relationships for all xxx_id foreign key fields
  • Use the actual random string IDs for tables and fields
  • Set cardinality based on UNIQUE constraint:

- Has UNIQUE → "one_to_one" - No UNIQUE → "many_to_one"

Structure:

{
  "tables": [
    {
      "id": "random_string",
      "name": "table_name",
      "comment": "表注释",
      "color": "#6360f7",
      "fields": [
        {
          "id": "random_string",
          "name": "id",
          "type": "BIGINT",
          "default": "",
          "check": "",
          "primary": true,
          "unique": true,
          "notNull": true,
          "increment": true,
          "comment": "主键ID"
        }
      ],
      "indices": [
        {
          "id": 0,
          "fields": ["field_name"],
          "name": "idx_field_name",
          "unique": false
        }
      ],
      "x": 50.0,
      "y": 50.0
    }
  ],
  "relationships": [
    {
      "name": "",
      "startTableId": "random_string",
      "endTableId": "random_string",
      "endFieldId": "random_string",
      "startFieldId": "random_string",
      "id": "random_string",
      "updateConstraint": "No action",
      "deleteConstraint": "No action",
      "cardinality": "many_to_one"
    }
  ],
  "notes": [],
  "subjectAreas": [],
  "database": "generic",
  "types": [],
  "title": "Project Database"
}

4.4 DrawDB DBML Format

Generate DBML file following references/drawdb-formats.md:

Key points:

  • Use lowercase data types: bigint, varchar(50), datetime
  • Add attributes in brackets: [pk, increment, not null, unique, note: '注释']
  • Define indexes inside table definition in indexes {} block
  • Define relationships outside tables using Ref blocks
  • Use proper relationship symbols: > (many-to-one), - (one-to-one)

Structure:

Table table_name [headercolor: #6360f7] {
  id bigint [pk, increment, not null, unique, note: 'Comment']
  field varchar(100) [not null, note: 'Comment']

  indexes {
    field [unique, name: 'uk_field']
  }

  Note: 'Table comment'
}

Ref fk_name {
  table1.field > table2.id [delete: no action, update: no action]
}

Step 5: Finalize and Deliver

5.1 Output Directory Convention

Recommended Approach (Following Claude Code Official Standards):

Save all database design files to outputs/<project-name>/database/:

outputs/
└── <project-name>/              # Project name (e.g., e-commerce-system)
    └── database/
        ├── schema-design.md     # Comprehensive design document
        ├── schema.sql           # Executable SQL script
        ├── drawdb-schema.json   # DrawDB JSON format
        └── drawdb-schema.dbml   # DrawDB DBML format

Example:

outputs/
├── e-commerce-system/
│   └── database/
│       ├── schema-design.md
│       ├── schema.sql
│       ├── drawdb-schema.json
│       └── drawdb-schema.dbml
└── task-management-app/
    └── database/
        ├── schema-design.md
        └── schema.sql

Alternative Approach (Traditional Project Structure):

If your project has an existing directory structure, you can also use:

project-root/
└── database/
    ├── schema-design.md
    ├── schema.sql
    ├── drawdb-schema.json
    └── drawdb-schema.dbml

5.2 Output File List

Required Outputs (4 files):

  • schema-design.md - Comprehensive database design document (Chinese)
  • schema.sql - Executable SQL script
  • drawdb-schema.json - DrawDB JSON format
  • drawdb-schema.dbml - DrawDB DBML format

Optional Outputs:

  • er-diagram.png - ER diagram visualization (if tools available)
  • index-strategy.md - Index strategy documentation

5.3 File Naming Convention

  • Use kebab-case: user-authentication-schema.sql
  • Include version/date when needed: schema-v1.0.sql or schema-2024-12-10.sql
  • Use descriptive names: e-commerce-database-schema.sql

5.4 Delivery Summary

After generating all files, provide a summary with:

  • Brief overview of design decisions
  • Number of tables created
  • Key relationships and their rationale
  • How to import into DrawDB (JSON or DBML)
  • File save location confirmation
  • Next steps suggestions (e.g., review indexes, implement in development environment)

Special Handling

When User Says "No System Fields"

Only create minimal structure:

CREATE TABLE `table_name` (
  `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  /* business fields only */
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Table comment';

When User Specifies Non-MySQL Database

Adapt SQL syntax accordingly:

PostgreSQL:

  • Use SERIAL or BIGSERIAL instead of AUTO_INCREMENT
  • Use TIMESTAMP instead of DATETIME
  • Different syntax for defaults and constraints

SQL Server:

  • Use IDENTITY(1,1) instead of AUTO_INCREMENT
  • Use DATETIME2 instead of DATETIME
  • Use NVARCHAR for Unicode support

Oracle:

  • Use SEQUENCE for auto-increment
  • Use VARCHAR2 instead of VARCHAR
  • Use DATE or TIMESTAMP for time fields

When Requirements Are Vague

Apply intelligent inference:

  1. Identify the business domain (e-commerce, blog, CRM, etc.)
  2. Reference similar examples in references/design-examples.md
  3. Include common fields appropriate to the domain
  4. Design reasonable indexes based on typical query patterns
  5. Explain assumptions made in the design document

Quality Verification

Before finalizing, verify:

  • All tables have COMMENT
  • All fields have COMMENT
  • Field sizes are realistic (not generic VARCHAR(255))
  • Index count per table ≤ 5
  • No physical FOREIGN KEY constraints
  • System fields added (unless user specified otherwise)
  • All names use snake_case
  • Logical relationships documented clearly
  • SQL syntax matches target database type
  • JSON/DBML formats follow DrawDB specifications
  • All foreign key relationships have corresponding Ref entries

Example Invocations

User says: "设计一个电商系统的数据库,包括用户、商品、订单功能" → Read design-principles.md and design-examples.md → Design: user_info, product_info, order_info, order_detail tables → Generate all 4 output files

User says: "Design a blog database" → Infer: user, article, comment, tag, article_tag tables → Follow standard design principles → Generate all outputs

User says: "Create a user table for PostgreSQL" → Single table design → Adapt SQL syntax for PostgreSQL → Include in all output formats

References

  • references/design-principles.md - Core design rules and standards
  • references/drawdb-formats.md - JSON and DBML format specifications
  • references/design-examples.md - Real-world design examples

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.13%
按下载量换算31

windsurf

21.72%
按下载量换算25

trae

17.53%
按下载量换算20

OpenCode

11.82%
按下载量换算14

Codex

7.16%
按下载量换算8

github-copilot

3.23%
按下载量换算4

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills