Token导航 LogoToken导航

Agent Skill · 研究检索

database-schema-design(数据库模式设计)

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

database-schema-design 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 47,767。

总安装 720周安装 30GitHub Stars 1下载 240核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/pixel-process-ug/superkit-agents --skill database-schema-design

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

database-schema-design 用于辅助数据库表结构和查询语句编写,适合 SQL 脚本和迁移建议生成。适用于 schema 分析、索引整理和查询问题排查的场景。明确数据库类型和连接环境,区分只读分析与写入变更;涉及删除或更新时优先备份保护。

通过 npx skills add 命令从指定 GitHub 仓库安装并使用该技能。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/database-schema-design

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/pixel-process-ug/superkit-agents --skill datab…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

database-schema-design 怎么安装?

在终端执行 npx skills add https://github.com/pixel-process-ug/superkit-agents --skill database-schema…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

database-schema-design 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

database-schema-design 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

database-schema-design 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

database-schema-design 用的人多吗?

公开数据是累计安装 720 次,近一周安装 30 次,下载 240 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

database-schema-design 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
database-schema-design

数据库模式设计 · 本页

7201需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Database Schema Design

Overview

Guide the design, implementation, and optimization of database schemas with sound data modeling, safe migrations, effective indexing, and appropriate query patterns. This skill covers the full lifecycle from conceptual modeling through physical optimization, ensuring schemas that are normalized, performant, and safely evolvable.

Announce at start: "I'm using the database-schema-design skill to design the database schema."

Phase 1: Discovery and Conceptual Model

Ask these questions to understand the data requirements:

#QuestionWhat It Determines
1What entities does the system manage?Table names
2What are the relationships between entities?Foreign keys, join tables
3What are the key attributes of each entity?Column definitions
4What are the primary query patterns?Index strategy
5What is the expected data volume? (rows, growth rate)Partitioning, scaling
6What is the read/write ratio?Normalization vs denormalization
7SQL or NoSQL? (or both?)Storage engine selection

Storage Engine Decision Table

FactorChoose SQL (PostgreSQL, MySQL)Choose Document (MongoDB)Choose Key-Value (Redis)
Data shapeStructured, relationalSemi-structured, nestedSimple lookups, caching
Query complexityComplex joins, aggregationsDocument-level queriesKey-based access only
Consistency needsACID requiredEventual consistency OKEphemeral or cached data
Schema evolutionMigrations manageableSchema-free flexibilityNo schema
Scale patternVertical first, then read replicasHorizontal shardingIn-memory, limited size

STOP after discovery — present the conceptual model (entities, relationships, cardinality) for confirmation.

Phase 2: Logical Model Design

Translate the conceptual model into tables, columns, types, and constraints.

Column Design Rules

DecisionGuidance
Primary keysUUIDs for distributed systems, auto-increment for single-node
Column typesUse the most specific type (timestamptz not varchar for dates)
NullabilityDefault NOT NULL; allow NULL only when absence is meaningful
DefaultsSet sensible defaults (created_at DEFAULT now())
ConstraintsAdd CHECK, UNIQUE, and FK constraints at the schema level
Namingsnake_case, singular table names or plural — be consistent

Normalization Guide

Normal FormRuleViolation ExampleFix
1NFAtomic values, no repeating groupstags VARCHAR "urgent,priority,vip"Separate order_tags table
2NFAll non-key columns depend on entire PKproduct_name in order_items (composite PK)Move to products table
3NFNo transitive dependenciescity depends on zip_code, not user_idSeparate zip_codes table

Rule: Always start normalized. Denormalize only with measured evidence.

Denormalization Decision Table

ScenarioPatternWhen to Apply
Read-heavy dashboardsMaterialized views or summary tablesMeasured slow query
Frequently joined dataEmbed as JSONB columnJoin is >80% of query time
Reporting / analyticsSeparate denormalized reporting tablesOLAP workload
Caching layerComputed columns refreshed on writeHigh-frequency reads

Relationship Patterns

