analyze
免费Analyze a legacy app in any language before rewriting it in Elixir: inventory, features as goals, why each mechanism exists, runtime topology, external contracts. Use to start or refresh a rewrite.
中文简介正在准备中。当前显示原文说明。
Phoenix context design — creating/splitting contexts, Scope (1.8+); Use when editing contexts, routers, or designing…
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Ash projects:
Ash.Domainreplaces Phoenix contexts for data access — use theash-frameworkskill. Context boundary and PubSub patterns still apply.
Reference for designing and implementing Phoenix contexts (bounded contexts).
Ecto.Multi for transactions with side effectslib/my_app/
├── accounts/ # Context directory
│ ├── user.ex # Schema
│ ├── scope.ex # Scope struct (Phoenix 1.8+)
├── accounts.ex # Context module (public API)
Context functions take the scope as their first parameter, so queries are filtered to the caller:
def list_posts(%Scope{} = scope) do
from(p in Post, where: p.user_id == ^scope.user.id)
|> Repo.all()
end
def create_post(%Scope{} = scope, attrs) do
%Post{user_id: scope.user.id}
|> Post.changeset(attrs)
|> Repo.insert()
|> broadcast(scope, :created)
end
# ✅ Reference by ID, convert at boundary
def create_order(%Scope{} = scope, user_id, product_ids) do
with {:ok, user} <- Accounts.fetch_user(scope, user_id) do
do_create_order(scope, user.id, product_ids)
end
end
# ❌ Reaching into other context's internals
alias MyApp.Accounts.User # Don't do this
Repo.all(from o in Order, join: u in User, ...) # Don't query other schemas
| Wrong | Right |
|---|---|
Service objects (UserCreationService) | Context functions (Accounts.create_user/2) |
| Repository pattern wrapping Repo | Repo IS the repository |
| Direct Repo calls in controllers | Delegate to context |
| Schema callbacks with side effects | Use Ecto.Multi |
%Scope{} struct for authorization contextreferences/scopes-auth.md "Pre-Scopes Patterns")For detailed patterns, see:
references/context-patterns.md - Full context module, PubSub, Multi, cross-boundaryreferences/scopes-auth.md - Scope struct, multi-tenant, authorization, plugsreferences/routing-patterns.md - Verified routes, pipelines, API authreferences/plug-patterns.md - Function/module plugs, placement, guardsreferences/json-api-patterns.md - JSON controllers, FallbackController, API auth还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Analyze a legacy app in any language before rewriting it in Elixir: inventory, features as goals, why each mechanism exists, runtime topology, external contracts. Use to start or refresh a rewrite.
中文简介正在准备中。当前显示原文说明。
Design the idiomatic Elixir architecture for a rewrite: set the compatibility bar (ADR-000), consult phx specialists on open questions, then build contexts, ledger and ADRs. Use after /rewrite:analyze.
中文简介正在准备中。当前显示原文说明。
Ash Framework — resources, actions, policies, aggregates, calculations, AshPhoenix.Form, LiveView, migrations. Use when generating resources via mix ash.codegen, editing changes, checks, types, validations, or domain code interfaces.
中文简介正在准备中。当前显示原文说明。
Ash Framework — resources, actions, policies, aggregates; Use when generating resources via mix ash.codegen, editing…
中文简介正在准备中。当前显示原文说明。
Compatibility alias for the Elixir/Phoenix plugin's LiveView assigns audit. Invoke explicitly with /lv:assigns.
中文简介正在准备中。当前显示原文说明。
Inspect LiveView socket assigns for memory bloat — missing temporary_assigns, unused assigns, unbounded lists needing streams, memory estimates. Use when LiveView memory grows or you need to add temporary_assigns.
中文简介正在准备中。当前显示原文说明。