estack-ecto

Installation
SKILL.md

Ecto patterns

Read the project's Repo, auth scope, schemas, database adapter, and installed Ecto version. If the app uses Ash resources, use its actions and policies rather than bypassing them with Repo calls.

Ownership and action authorization

Accept the existing authenticated scope at the context boundary. Cast only client-editable fields; set ownership from trusted identity. The following is an illustrative context fragment; Scope, Report, Policy, and Repo are application modules:

def create_report(%Scope{user: user} = scope, attrs) do
  with :ok <- Policy.authorize(scope, :create_report) do
    %Report{user_id: user.id}
    |> Report.create_changeset(attrs)
    |> Repo.insert()
  end
end

In create_changeset, omit :user_id, :tenant_id, roles, and other protected fields from cast. Do not atomize arbitrary client keys. Use action-specific changesets so update input cannot change ownership. Keep caller parameters consistently string-keyed or atom-keyed as required by Ecto; do not mix them while stamping ownership.

Installs
1
GitHub Stars
31
First Seen
Oct 16, 2026