RelationshipImplementationIndex Needed
One-to-OneFK with UNIQUE constraint on childOn FK column
One-to-ManyFK on the "many" sideOn FK column
Many-to-ManyJunction/join table with composite PKOn both FK columns
PolymorphicSeparate FK columns with CHECK constraint (preferred) or type+id patternOn type+id or each FK
Self-referential (trees)parent_id FK to same table; or ltree/materialized pathOn parent_id or path

STOP after logical model — present the table definitions for review.

Phase 3: Physical Model and Indexing

Index Type Decision Table

Index TypeBest ForExample
B-tree (default)Equality and range queriesCREATE INDEX idx_users_email ON users(email)
GINFull-text search, JSONB, arraysCREATE INDEX idx_posts_search ON posts USING GIN(to_tsvector('english', body))
PartialSubset of rows matching conditionCREATE INDEX idx_active_users ON users(email) WHERE active = true
Covering (INCLUDE)Index-only scans avoiding table lookupCREATE INDEX idx_users_email ON users(email) INCLUDE (name)
CompositeMulti-column queriesCREATE INDEX idx_orders ON orders(tenant_id, status)

Composite Index Column Order

PositionColumn TypeReason
FirstHigh-cardinality equality columnsMost selective filter first
MiddleAdditional equality columnsFurther narrows results
LastRange columns (dates, numbers)Range scan on remaining rows

Rule: A composite index on (A, B, C) supports queries on A, A+B, A+B+C — but NOT B alone or C alone.

Query Optimization Checklist

Signal in EXPLAIN ANALYZEProblemFix
Seq Scan on large tableMissing indexAdd appropriate index
Nested Loop with large outer tableInefficient joinAdd index or restructure query
High actual vs estimated rowsStale statisticsRun ANALYZE on table
Hash Join high memorywork_mem too lowTune work_mem or restructure

N+1 Detection and Prevention

-- N+1 problem (bad):
SELECT * FROM users;
-- Then for EACH user: SELECT * FROM orders WHERE user_id = ?;

-- Fixed with join:
SELECT u.*, o.* FROM users u LEFT JOIN orders o ON o.user_id = u.id;

-- Fixed with batch load:
SELECT * FROM orders WHERE user_id = ANY($1);

STOP after physical model — present indexes and optimization strategy for review.

Phase 4: Migration Strategy

Zero-Downtime Migration (Expand-Contract)

Never make a breaking change in a single migration. Use two phases:

Expand phase (backward compatible):

  1. Add new column/table (nullable or with default)
  2. Deploy code that writes to both old and new
  3. Backfill existing data in batches
  4. Deploy code that reads from new

Contract phase (after all code uses new schema):

  1. Remove code that writes to old
  2. Drop old column/table

Migration Safety Rules

RuleRationale
Every migration has a corresponding rollbackSafe to revert
Test rollback in staging before productionVerify reversibility
Data-destructive rollbacks need explicit approvalPrevent accidental data loss
Keep migration files immutable once appliedReproducible state
Backfill large tables in batches (1000 rows)Avoid table locks

Backfill Pattern

-- Backfill in chunks of 1000
UPDATE users SET display_name = username
WHERE display_name IS NULL
AND id IN (SELECT id FROM users WHERE display_name IS NULL LIMIT 1000);

Migration Type Decision Table

Change TypeSafe ApproachDangerous Approach
Add columnAdd nullable or with defaultAdd NOT NULL without default
Remove columnExpand-contract (two deploys)Drop column directly
Rename columnAdd new, copy data, drop oldALTER RENAME (breaks queries)
Add indexCREATE INDEX CONCURRENTLYCREATE INDEX (locks table)
Change column typeAdd new column, migrate dataALTER COLUMN TYPE (locks table)

STOP after migration plan — confirm rollback strategy before finalizing.

Phase 5: Save and Transition

After explicit approval:

  1. Save schema design to docs/database/ or generate migration files
  2. Commit with message: docs(db): add schema design for <feature>

Transition Decision Table

