/estack:estack-ectofrom estack
Implements Ecto data access patterns: ownership, changesets, scoped queries, transactions, and safe migrations. Use when editing schemas, queries, tenant-scoped contexts, or database writes.
Ships in estack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
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.
# Illustrative owner-only lookup using the project's Scope struct.
def get_report(%Scope{user: %{id: user_id}}, id) do
case Repo.one(from r in Report, where: r.user_id == ^user_id and r.id == ^id) do
nil -> {:error, :not_found}
report -> {:ok, report}
end
end
Scope reads, updates, deletes, aggregates, preloads, and background work. For organizations, scope to authorized membership and the selected tenant; a user ID alone is not a tenancy model. Avoid blanket admin bypasses unless the product's policy explicitly grants that access.
Authorize the requested action as well as resource visibility. Use scoped lookups on writes, and consider constraints or locking when authorization or state may change concurrently. Return :not_found for resources whose existence must be hidden; preserve deliberate :forbidden semantics for visible resources with disallowed actions.
Test with two users in different tenants, plus same-tenant users with different permissions. Test mutations as well as lists.
:utc_datetime or :utc_datetime_usec). NaiveDateTime has no timezone; its correctness depends on the application's explicit convention.Group dependent writes in a transaction. This illustrative fragment assumes Oban uses the same Repo/database:
Ecto.Multi.new()
|> Ecto.Multi.insert(:order, order_changeset)
|> Oban.insert(:sync_job, fn %{order: order} ->
SyncJob.new(%{order_id: order.id})
end)
|> Repo.transaction()
Match the Multi result, including {:error, step, reason, changes_so_far}. Test that failed steps roll back both the domain write and queued job. Prefer the transaction API supported by the locked Ecto version; Repo.transaction/1 is shown for compatibility.
Do not make an irreversible vendor request inside a database transaction and assume rollback undoes it. Persist intent/outbox work and make external effects idempotent. Choose optimistic or pessimistic locking based on the contested invariant.
Generate migrations with mix ecto.gen.migration. Never edit an already-applied migration as a shortcut. Distinguish writing/reviewing a migration from executing it against production; use the authorization provided for the task.
Use expand/backfill/contract for rolling deployments. Consider table locks, concurrent indexes, database support, nullable transitions, and old application versions. Run the project's migration checker if installed. Scope and justify exceptions using the installed checker's syntax; a suppression comment does not make a change safe.
Keep seeds idempotent. Separate optional development sample data from production bootstrap operations and never require vendor credentials for ordinary tests.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ecto, elixir, data-access, authorization, database-migrations
Generated from the plugin's indexed repository (singularityhacker/estack) — no native marketplace selected
npx claudepluginhub p/singularityhacker-estack20 skills in this plugin
/estack-architectureDesign Phoenix context boundaries and application interfaces. Use when adding a feature, deciding where modules belong, introducing API/MCP adapters, or working in an Ash or umbrella application./estack-debugInvestigate and fix Elixir/Phoenix failures from symptoms and code evidence. Use for crashes, failed tests, incorrect queries, LiveView events, Oban retries, or production error reports./estack-deployPrepare Phoenix releases, migrations, health checks, and observable rollouts. Use when editing runtime config, deployment pipelines, Docker builds, production topology, or release diagnostics.Other plugins' skills for the same job