AGENT SKILL

数据库模式设计与审查

database-schema-designer

设计或审查数据库模式(schema)。在数据建模、创建表/集合、选择 SQL 还是 NoSQL、模式规范化、规划索引、编写迁移脚本,或审计数据库完整性与性能时使用。

适用职业数据库管理员
使用场景数据库管理
License 许可
MIT
所属仓库
carterdea/dots
最近更新
2026-11-15
Stars
★ 4
Forks
3

01 前言 Front Matter

name
database-schema-designer
license
MIT
description
Design or review database schemas. Use when modeling data, creating tables/collections, choosing SQL vs NoSQL, normalizing schemas, planning indexes, writing migrations, or auditing database integrity and performance.

02 资源文件 64

03 SKILL.md 正文

Database Schema Designer

Design database schemas from domain requirements and access patterns. The main job is not to emit tables quickly; it is to produce a schema that preserves data integrity, fits the workload, and can evolve safely.

References

Load only the reference that matches the branch you are in:

Dialect Policy

  • Ask for the target database when syntax matters.
  • Default examples to PostgreSQL-compatible SQL unless the request names another dialect.
  • Translate identity columns, timestamp defaults, indexes, JSON types, generated columns, and migration syntax to the chosen dialect before presenting final DDL.
  • Do not emit MySQL-only syntax (AUTO_INCREMENT, inline INDEX, ON UPDATE CURRENT_TIMESTAMP, ALTER TABLE ... MODIFY) for PostgreSQL or SQLite requests.
  • If the request names MongoDB or document storage, switch to the NoSQL branch and model around access patterns.

Workflow

1. Gather The Shape

Extract or ask for:

  • Entities or collections.
  • Relationships and cardinality.
  • Read/write access patterns.
  • Scale hints, tenancy, and retention requirements.
  • Database engine and dialect.
  • Existing schema or migration constraints, when this is a review or evolution task.

Completion criterion: every table/collection you propose maps to a domain concept or named access pattern, and every unknown that affects syntax or integrity is either resolved or listed as an assumption.

2. Choose The Storage Model

Use SQL by default for transactional domains with relationships, constraints, joins, reporting correctness, or evolving business rules.

Use NoSQL/document modeling only when access patterns are known and documents are usually read/written together, or when the user explicitly asks for it.

Completion criterion: the output states why SQL or NoSQL fits the workload, and names the tradeoff that would make the other choice better.

3. Design The Schema

For SQL, load references/sql-design.md. Design from the domain outward:

  • Normalize to 3NF first unless a specific read path justifies denormalization.
  • Define primary keys, foreign keys, ON DELETE behavior, NOT NULL, UNIQUE, and CHECK constraints.
  • Choose dialect-appropriate data types.
  • Add timestamps only where lifecycle tracking is useful.

For NoSQL, load references/nosql-design.md. Design around access patterns:

  • Choose embedded documents when data is read together and bounded.
  • Use references when child sets are large, independently updated, or shared.
  • Keep document size and update frequency explicit.

Completion criterion: every relationship has an ownership/cardinality decision, every required field has an integrity rule, and every intentional duplicate/denormalized value names the query it serves.

4. Plan Indexes From Queries

Indexes follow access patterns, not vibes. List the query patterns first, then add indexes for:

  • Foreign keys and joins.
  • High-frequency WHERE, ORDER BY, and uniqueness checks.
  • Composite queries with column order matched to the query.
  • Partial, text, or geospatial indexes only when the query shape calls for them.

Completion criterion: every non-primary index has a named query/use case, and the output calls out write-cost or over-indexing risks.

5. Plan Migration Safety

For new schemas, provide DDL and initial indexes.

For schema changes, make migrations reversible and deployment-aware:

  • Add nullable columns before enforcing NOT NULL.
  • Backfill separately from schema changes for large tables.
  • Dual-write/read-compatibly for renames.
  • Avoid long locks; use dialect-safe concurrent index patterns where needed.

Completion criterion: migration output includes an UP path, a DOWN path or explicit irreversible-risk note, and the rollout order needed to keep existing app versions working.

6. Review Before Final

Before responding, load references/schema-design-checklist.md for any substantial design or review task.

Completion criterion: final output includes the relevant checklist results or a concise "review notes" section covering primary keys, relationships, constraints, indexes, migrations, and unresolved risks.

Output Shape

Use the smallest useful structure for the request:

  • New schema: assumptions, schema DDL or document shapes, indexes, migration notes, review notes.
  • Schema review: findings ordered by severity, specific table/field/index references, fixes, and migration risk.
  • Index request: access patterns, proposed indexes, query examples, tradeoffs.
  • Migration request: rollout plan, UP, DOWN, backfill/dual-write notes, lock risk.
  • SQL vs NoSQL decision: recommendation, access-pattern reasoning, rejected alternative, risk.

Core Rules

  • Model the domain, not the UI.
  • Prefer database-enforced integrity over app-only conventions.
  • Use DECIMAL/exact numeric types for money; never use floating point for currency.
  • Index foreign keys unless the dialect already does and you have verified that behavior.
  • Treat SELECT *, missing foreign keys, unbounded documents, and non-reversible migrations as review findings.
  • Do not invent production scale, access patterns, or business rules. State assumptions when the prompt omits them.

04 同仓库更多 Skills

carterdea
carterdea/dots

test-audit

Writing/changing/reviewing/sweeping tests: reject duplicate or implementation-coupled proof; remove test-only production seams.

★ 4
carterdea
carterdea/dots

untangle-codebase

Untangle a whole codebase in one pass, so agents working in it read less per change, break less without noticing, and debug faster.

★ 4
carterdea
carterdea/dots

write-swift

How to write modern Swift well — modeling with value types, Swift 6 data-race safety and approachable concurrency (@concurrent, main-actor-by-default, actors, task groups), protocols and generics (some vs any), API design, performance and ARC, Swift Testing, macros, and the modern language features agents don't know about yet. Use when writing, reviewing, or migrating Swift, or when a concurrency error, a hang, a data race, a retain cycle, or a performance problem needs fixing.

★ 4
carterdea
carterdea/dots

stageshow

Build faux product UI that looks like a real product, as a still illustration or an animated demo with a cursor. Browser and app windows, dashboards, phones, notifications, terminals, bento grids and cursor walkthroughs, framed, masked and cropped the way a marketing page, feature card or docs hero needs them. Use whenever someone wants a fake or mocked UI, a product demo or walkthrough animation, a hero or feature-card illustration of an app, a product shot in the style of a polished marketing site, or an animated cursor doing things in an interface, even if they never say "faux UI". React and plain CSS.

★ 4
carterdea
carterdea/dots

review-animations

Reviews animation and motion code against a high craft bar derived from Emil Kowalski's design engineering philosophy. Default to flagging; approval is earned.

★ 4
carterdea
carterdea/dots

remove-animations

Find the animations an interface doesn't need and remove them — motion on keyboard actions, high-frequency surfaces, functional data, and decoration with no purpose — then clean up what they leave behind. Edits code, but only to subtract; it never adds or retunes motion. Use when the user says the app "feels slow", "has too much animation", "feels over-animated", wants to "tone down the motion", or asks what animations to remove. For finding places that should animate, use find-animation-opportunities; for fixing animations that should stay, use improve-animations or review-animations.

★ 4