User IntentNext SkillRationale
"Create the migrations"planningPlan migration implementation
"Write specs for this"spec-writingBehavioral specs for data operations
"Implement the schema"test-driven-developmentTDD with migration tests
"Just save the design"NoneSchema design is the deliverable
"Review for performance"performance-optimizationAnalyze query patterns

ORM Guidance

ORMLanguageStrengthWatch Out For
PrismaTypeScriptType-safe schema, migrationsN+1 in nested queries, limited raw SQL
DrizzleTypeScriptSQL-like API, lightweightNewer ecosystem, fewer guides
SQLAlchemyPythonMature, flexible, raw SQL supportComplex session management
GORMGoConvention-based, auto-migrateSilent failures, implicit behavior

ORM Best Practices

  • Always review generated SQL (enable query logging in development)
  • Use eager loading to prevent N+1 queries
  • Write raw SQL for complex queries rather than fighting the ORM
  • Use ORM migrations, not auto-sync in production
  • Test query performance with realistic data volumes

Connection Pooling

  • Use a connection pooler (PgBouncer, built-in pool)
  • Pool size formula: connections = (CPU cores * 2) + disk spindles
  • Use transaction-level pooling for most workloads
  • Application servers should not open raw connections

Anti-Patterns / Common Mistakes

MistakeWhy It Is WrongWhat To Do Instead
No foreign key constraintsOrphaned data, broken relationshipsAlways define FK constraints
VARCHAR for everythingLoses type safety, wastes storageUse specific types (timestamptz, int, uuid)
No indexes on FK columnsSlow joins on related tablesIndex every FK column
Premature denormalizationComplexity without measured benefitStart normalized, denormalize with evidence
Dropping columns directlyBreaks running application codeUse expand-contract pattern
CREATE INDEX without CONCURRENTLYLocks table during index creationAlways use CONCURRENTLY in production
Auto-sync schema in productionUnpredictable destructive changesUse explicit migration files
No rollback plan for migrationsCannot recover from failed deployWrite down migration for every up migration
Nullable columns everywhereLoses data integrity guaranteesDefault NOT NULL, allow NULL intentionally

Anti-Rationalization Guards

  • Do NOT skip the conceptual model — understand entities and relationships first
  • Do NOT add indexes speculatively — measure query patterns first
  • Do NOT denormalize without measured evidence of a performance problem
  • Do NOT create migrations without rollback plans
  • Do NOT skip the discovery phase — understand query patterns and data volume
  • Do NOT drop columns or tables without expand-contract pattern in production

Documentation Lookup (Context7)

Use mcp__context7__resolve-library-id then mcp__context7__query-docs for up-to-date docs. Returned docs override memorized knowledge.

  • prisma — for schema syntax, relations, or migration API
  • typeorm — for entity decorators, repository patterns, or query builder
  • knex — for query builder syntax, migrations, or seed files

Integration Points

SkillRelationship
api-designUpstream: API resources map to database entities
spec-writingUpstream: specs define data persistence requirements
planningDownstream: schema design informs implementation plan
test-driven-developmentDownstream: migration tests written before migration code
performance-optimizationDownstream: query optimization after schema is live
reverse-engineering-specsUpstream: reverse-engineer existing schema behavior
senior-backendParallel: backend specialist for ORM and query patterns

Verification Gate

Before claiming the schema design is complete:

  1. VERIFY all entities and relationships are modeled
  2. VERIFY normalization is at least 3NF (or denormalization is justified)
  3. VERIFY indexes are defined for all query patterns and FK columns
  4. VERIFY migration strategy includes rollback for every step
  5. VERIFY the user has approved the schema design
  6. VERIFY connection pooling strategy is defined for production

Skill Type

Flexible — Adapt storage engine, normalization level, and index strategy to project needs while preserving the conceptual-to-physical modeling progression, migration safety rules, and measured-evidence-before-denormalization principle.

平台分布

Codex

35.15%
按下载量换算84

Claude

29.08%
按下载量换算70

Cursor

18.99%
按下载量换算46

Gemini CLI

9.9%
按下载量换算24

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills