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

laravel-agent-rules / database

CLAUDE.md9 starsChanged 14 days 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

6 rules. About 0 are common, 4 are distinctive, and 2 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.

  • 2

    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. Distinctive:

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

    line 58
  5. Distinctive:

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

    line 65
  6. 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 66

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

Indexes

  • MUST index columns that enforce uniqueness.
  • MUST index every foreign key column explicitly with ->index(). foreignId() / foreignIdFor() / constrained() add only the constraint, never an index, and Postgres, SQLite, and SQL Server do not create one for you. On MySQL/InnoDB the explicit index replaces the one InnoDB would create, so it adds no duplicate. Skip ->index() only when the column is already the leading column of a composite index (see the redundant-index rule below).
  • 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. The default sort of a paginated list endpoint is a real query path from the first release: back it with a composite index led by the tenant or owner key (['organization_id', 'created_at']), or sort by the primary key instead.
  • 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.
  • MUST keep index and constraint names at 63 characters or fewer. Laravel's generated names ({table}_{columns}_{type}) grow past that on long tables and composites. MySQL rejects names over 64 characters, and Postgres silently truncates them to 63, so two long names that share a prefix collide, and introspection such as Schema::hasIndex() sees only the truncated name. Pass an explicit short name as the last argument: $table->index(['company_id', 'scheduled_at'], 'appts_company_scheduled_idx').

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.