agentleFS
leekleek/laravel-agent-rules/database/CLAUDE.md

laravel-agent-rules / database

CLAUDE.md9 starsChanged 2 months agoMITView on GitHub

Schema design + naming conventions. Sub-directory rules: MUST avoid SQL reserved words (e.g. order, group, desc, key, range) as identifiers. Prefer a more specific name (order_column, group_name). Order columns top-to-bottom as: When adding columns in later migrations on MySQL/MariaDB, SHOULD use after() / before() to preserve this ordering. Those modifiers are MySQL/MariaDB-only — Postgres, SQLite, and SQL Server do not support column positioning; omit them there.

The file

We split this CLAUDE.md into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    MUST: avoid SQL reserved words (e.g.

    line 19
  2. Distinctive:

    SHOULD: use auto-incrementing big integer for internal-only tables.

    line 24
  3. Distinctive:

    SHOULD: use UUID (or ULID) PK when the row will be exposed in a public URL or contains sensitive data (orders, invoices, bank accounts).

    line 25
  4. Very specific:

    SHOULD: add an index (or composite index) for filters, sorts, and joins that show up in real query paths — verify with EXPLAIN / slow-query …

    line 56
  5. Distinctive:

    MUST: add a composite index when multiple columns are queried together as a unit (and order columns to match the query).

    line 57
  6. Distinctive:

    SHOULD: use UUID/ULID for publicly addressable rows: external order numbers, public profile pages, signed invoices.

    line 63
  7. Very specific:

    SHOULD: keep id as an internal bigint and add a separate uuid column for external use, unless the project explicitly switches to UUID PKs.

    line 64

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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
CLAUDE.md

Database

Schema design + naming conventions. Sub-directory rules:

  • database/migrations/CLAUDE.md — migration workflow.
  • database/factories/CLAUDE.md — factory rules.
  • database/seeders/CLAUDE.md — seeder rules.

Naming

EntityPatternExamples
Tablesnake_case, pluralusers, products, categories
Pivot tablesnake_case, singular names, alphabeticalcategory_product, order_user
Columnsnake_case, no table prefixtitle, price, description
Primary keyalways idid
Foreign key{singular_model}_iduser_id, product_id, category_id

MUST avoid SQL reserved words (e.g. order, group, desc, key, range) as identifiers. Prefer a more specific name (order_column, group_name).

Primary keys

  • MUST name the PK id.
  • SHOULD use auto-incrementing big integer for internal-only tables.
  • SHOULD use UUID (or ULID) PK when the row will be exposed in a public URL or contains sensitive data (orders, invoices, bank accounts).

Foreign keys

  • MUST name {singular_model}_id.
  • SHOULD declare with foreignId(...)->constrained() and an explicit onDelete() policy.

Column type → name patterns

  • boolean → prefix is_ / has_ (is_enabled, has_reviews).
  • timestamp → suffix _at / _from / _for (published_at, valid_from, scheduled_for).
  • PREFER a nullable timestamp over a boolean when the moment of state-change is also useful: replace is_finished with finished_at — encodes two facts (whether + when) in one column.

Column sorting

Order columns top-to-bottom as:

  1. id
  2. Foreign keys
  3. Domain columns, ordered by priority and grouped by context
  4. Native timestamps (created_at, updated_at, deleted_at)

When adding columns in later migrations on MySQL/MariaDB, SHOULD use after() / before() to preserve this ordering. Those modifiers are MySQL/MariaDB-only — Postgres, SQLite, and SQL Server do not support column positioning; omit them there.

Common column patterns

  • order_column — sort position (avoid reserved word order as a column name).

Indexes

  • MUST index foreign keys (Laravel's foreignId() / foreignIdFor() adds one automatically) and columns that enforce uniqueness.
  • SHOULD add an index (or composite index) for filters, sorts, and joins that show up in real query paths — verify with EXPLAIN / slow-query logs rather than indexing every WHERE/ORDER BY column by habit.
  • MUST add a composite index when multiple columns are queried together as a unit (and order columns to match the query).
  • AVOID indexes on low-cardinality columns alone (booleans, small enums) unless they are part of a selective composite.
  • AVOID redundant single-column indexes that are already covered by a composite index's leading column.

UUIDs

  • SHOULD use UUID/ULID for publicly addressable rows: external order numbers, public profile pages, signed invoices.
  • SHOULD keep id as an internal bigint and add a separate uuid column for external use, unless the project explicitly switches to UUID PKs.

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.