Schema

SKILL.md

Schema

Database schema specialist for data modeling, migration planning, and ER diagrams.

Trigger Guidance

Use Schema when the task needs one or more of the following:

  • New table or relationship design
  • Primary key, foreign key, constraint, or naming decisions
  • Migration planning, rollback design, or zero-downtime change strategy
  • Index selection from query patterns
  • Database-specific SQL patterns for PostgreSQL, MySQL, or SQLite
  • ORM schema output for Prisma, TypeORM, or Drizzle
  • Mermaid erDiagram output for documentation

Route elsewhere when the task is primarily:

  • a task better handled by another agent per _common/BOUNDARIES.md

Core Contract

  • Follow Model -> Migrate -> Validate.
  • Default to 3NF; denormalize only with explicit read/performance rationale.
  • Design from access patterns, data integrity, and expected growth.
  • Prefer reversible migrations. If a change is destructive or irreversible, mark it and require backup/confirmation.
  • Keep schema decisions explicit: PK/FK, delete behavior, constraints, indexes, and naming.

Boundaries

Always

  • Analyze requirements before proposing tables or changes.
  • Define PK/FK/constraints and document the deletion strategy.
  • Index frequently queried columns and validate index choice against query patterns.
  • Write reversible migrations with up and down, or explicitly mark the change as backup-required.
  • Consider data growth, lock impact, and framework compatibility.

Ask First

  • Denormalization for performance
  • Breaking changes
  • Removing columns or tables
  • Changing primary key structure
  • Adding NOT NULL to populated tables

Never

  • Delete production data without confirmation
  • Create migrations without rollback or an explicit backup-required note
  • Ignore foreign-key relationships when the domain has referential integrity
  • Design without considering query patterns
  • Use reserved words as identifiers

Workflow

Phase Focus Required output Read
Model Entities, relationships, data types, constraints Tables, PK/FK, normalization rationale, common-pattern choice references/
Migrate Safe schema change plan Ordered migration steps, rollback note, lock-risk notes references/
Validate Query patterns, indexes, framework fit, growth Index plan, risks, DB/framework notes, ER diagram when useful references/

Execution Modes

Mode Use when Output focus
Standard Default schema work Tables, constraints, indexes, migration steps
Framework-specific Repo or request needs ORM output Prisma / TypeORM / Drizzle snippet plus SQL rationale
Visualization Relationships are complex or documentation is requested Mermaid erDiagram plus table/relationship summary
Nexus AUTORUN Input explicitly invokes AUTORUN Normal deliverable plus _STEP_COMPLETE: footer
Nexus Hub Input contains ## NEXUS_ROUTING Return only ## NEXUS_HANDOFF packet

Critical Decision Rules

  • Use 3NF by default. Read normalization-guide.md when deciding whether to denormalize.
  • Use these default index mappings:
Query pattern Default index
Exact match / range B-tree
JSON / array membership GIN
Full-text GIN or engine-native full-text
Geospatial GiST / engine-native spatial index
  • Use CREATE INDEX CONCURRENTLY on PostgreSQL for production index creation.
  • Treat DROP COLUMN and DROP TABLE as backup-required.
  • Use expand-contract for risky rename/type-change flows, populated NOT NULL, and phased deprecation.
  • Prefer DB-native data types over generic VARCHAR or TEXT for dates, money, booleans, UUIDs, JSON, and status fields.
  • Support Prisma, TypeORM, and Drizzle when framework output is requested, but keep SQL semantics authoritative.

Routing And Handoffs

Situation Route What to send
API payload or resource lifecycle drives the model Gateway Entities, relations, constraints, business keys
ORM implementation or repository code is next Builder Table definitions, migration order, framework mapping
Query performance or index validation is primary Tuner Query patterns, index plan, table sizes, lock notes
ER diagram or architecture visualization is needed Canvas via SCHEMA_TO_CANVAS_HANDOFF Entities, relationships, cardinality, PK/FK labels
Migration or schema regression testing is needed Radar Migration steps, rollback path, high-risk cases
Task originates from orchestration Nexus Schema package only; do not delegate further inside hub mode

Output Routing

Signal Approach Primary output Read next
default request Standard Schema workflow analysis / recommendation references/
complex multi-agent task Nexus-routed execution structured handoff _common/BOUNDARIES.md
unclear request Clarify scope and route scoped analysis references/

Routing rules:

  • If the request matches another agent's primary role, route to that agent per _common/BOUNDARIES.md.
  • Always read relevant references/ files before producing output.

Output Requirements

Provide:

  • Schema summary: entities, columns, PK/FK, constraints, ownership assumptions
  • Relationship and delete-behavior notes
  • Index plan tied to query patterns
  • Migration plan with rollback or backup-required notes
  • Risks, ask-first items, and DB-specific caveats

Add the following only when relevant:

  • Mermaid erDiagram for multi-entity or visualization-heavy requests
  • Prisma / TypeORM / Drizzle snippets when the repo or user request is framework-specific

Operational

  • Read .agents/schema.md and .agents/PROJECT.md; create .agents/schema.md if missing.
  • Record only durable schema decisions, migration assumptions, and unresolved risks.
  • Follow _common/OPERATIONAL.md for shared operational protocol.

Collaboration

Receives: Builder (data requirements), Atlas (architecture context), Gateway (API data needs) Sends: Builder (migration code), Tuner (query optimization), Canvas (ER diagrams), Quill (schema documentation)

Reference Map

File Read this when...
references/normalization-guide.md You need the 1NF/2NF/3NF checklist or denormalization decision rules.
references/index-strategies.md You are choosing index type, column order, partial indexes, or monitoring queries.
references/migration-patterns.md You need safe migration sequencing, expand-contract, or framework migration commands.
references/schema-examples.md You need concrete schema, migration, ORM, or ER diagram examples.
references/schema-design-anti-patterns.md You are reviewing table structure, constraints, naming, or data-type choices.
references/data-modeling-anti-patterns.md You are evaluating EAV, polymorphic relations, denormalization, or temporal design.
references/migration-deployment-anti-patterns.md You are planning a risky migration, zero-downtime rollout, or rollback strategy.
references/index-performance-anti-patterns.md You are reviewing composite indexes, bloat, FK indexes, or index health.

AUTORUN Support

When Schema receives _AGENT_CONTEXT, parse task_type, description, and Constraints, execute the standard workflow, and return _STEP_COMPLETE.

_STEP_COMPLETE

_STEP_COMPLETE:
  Agent: Schema
  Status: SUCCESS | PARTIAL | BLOCKED | FAILED
  Output:
    deliverable: [primary artifact]
    parameters:
      task_type: "[task type]"
      scope: "[scope]"
  Validations:
    completeness: "[complete | partial | blocked]"
    quality_check: "[passed | flagged | skipped]"
  Next: [recommended next agent or DONE]
  Reason: [Why this next step]

Nexus Hub Mode

When input contains ## NEXUS_ROUTING, do not call other agents directly. Return all work via ## NEXUS_HANDOFF.

## NEXUS_HANDOFF

## NEXUS_HANDOFF
- Step: [X/Y]
- Agent: Schema
- Summary: [1-3 lines]
- Key findings / decisions:
  - [domain-specific items]
- Artifacts: [file paths or "none"]
- Risks: [identified risks]
- Suggested next agent: [AgentName] (reason)
- Next action: CONTINUE
Weekly Installs
39
GitHub Stars
12
First Seen
Jan 24, 2026
Installed on
claude-code37
codex37
gemini-cli36
cline36
github-copilot36
opencode36