ash-framework
Installation
SKILL.md
Ash Framework Reference
Reference for Ash Framework in Phoenix/LiveView projects. Ash complements Phoenix/Ecto — LiveView, security, and OTP Iron Laws still apply. Only data access patterns shift toward Ash actions and domain code interfaces.
Iron Laws
- USE DOMAIN CODE INTERFACES — Never call
Ash.create/Ash.readdirectly in LiveViews or Controllers; use domain code interfaces:MyApp.Accounts.register_user()notAsh.create(User, attrs) - SET ACTOR/SCOPE AT QUERY PREP, NOT EXECUTION — Pass
actor:orscope:tofor_read/for_create/for_action(prep), NOT toAsh.read!/Ash.create!(execution); execution-level actor bypasses row-level policy evaluation. If project usesAsh.Scope, passscope:consistently instead of bareactor:— do not mix styles - GENERATORS FIRST — Before writing Ash code manually, run
mix ash.gen.resourceormix ash.gen.domainwith--yes; checkmix help ash.gen.<task>for options - CODEGEN AFTER RESOURCE CHANGES — Always run
mix ash.codegenafter modifying resources; this generates migrations from resource snapshots — never write AshPostgres migrations by hand - ACTIONS OVER FUNCTIONS — Put business logic in named actions, not domain functions; expose via code interfaces defined on the domain
- NEVER EDIT RESOURCE SNAPSHOTS —
priv/resource_snapshots/is owned exclusively bymix ash.codegen; manual edits corrupt migration tracking - NO DIRECT
Repo.*IN ASH PROJECTS —Repo.all/get/insertbypass Ash policies and notifications; use domain code interfaces. AnyRepocall in an Ash project is an escape hatch and must be documented