agentleFS
Vimalk0703Vimalk0703/shipworthy/skills/architecture/database-design/SKILL.md

database-design

Skill6 starsChanged 8 months agoMITView on GitHub

Schema design, migrations, indexing, naming conventions, and query performance. Prevents N+1 queries, missing indexes, and irreversible schema changes.

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 10 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

  • GenerativeAgentsSkill

    architecture-design

    アーキテクチャ設計書を作成するための詳細ガイドとテンプレート。アーキテクチャ設計時にのみ使用。

    Also in 8 projects that use this

  • +8 more from xfstudio

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 41 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Timestamps: always include created_at and updated_at

    line 14
  2. Distinctive:

    Every foreign key MUST have a constraint

    line 18
  3. Distinctive:

    Use appropriate column types (don't store dates as strings)

    line 19
  4. Distinctive:

    Use enums/check constraints for fixed value sets

    line 21
  5. Distinctive:

    Every schema change goes through a migration — never modify DB directly

    line 24
  6. Distinctive:

    Never query inside a loop

    line 44
  7. Distinctive:

    Use pagination for large result sets

    line 46

“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

Database Design

Naming Conventions

  • Tables: plural, snake_case (user_profiles, order_items)
  • Columns: singular, snake_case (first_name, created_at)
  • Primary keys: id
  • Foreign keys: {table_singular}_id (user_id, order_id)
  • Timestamps: always include created_at and updated_at
  • Booleans: prefix with is_ or has_

Data Integrity

  • Every foreign key MUST have a constraint
  • Use appropriate column types (don't store dates as strings)
  • Set NOT NULL on columns that should never be empty
  • Use enums/check constraints for fixed value sets

Migrations

  1. Every schema change goes through a migration — never modify DB directly
  2. Migrations must be reversible (include up and down)
  3. One concern per migration
  4. Name descriptively: add_email_verification_to_users

Indexing

  • Must index: foreign keys, WHERE clause columns, ORDER BY columns, JOIN columns
  • Avoid: indexing every column, missing composite indexes, indexing low-selectivity columns

N+1 Prevention

// BAD: 1 + N queries
for (const user of users) {
  user.orders = await db.orders.findByUserId(user.id);
}
// GOOD: 2 queries
const users = await db.users.findAll({ include: ['orders'] });

Rules

  • Never query inside a loop
  • Set LIMIT on all list queries
  • Use pagination for large result sets
  • Log slow queries (>100ms)
  • Maintain seed data for dev/testing

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.