phoenix-standards
Use when building or reviewing a Phoenix 1.7+/LiveView app in a touchstone repo — contexts, Ecto, the web layer, LiveView, channels/PubSub, auth/scopes, Oban, releases. Triggers on `phoenix` in `mix.exs`, a `*_web/` directory, `.heex` templates, `use Phoenix.LiveView`. Elixir-language idioms (OTP, GenServer, supervision) live in the elixir skill; this is the framework layer.
- License 许可
- MIT
- 最近更新
- 2026-08-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- phoenix-standards
- license
- MIT
- metadata
- { "author": "touchstone", "version": "0.2.0" }
- description
- Use when building or reviewing a Phoenix 1.7+/LiveView app in a touchstone repo — contexts, Ecto, the web layer, LiveView, channels/PubSub, auth/scopes, Oban, releases. Triggers on `phoenix` in `mix.exs`, a `*_web/` directory, `.heex` templates, `use Phoenix.LiveView`. Elixir-language idioms (OTP, GenServer, supervision) live in the elixir skill; this is the framework layer.
03 SKILL.md 正文
Phoenix (framework)
Full standard: standards/frameworks/phoenix.md (layers on standards/languages/elixir.md). Rules:
Always
- Contexts are the boundary — Ecto/
Reponever leaks past a context; the web layer calls context functions returning{:ok, _}/{:error, changeset}, never queries the schema itself. - Changesets validate at the boundary with allowlisted
cast(no blanket-cast mass assignment); DB constraints surfaced via*_constraint;Ecto.Multifor multi-step writes. - Preload every walked association — Ecto does not lazy-load; preloading in a loop is the N+1.
- LiveView is the default interactive UI — streams for large collections (never replace a big assign every tick), minimal assigns +
temporary_assigns, forms validate onphx-change; LiveViews call contexts, notRepo. - Verified routes (
~p) everywhere; thin controllers withaction_fallback; JSON rendered through an allowlist, never schema field-for-field. - Auth via
phx.gen.auth(magic-link, sudo mode); scopes thread the current user/tenant through contexts so authorization is the default. Background work on Oban — idempotent, pass ids, enqueue inside the transaction.
Defer (don't duplicate)
- Schema/migrations/expand-contract →
../../standards/platform/database.md; authN/authZ/OWASP →../../standards/practices/app-security.md; telemetry/metrics/tracing →../../standards/platform/observability.md; durable cross-system events →../../standards/design/event-driven.md; Elixir/OTP idioms →../../standards/languages/elixir.md; test strategy →../../standards/practices/testing-strategy.md.
Done
contexts own Ecto · changesets validate + Multi · associations preloaded (no N+1) · expand/contract migrations · ~p routes + thin controllers · LiveView with streams · phx.gen.auth + scopes · idempotent Oban · ExUnit SQL Sandbox async: true + LiveViewTest on real Postgres · mix release with runtime.exs fail-fast. See standards/frameworks/phoenix.md.
04 同仓库更多 Skills
ok-standards
Use when writing shell, per standards/languages/shell.md.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.