agentleFS
MartinKChenMartinKChen/harness-claude-code/skills/pattern-architect-data-model/SKILL.md

pattern-architect-data-model

Skill0 starsChanged 5 months agoMITView on GitHub

Data-model shape and naming guidance: tables, columns, indexes, constraints, views, and the SQLAlchemy `MetaData` naming convention that emits predictable names. Every decision lands in the data contract at `docs/data-model/<entity>.yaml` which engineers implement against and reviewers verify. Activate when designing or reviewing a new table, model, or schema, or when asked 'how should I name this table/column/index/constraint?'. Skip for application-level query logic that doesn't change schema, and for code-first / migration / `migrate` compose / `alembic` mechanics.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    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:

    If the contract is missing for an entity the engineer is about to touch, this skill — not the engineer — owns adding it.

    line 78

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

pattern-architect-data-model

Standardize how we design data models: the shape of every entity — what gets named what, which columns it carries, how its constraints/indexes/views are spelled — follows a predictable convention so reviewers and tools can navigate the schema without surprises.

When to activate

Activate this skill whenever the user:

  • designs a new table, model, or schema ("add a users table", "model the orders domain")
  • adds, renames, or drops a column, index, or constraint
  • edits ORM model files (models.py, models/*.py, SQLAlchemy Base subclasses, Django models)
  • asks "how should I name this table/column/index/constraint?"
  • proposes a new entity at architecture-discovery time and is deciding its column shape and relationships

Pattern

Naming conventions

Tables — plural nouns, snake_case:

✅ users, orders, order_items, audit_logs
❌ user, Order, OrderItem, AuditLog

Columns — descriptive snake_case nouns. Avoid single-letter or generic names:

✅ email, created_at, total_amount_cents, shipping_address_id
❌ e, ts, amt, addr_id, data, info

Constraints, indexes, views — prefix with the kind, then table, then columns:

KindPrefixExample
Primary Keypk_pk_users
Foreign Keyfk_fk_orders_user_id
Indexidx_idx_orders_created_at
Unique Constraintuq_uq_users_email
Check Constraintck_ck_orders_positive_total
Viewvw_vw_active_users

SQLAlchemy MetaData naming convention

Pin the prefixes above at the MetaData level so every autogenerated migration emits predictable names — never rely on the dialect's anonymous defaults (they make downgrade() and name-parity tests impossible):

from sqlalchemy import MetaData

NAMING_CONVENTION = {
    "pk": "pk_%(table_name)s",
    "fk": "fk_%(table_name)s_%(column_0_name)s",
    "ix": "idx_%(table_name)s_%(column_0_name)s",
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_%(constraint_name)s",
}

metadata = MetaData(naming_convention=NAMING_CONVENTION)
# Base = declarative_base(metadata=metadata)  /  class Base(DeclarativeBase): metadata = metadata

Multi-column or rule-bearing artifacts still pass name= explicitly (UniqueConstraint("org_id", "email", name="uq_users_org_id_email")); the convention is the safety net, not a substitute for deliberate names on anything compound.

Recording the decision in the data-model contract

Every entity-shape decision this skill produces lands in docs/data-model/<entity>.yaml — one ODCS file per persistence entity (template: skills/workflow-writer-publish-architecture/templates/data-model.yaml). The contract is the single source of truth: engineers implement against it (pattern-engineer-database, the migration/ORM layer), E2E seed helpers conform to it (pattern-e2e-coding-standard), and reviewers verify against it (pattern-reviewer-contract). Do NOT decide entity shape in code, commit messages, or PR descriptions.

What the contract file declares, per entity: table name (plural snake_case physicalName), every column with type + nullability + default, PK/FK/unique/check constraints and indexes by their convention names above, FK ON DELETE/ON UPDATE policy, and relationship cardinality.

Cross-references: endpoint shape lives in the sibling docs/api-contract/<entity>.yaml; project-wide axes (ID strategy, timestamp policy) live in the relevant ADR — this contract inherits them rather than redefining.

If the contract is missing for an entity the engineer is about to touch, this skill — not the engineer — owns adding it. The engineer halts and surfaces "no data-model contract for <entity>" rather than guessing.

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.