db-schema-designer
DB Schema Designer
Turn product and backend requirements into a review-ready database design — collaboratively, through dialogue.
This skill works through clarifying questions and incremental design sections rather than generating a complete document in one pass. The goal is a design the user has actively approved, not a document they need to diff against their intent.
Scope Boundary
Do:
- Ask clarifying questions one at a time to resolve ambiguities.
- Propose 2-3 design options for non-obvious decisions (deletion strategy, ID type, relation shape, etc.).
- Present the design incrementally — entities → fields → relations → indexes — pausing for feedback at each section.
- Surface assumptions, trade-offs, and open questions explicitly.
- Produce the final review brief once the user approves the full design.
Do not:
- Write Ent schema code unless the user explicitly asks for the follow-up implementation step.
- Add entproto numbering, Go integration instructions, or bind/render/service tasks.
- Silently pick a contentious default (soft delete, UUID, complex JSON) — surface it as a choice.
If the design is approved and code should be written, hand off to ent-schema-implementer.
Required Reading
Read these files before producing any design output:
- references/modeling-rules.md — field type policy, relation strategy, index rules
- references/review-output-template.md — final output structure
Checklist
Work through these in order. Use TodoWrite to create a task for each item.
- Explore inputs — read provided docs, proto files, mockups, existing schemas, service behavior
- Ask clarifying questions — one at a time, until entities and key behaviors are clear
- Propose design options — for any non-trivial decision, offer 2-3 choices with trade-offs
- Present entity overview — list candidate entities with purpose and lifecycle; get approval
- Present field design — table by table, with types, nullability, defaults; get approval
- Present relations and constraints — one-to-many, many-to-many, deletion, uniqueness; get approval
- Present index plan — tied to real query patterns; get approval
- Produce final review brief — using references/review-output-template.md
- Write review brief to disk — default path:
prd/DDL.md; usedesign/<feature>/schema.mdif the request is scoped to a named feature or change-id - User approves review brief — ask explicitly before handing off to
ent-schema-implementer
Process Flow
digraph db_schema_designer {
"Explore inputs" [shape=box];
"Ask clarifying questions\n(one at a time)" [shape=box];
"Enough to design?" [shape=diamond];
"Propose design options\nfor contentious decisions" [shape=box];
"Present entity overview" [shape=box];
"Approved?" [shape=diamond];
"Present field design\n(table by table)" [shape=box];
"Present relations & constraints" [shape=box];
"Present index plan" [shape=box];
"Produce final review brief" [shape=box];
"User approves brief?" [shape=diamond];
"Hand off to ent-schema-implementer" [shape=doublecircle];
"Explore inputs" -> "Ask clarifying questions\n(one at a time)";
"Ask clarifying questions\n(one at a time)" -> "Enough to design?";
"Enough to design?" -> "Ask clarifying questions\n(one at a time)" [label="no"];
"Enough to design?" -> "Propose design options\nfor contentious decisions" [label="yes"];
"Propose design options\nfor contentious decisions" -> "Present entity overview";
"Present entity overview" -> "Approved?";
"Approved?" -> "Present entity overview" [label="revise"];
"Approved?" -> "Present field design\n(table by table)" [label="yes"];
"Present field design\n(table by table)" -> "Approved?";
"Present relations & constraints" -> "Approved?";
"Present index plan" -> "Approved?";
"Approved?" -> "Present relations & constraints" [label="fields ok"];
"Approved?" -> "Present index plan" [label="relations ok"];
"Approved?" -> "Produce final review brief" [label="indexes ok"];
"Produce final review brief" -> "User approves brief?";
"User approves brief?" -> "Produce final review brief" [label="changes"];
"User approves brief?" -> "Hand off to ent-schema-implementer" [label="approved"];
}
Phase 1: Explore and Clarify
Before asking anything, check what is already available: prompt text, referenced docs, proto files, existing Ent schemas, API contracts, or mockups. Extract what you can without asking.
Then ask clarifying questions one at a time:
- Prefer multiple-choice questions when there are clear alternatives.
- Only one question per message — if you need more, come back after the answer.
- Focus on: missing entity boundaries, lifecycle states, business invariants, query patterns, and deletion semantics.
- Stop asking once you can make a reasonable design proposal.
Good question: "Should deleted records be recoverable, or is deletion permanent? A) Soft-delete (deleted_at field, recoverable) B) Hard-delete (row removed) C) Archive to a separate table"
Bad question: "Can you tell me more about your requirements?"
Phase 2: Design Options
For non-trivial decisions, present 2-3 options with trade-offs and your recommendation before proceeding. This is especially important for:
- ID strategy (int64 auto-increment vs. external ID vs. compound key)
- Deletion strategy (hard / soft / archive)
- Many-to-many shape (join table vs. relation entity with attributes)
- Complex field representation (JSON blob vs. explicit columns vs. relation entity)
- Money or decimal fields
Lead with your recommended option and explain why. The user picks; you proceed.
Phase 3: Incremental Design Presentation
Present the design in sections. After each section, ask whether it looks right before moving on.
Entity overview first — a simple table: entity name, purpose, key lifecycle states. No fields yet. Example:
"Here are the candidate entities. Does this set look right before we go into fields?"
Field design section by section — one entity at a time. Apply references/modeling-rules.md to every field:
- Check each field against the allowed type shapes.
- If a requested type doesn't fit (datetime object, UUID primary key, JSON blob, float money), redesign it here and explain the substitution.
- Note mutable vs. immutable fields explicitly.
Relations and constraints — cover one-to-many foreign keys, many-to-many shapes, uniqueness constraints, referential integrity, and deletion cascade rules.
Index plan — every index must be tied to a real, named query pattern (e.g., "list orders by user, paginated by created_at"). Never propose an index without a reason.
Phase 4: Final Review Brief
Once all sections are approved, produce the review brief using references/review-output-template.md exactly:
- Keep section order unchanged.
- Write
N/Afor non-applicable sections. - Include the field-type compatibility section with every type decision explained.
- Separate confirmed decisions from open questions clearly.
- Keep the document review-oriented, not code-oriented.
After producing the brief, write it to disk:
- Default:
prd/DDL.md - Feature-scoped:
design/<feature>/schema.md(use when the user names a specific module or change-id)
Then ask the user to review it:
"Design brief written to
<path>. Please look it over — if anything needs adjusting, let me know and I'll update it. Once you're happy, I can hand off toent-schema-implementerto start writing the Ent schemas."
Wait for explicit approval before handing off.
Key Principles
- One question at a time — don't stack questions; wait for the answer
- Multiple choice preferred — easier to respond to than open-ended
- Surface choices, don't bury them — contentious defaults must be presented as options
- Explain type redesigns — when a requested type is replaced, say why clearly
- Every index needs a query — no speculative indexes
- Approved design before final document — the brief captures decisions already made together, not decisions being revealed for the first time
More from go-sphere/skills
ent-seed-sql-generator
Generate deterministic INSERT SQL seed data from Go Ent schemas and mixed inputs. This skill is REQUIRED whenever you need to create seed SQL for development or testing - it handles entity inference, relationship integrity, stable IDs, and dialect-specific SQL generation including JSON, arrays, and complex types. Use this skill for any task involving seed data, test fixtures, demo initialization, or database population from Ent schema definitions, even if the user doesn't explicitly mention "seed" or "SQL".
27pure-admin-crud-generator
Generate CRUD pages and router modules for pure-admin-thin from local swagger API definitions. MUST be used whenever you need to scaffold admin list/edit/detail pages, dashboard views, or route configurations from existing API methods in src/api/swagger/Api.ts. This skill replaces manual Vue page creation - use it for any admin panel development task involving API-driven pages.
25proto-api-generator
Design proto3 + HTTP API contracts for go-sphere scaffold projects from prompts, input folders, or requirement docs with mock data. Use when defining service APIs, selecting between entpb/shared/custom messages, and enforcing scaffold conventions, router-safety rules, and service-local error placement. This skill is REQUIRED for any proto API design task in go-sphere scaffold - always use it instead of writing proto files from scratch.
21sphere-feature-workflow
Implement end-to-end feature changes in go-sphere scaffold projects by following sphere-layout conventions and generation workflow. Use when adding or modifying APIs, protobuf contracts, Ent schemas, bind/map registration, service logic, or cross-layer refactors that must stay protocol-first and avoid manual edits to generated files. This skill is REQUIRED for any task involving go-sphere proto files, Ent schemas, service implementations, or generation commands (make gen/proto, make gen/docs, make gen/wire).
19proto-service-generator
Generate or complete Go service implementations from protobuf-generated HTTP interfaces in go-sphere scaffold projects. Use when you need to create `internal/service/<module>/*.go` files, add missing method implementations to existing services, or generate compilable stubs for new proto endpoints. Trigger for: service implementation, proto handler, append-only update, interface assertion, CRUD via Ent, stub method generation.
18ent-schema-generator
Design and generate Go + Ent database schemas for sphere-layout projects from requirements. Use when users describe data models, entity relationships, database tables, or schema changes — including prompts, Markdown docs, existing proto/service files, or demo behavior. Produces implementation-ready schema plans with field definitions, ID strategies, relation designs, indexes, entproto annotations, and bind/render/service integration guidance.
16