返回 Skill 列表
extension
分类: 开发与工程无需 API Key

db-schema-designer

根据需求、文档、演示或现有API为go-sphere及类似的后端项目设计可进行评审的数据库模式。当目标是在任何Ent实现或代码生成之前定义或审查实体、字段、关系、约束、索引、生命周期状态或模式演变时,请使用此技能。每当用户希望首先进行数据库设计、优先审查建模、讨论表结构或在编码前获得批准时,优先选择此技能。

person作者: jakexiaohubgithub

DB Schema Designer

Overview

Turn product and backend requirements into review-ready database design briefs.

This skill stops at the database design stage. Its job is to help humans review and approve the data model before any Ent schema coding, entproto annotations, or project integration work begins.

Because approved designs will later be implemented in Ent and exposed through proto3 messages, this skill must reject or redesign field types that do not map cleanly to the Ent + proto3 constraint set.

Scope Boundary

Do:

  1. Extract entities, fields, relationships, constraints, statuses, and timestamps.
  2. Design table-level structure, key naming, nullability, uniqueness, indexing, and field-type compatibility.
  3. Surface assumptions, trade-offs, and open questions for review.
  4. Produce a review brief using the required output template.

Do not:

  1. Write Ent schema code unless the user explicitly asks for a follow-up implementation step.
  2. Add entproto numbering or Go integration instructions.
  3. Mix bind/render/service tasks into the review document.

If the design is approved and code should be written, hand off to ent-schema-implementer.

Required Reading

Read these files in order before producing a database design:

  1. references/modeling-rules.md
  2. references/review-output-template.md

Workflow

Phase 1: Evidence and Extraction

  1. Gather inputs from prompt, docs, mockups, proto files, existing schemas, and service behavior.
  2. Extract candidate entities, lifecycle states, key timestamps, and business invariants.
  3. Record evidence conflicts and resolve them explicitly.

Phase 2: Database Design

  1. Design fields with type, requiredness, default behavior, uniqueness, and mutability.
  2. Apply the field-type policy from references/modeling-rules.md and redesign unsupported types before approval.
  3. Choose ID strategy and explain why.
  4. Design one-to-many and many-to-many relations.
  5. Build an index plan from list/filter/sort/query patterns.
  6. Decide deletion strategy, snapshot fields, and audit timestamps.

Phase 3: Review Packaging

  1. Mark assumptions explicitly as Assumption:.
  2. List unresolved questions and approval blockers clearly.
  3. Produce the final review brief using references/review-output-template.md.

Hard Gates

  1. The output must be understandable without showing Ent code.
  2. Every major table needs a business purpose, key fields, and lifecycle notes.
  3. Every proposed index must be tied to a real query pattern.
  4. Every field type must be checked against downstream Ent + proto3 compatibility before approval.
  5. If a type does not map cleanly, redesign it in the review output instead of deferring the problem to implementation.
  6. If the request is incomplete, stop at design options and blocking questions rather than forcing implementation details.
  7. If DDL is requested, provide it only as an optional appendix after the review brief, not as the primary artifact.

Output Requirements

Use the review template exactly:

  1. Keep section order unchanged.
  2. Write N/A for non-applicable sections.
  3. Include a dedicated field-type compatibility section.
  4. Separate confirmed design decisions from open questions.
  5. Keep the document review-oriented rather than code-oriented.