agentleFS
igmarinigmarin/elixir-phoenix-skills/skills/ecto-essentials/SKILL.md

ecto-essentials

Skill4 starsChanged 4 months agoMITView on GitHub

Use for Ecto schemas, queries, changesets, associations, preloads, transactions, and persistence boundaries in an existing Elixir project.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

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

    Follow the repository's Ecto and database conventions.

    line 11
  2. Very specific:

    Use cast/3 with an explicit field allowlist for external maps.

    line 16
  3. Very specific:

    Keep association ownership and delete behavior explicit.

    line 18
  4. Distinctive:

    Keep reusable filters and ordering in query functions.

    line 23
  5. Very specific:

    Use Repo.one/1, Repo.all/1, and bang variants according to the caller's expected absence and error contract.

    line 25
  6. Very specific:

    Use Ecto.Multi when a transaction has multiple named steps or its failure step matters to the caller.

    line 30
  7. Distinctive:

    Do not put network calls or other irreversible side effects inside a database transaction.

    line 31
  8. Very specific:

    Add or update tests for the changed persistence behavior.

    line 36

≈ “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

Ecto Essentials

Follow the repository's Ecto and database conventions. Keep business rules in the context or pure domain modules; keep Repo calls at the persistence edge.

Schemas and changesets

  • Model persisted data in schemas and validate external input with changesets.
  • Use cast/3 with an explicit field allowlist for external maps. Use change/2 for trusted internal updates.
  • Attach database constraints to changesets with unique_constraint/3, foreign_key_constraint/3, or the matching constraint helper so expected database errors return changeset errors.
  • Keep association ownership and delete behavior explicit. Use cast_assoc/3 only when nested input is part of the public operation.

Queries and associations

  • Compose Ecto.Query fragments with named bindings and parameterized values. Never interpolate user input into SQL.
  • Keep reusable filters and ordering in query functions; keep policy and orchestration in the context.
  • Preload what the caller needs. For lists, inspect query counts and prefer joins or batched preloads over per-row Repo.get/2 calls.
  • Use Repo.one/1, Repo.all/1, and bang variants according to the caller's expected absence and error contract.

Writes and transactions

  • Return {:ok, value} / {:error, changeset_or_reason} from expected failures.
  • Use Ecto.Multi when a transaction has multiple named steps or its failure step matters to the caller. Use a normal transaction for a small atomic block.
  • Do not put network calls or other irreversible side effects inside a database transaction.
  • For upserts, state the conflict target and verify the database constraint matches it.

Verification

Add or update tests for the changed persistence behavior. Run the focused test, then the project checks that cover Ecto and migrations. Use ecto-changeset-patterns, ecto-nested-associations, or ecto-migration only when that narrower behavior is central.

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.