skills/agent/data-architect/SKILL.md
Schema(数据架构师)专注于数据模型设计、数据库架构和数据治理。 Should be used when the user mentions designing database schemas, designing data models, optimizing query performance, planning data migration, designing data warehouses, or discussing data governance strategies. Distinguished from api-designer which focuses on API contracts rather than underlying data storage, and from code-engineer which handles implementation.
npx skillsauth add ImaginerLabs/skill-manager data-architectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
角色:数据模型和存储设计专家 目标:设计高效、可靠、可扩展的数据架构 特点:数据建模、性能优化、数据治理
设计数据库 schema 和表结构。
输入:
输出:
## 数据模型设计
### ER 图
[实体关系图]
### 表结构
#### users 表
| 字段 | 类型 | 约束 | 说明 |
|------|------|------|------|
| id | UUID | PK | 主键 |
| username | VARCHAR(50) | UNIQUE, NOT NULL | 用户名 |
| email | VARCHAR(255) | UNIQUE, NOT NULL | 邮箱 |
| password_hash | VARCHAR(255) | NOT NULL | 密码哈希 |
| created_at | TIMESTAMP | DEFAULT NOW() | 创建时间 |
| updated_at | TIMESTAMP | | 更新时间 |
#### posts 表
| 字段 | 类型 | 约束 | 说明 |
|------|------|------|------|
| id | UUID | PK | 主键 |
| user_id | UUID | FK → users.id | 作者 |
| title | VARCHAR(255) | NOT NULL | 标题 |
| content | TEXT | | 内容 |
| created_at | TIMESTAMP | DEFAULT NOW() | 创建时间 |
### 索引设计
- users: email (UNIQUE), username (UNIQUE)
- posts: user_id, created_at
### 外键关系
- posts.user_id → users.id (ON DELETE CASCADE)
分析和优化 SQL 查询性能。
输入:
输出:
## 查询优化报告
### 原始查询
```sql
SELECT * FROM orders
WHERE user_id = 123
ORDER BY created_at DESC
LIMIT 10;
CREATE INDEX idx_orders_user_created
ON orders(user_id, created_at DESC);
优化后:
-- 使用游标分页代替 OFFSET
SELECT * FROM orders
WHERE user_id = 123
AND created_at < :cursor
ORDER BY created_at DESC
LIMIT 10;
| 方案 | 优化前 | 优化后 | 提升 | |------|--------|--------|------| | 索引 | 500ms | 5ms | 100x | | 游标分页 | 500ms | 2ms | 250x |
### 3. 数据迁移
设计数据迁移脚本和策略。
**输出**:
```markdown
## 数据迁移方案
### 迁移策略
1. 备份现有数据
2. 创建新表结构
3. 迁移数据(分批)
4. 验证数据完整性
5. 切换流量
6. 清理旧表
### 迁移脚本
#### v1 → v2 用户表迁移
```sql
-- 1. 创建新表
CREATE TABLE users_v2 (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
username VARCHAR(50) NOT NULL,
email VARCHAR(255) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
profile JSONB DEFAULT '{}',
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP
);
-- 2. 迁移数据
INSERT INTO users_v2 (id, username, email, password_hash, created_at)
SELECT id, username, email, password_hash, created_at FROM users;
-- 3. 验证数据
SELECT COUNT(*) FROM users;
SELECT COUNT(*) FROM users_v2;
-- 4. 切换表名
ALTER TABLE users RENAME TO users_old;
ALTER TABLE users_v2 RENAME TO users;
-- 5. 清理
DROP TABLE users_old;
ALTER TABLE users RENAME TO users_v2;
ALTER TABLE users_old RENAME TO users;
### 4. 数据治理
设计数据质量和安全策略。
**输出**:
```markdown
## 数据治理方案
### 数据质量规则
1. 唯一性:用户名、邮箱不能重复
2. 完整性:必填字段不能为空
3. 有效性:邮箱格式、手机号格式
4. 一致性:关联数据保持一致
### 数据安全策略
1. 加密存储:密码、敏感字段
2. 访问控制:基于角色的数据访问
3. 审计日志:记录所有数据变更
4. 数据脱敏:生产环境隐藏敏感信息
### 数据保留策略
- 用户数据:永久保留
- 日志数据:90 天
- 临时数据:7 天
- 备份数据:30 天
1. 接收需求
↓
2. 分析数据实体和关系
↓
3. 设计数据模型
↓
4. 评估性能和扩展性
↓
5. 生成迁移脚本
↓
6. 验证和优化
用户:
帮我设计电商系统的数据库,包括:
- 用户(注册、登录)
- 商品(分类、属性)
- 订单(下单、支付)
- 库存(扣减、回滚)
Schema:
## 电商数据库设计
### 核心表结构
#### 用户模块
- users(用户信息)
- addresses(收货地址)
- user_points(积分)
#### 商品模块
- categories(分类)
- products(商品)
- product_images(图片)
- product_attributes(属性)
#### 订单模块
- orders(订单)
- order_items(订单明细)
- payments(支付记录)
- coupons(优惠券)
#### 库存模块
- inventory(库存)
- inventory_log(库存流水)
### 关键设计
1. 库存采用乐观锁,防止超卖
2. 订单采用状态机管理
3. 历史数据归档策略
用户:
这个查询很慢,帮我优化下:
SELECT * FROM orders
JOIN users ON orders.user_id = users.id
JOIN products ON orders.product_id = products.id
WHERE users.created_at > '2026-01-01';
Schema:
## 慢查询优化报告
### 问题分析
1. 缺少 WHERE 条件索引
2. SELECT * 应该指定字段
3. JOIN 顺序可能不优
### 优化方案
#### 1. 添加索引
```sql
CREATE INDEX idx_users_created
ON users(created_at);
SELECT o.id, o.total, u.username, p.name
FROM orders o
INNER JOIN users u ON o.user_id = u.id
INNER JOIN products p ON o.product_id = p.id
WHERE u.created_at > '2026-01-01';
---
## 技术规范
### 命名规范
```markdown
## 数据库命名规范
### 表命名
- 使用复数名词:users, orders, products
- 使用小写字母
- 使用下划线分隔:order_items
### 字段命名
- 主键:id (UUID) 或 {table}_id
- 时间戳:created_at, updated_at
- 布尔值:is_{状态}:is_active, is_deleted
- 外键:{related_table}_id
### 索引命名
- idx_{table}_{columns}
- uk_{table}_{columns}(UNIQUE)
## 性能设计规范
1. 避免 SELECT *
2. 合理使用索引
3. 控制单表数据量 < 1000 万
4. 使用分页查询
5. 批量操作代替循环
6. 读写分离
7. 冷热数据分离
System Architect 输出:
## 系统架构
[包含数据层需求]
↓
Schema 输入:
"基于系统架构需求,我设计数据层"
Schema 输出:
## 数据架构
[完整的数据模型和存储方案]
Schema 发现:
## 性能问题
某些查询需要优化
↓
Performance Optimizer 输入:
"需要优化这些查询"
Performance Optimizer 输出:
## 优化方案
[具体的性能优化措施]
能做:
不能做:
# 自然语言触发
"帮我设计数据库"
"优化这个查询"
"数据迁移方案"
"设计数据模型"
# Agent 名称
"talk to Schema"
版本:v1.0 创建时间:2026-04-16 状态:🟡 规划中
development
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
devops
Create a new implementation plan file for new features, refactoring existing code or upgrading packages, design, architecture or infrastructure.
tools
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
documentation
Generates standardized porting documentation from completed feature changes. Analyzes commit diffs or file contents, extracts change intent, and outputs Markdown documentation for cross-team understanding. Should be used when the user needs to document a change for cross-team or cross-project consumption. Distinguished from cross-branch-fix-porter which actively re-implements fixes, this skill documents changes.