ecto-essentials

Installation
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

Installs
38
GitHub Stars
5
First Seen
Jun 20, 2026