agentleFS
SWEStashSWEStash/swe-workflow-skills/skills/data-modeling/SKILL.md

data-modeling

Skill1 starsChanged 4 days agoMITView on GitHub

Design database schemas, relationships, indexes, and migration strategies — relational and document stores. Triggers: data model, schema design, ER diagram, database schema, table design, foreign key, index strategy, normalization, denormalization, migration plan, document model, partition key.

16 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use observability, accessibility and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 6 projects that use this

  • ElasticSkill

    accessibility

    Accessibility guidance for Kibana. Use this skill when working with or reviewing EUI components, resolving a11y-related (@elastic/eui) ESLint issues, and ensuring proper use of ARIA attributes, focus management, keyboard interactions, and accessible naming conventions.

    Also in 5 projects that use this

  • AnthropicSkill

    documentation

    Write and maintain technical documentation. Trigger with "write docs for", "document this", "create a README", "write a runbook", "onboarding guide", or when the user needs help with any form of technical writing — API docs, architecture docs, or operational runbooks.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 11 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If any database exists, establish what it already holds before proposing a single new table, column, or index.

    line 14
  2. Distinctive:

    Before touching schemas, understand the business domain:

    line 44
  3. Distinctive:

    If the user describes a feature rather than a domain, extract the entities from the feature description first.

    line 52
  4. Distinctive:

    1NF: No repeating groups; every column holds atomic values

    line 68
  5. Distinctive:

    2NF: Every non-key column depends on the whole primary key

    line 69
  6. Distinctive:

    3NF: No transitive dependencies (non-key → non-key)

    line 70
  7. Distinctive:

    Use templates/schema.md as a starting point for table DDL, index naming, enum patterns, and migration file structure.

    line 84
  8. Distinctive:

    If modifying an existing schema:

    line 88
  9. Distinctive:

    Backwards-compatible changes: Add columns with defaults, add tables, add indexes

    line 90
  10. Distinctive:

    KISS: Start normalized; denormalize only when measured performance demands it

    line 109
  11. Distinctive:

    YAGNI: Don't add columns or tables "just in case"

    line 111

“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Data Modeling

Guide the user through designing data models that are normalized, consistent, and evolvable. Good data models make the right things easy and the wrong things hard.

Workflow

Step 0: Inventory What Already Exists

If any database exists, establish what it already holds before proposing a single new table, column, or index. Inspect the current schema directly — don't infer it from the requirements, the ORM models, or memory. Dump it from the live database where you can reach one, otherwise read the migration history end to end.

Cover both:

  • Artifacts — existing tables, columns, and indexes that hold, or could hold, the fact in question. Grep for the concept by name and by synonym; the right table is often named for a different concern than the one you're serving.
  • Written decisions — ADRs, schema conventions, and prior audit findings that already constrain the shape.

Exit condition — one line, then keep going in the same response: "<existing table> already stores <fact>; it does / does not serve this because <reason>."

This step is not a gate on delivering. Greenfield — no database yet, or none you can reach — closes it in one line: say so and go straight to Step 1. When you can't inspect (no repo access, a conversational answer), name what you would check and continue under stated assumptions. Never answer a schema request with inventory and questions alone; produce the model in the same reply.

This constrains the input, not the choice. A new table is a fine outcome; an unexamined one isn't — and a second home for the same fact is duplication however well it's named.

Step 1: Understand the Domain

Before touching schemas, understand the business domain:

  • What are the core entities? (nouns in the requirements: User, Order, Product)
  • What are the relationships? (verbs: User places Order, Order contains Products)
  • What are the cardinalities? (one-to-one, one-to-many, many-to-many)
  • What are the access patterns? (how will the data be queried most often)
  • What are the invariants? (rules that must always hold: "an order must have at least one item")

If the user describes a feature rather than a domain, extract the entities from the feature description first.

Step 2: Design the Conceptual Model

Produce an entity-relationship description listing:

  • Each entity with its key attributes
  • Relationships with cardinality (1:1, 1:N, M:N)
  • Business rules that constrain the model

Present this as a structured list or ASCII diagram. Don't jump to SQL yet — validate the conceptual model with the user first.

Step 3: Apply Normalization

Design tables following normalization principles:

  • 1NF: No repeating groups; every column holds atomic values
  • 2NF: Every non-key column depends on the whole primary key
  • 3NF: No transitive dependencies (non-key → non-key)

Denormalize only with explicit justification (specific read performance requirement with measured data). Document every denormalization decision and the access pattern it serves.

Step 4: Define the Physical Schema

Produce SQL DDL or ORM model definitions. For each table include:

  • Primary key strategy (auto-increment, UUID, ULID — justify the choice)
  • Foreign keys with ON DELETE/ON UPDATE behavior
  • Indexes based on identified access patterns
  • Constraints (NOT NULL, UNIQUE, CHECK) that enforce business rules
  • Timestamps (created_at, updated_at) as appropriate

Use templates/schema.md as a starting point for table DDL, index naming, enum patterns, and migration file structure.

Step 5: Plan the Migration

If modifying an existing schema:

  • Backwards-compatible changes: Add columns with defaults, add tables, add indexes
  • Breaking changes: Require a migration strategy (expand-contract pattern)
  • Data backfills: Script them, don't do them manually

Produce migration files appropriate to the ORM/framework in use. Each migration should be independently reversible.

Step 6: Validate

Cross-check the schema against:

  • Every acceptance criterion from the feature plan can be served by the schema
  • Every identified access pattern has an appropriate index
  • Every business invariant is enforced by constraints
  • No data can be orphaned (foreign keys and cascades are correct)
  • The migration is reversible

Principles Applied

  • DRY: Single source of truth for each piece of data
  • KISS: Start normalized; denormalize only when measured performance demands it
  • Functional Independence: Each table represents one concept
  • YAGNI: Don't add columns or tables "just in case"

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.