agentleFS
sohaibdevvsohaibdevv/AI-AGENT-SKILLS/skills/database-design/SKILL.md

database-design

Skill2 starsChanged 6 months agoMITView on GitHub

Schema design, migrations, indexing, and query patterns for maintainable and performant databases

42 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use intelligent-routing, i18n-localization and 9 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.
  • tiendatworkSkill

    intelligent-routing

    Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.

    Also in 3 projects that use this

  • xfstudioSkill

    i18n-localization

    Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

    Also in 5 projects that use this

  • xfstudioSkill

    behavioral-modes

    AI operational modes (brainstorm, implement, debug, review, teach, ship, orchestrate). Use to adapt behavior based on task type.

    Also in 3 projects that use this

  • +8 more from xfstudio

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 41 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before designing a new table or collection

    line 14
  2. Distinctive:

    Before writing a database migration

    line 15
  3. Distinctive:

    When queries are slow and the cause is suspected to be the schema or indexes

    line 16
  4. Distinctive:

    When designing a new service's data layer

    line 17
  5. Distinctive:

    Start with a normalized design.

    line 25
  6. Distinctive:

    Use UUIDs or ULIDs for globally unique IDs (not auto-increment integers for externally visible IDs)

    line 28
  7. Distinctive:

    Never expose integer sequence IDs to users (enumeration attack)

    line 29
  8. Distinctive:

    Ensure IDs are indexed

    line 30
  9. Distinctive:

    Every migration must be backward compatible with the current code:

    line 33
  10. Distinctive:

    Never drop a column in the same deploy that stops using it.

    line 38
  11. Very specific:

    Run EXPLAIN on every hot query before deploying.

    line 43
  12. Very specific:

    Every table should have: created_at, updated_at.

    line 49
  13. Distinctive:

    Test every migration against a production-size dataset:

    line 52

“Common” is measured: kept by at least 6 in 10 of the 41 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

Overview

Database schemas are among the hardest things to change in a production system. Migrations run during live traffic. Indexes affect every query. Schema choices made today constrain options for years. This skill gets them right from the start.

When to Use

  • Before designing a new table or collection
  • Before writing a database migration
  • When queries are slow and the cause is suspected to be the schema or indexes
  • When designing a new service's data layer

Process

Step 1: Design for the queries, not just the data

Understand the access patterns before normalizing. Which queries are in the critical path? What are the read/write ratios? This drives index and schema decisions.

Step 2: Normalize first, denormalize deliberately

Start with a normalized design. Denormalize only when profiling shows it's necessary, and document why.

Step 3: Choose IDs carefully

  • Use UUIDs or ULIDs for globally unique IDs (not auto-increment integers for externally visible IDs)
  • Never expose integer sequence IDs to users (enumeration attack)
  • Ensure IDs are indexed

Step 4: Migrations - backward compatible first

Every migration must be backward compatible with the current code:

  1. Deploy migration (add new column, add new table)
  2. Deploy code that uses the new column
  3. Deploy cleanup migration (drop old column) - only after old code is gone

Never drop a column in the same deploy that stops using it.

Step 5: Index strategy

Index columns that appear in WHERE clauses, JOIN conditions, and ORDER BY of hot queries. Don't over-index - each index slows writes.

Run EXPLAIN on every hot query before deploying.

Step 6: Soft deletes vs hard deletes

For audit trails, compliance, or reference integrity: use soft deletes (deleted_at timestamp). For data that must be truly erased (GDPR): implement hard delete + audit log.

Step 7: Timestamps and audit columns

Every table should have: created_at, updated_at. Tables with audit requirements: created_by, updated_by.

Step 8: Test migrations

Test every migration against a production-size dataset:

  • Does it run in an acceptable time window?
  • Does it lock tables in ways that will cause timeouts?
  • Can it be rolled back?

Verification Requirements

  • Access patterns identified before schema designed
  • Migrations are backward compatible
  • Hot queries have EXPLAIN run
  • Indexes added for WHERE/JOIN/ORDER BY columns
  • Migration tested against production-size data
  • Rollback for migration documented

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.