Skip to content
Back to skills

In Ash Ecto Essentials

ASecurity

Ash Framework database-access rules: domain code interfaces, actor on query/changeset

  • 26 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added May 27, 2026
developmentgoexpressapidatabase

Works with

  • terminal
  • api

Security analysis

A100/100

Scanned September 21, 2026

npx -y skills add matthewsinclair/intent --skill in-ash-ecto-essentials --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of In Ash Ecto Essentials?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for In Ash Ecto Essentials
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/matthewsinclair-in-ash-ecto-essentials/badge)](https://www.skillsdirectory.com/skills/matthewsinclair-in-ash-ecto-essentials)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: "Ash Framework database-access rules: domain code interfaces, actor on query/changeset"
---

# Ash/Ecto Essentials

Load the Intent Ash rule pack into context. All database access in Ash-framework projects goes through Ash -- never raw Ecto in application code. Authoritative upstream reference: `deps/ash/usage-rules.md`.

## Procedure

### 1. Load the Ash rules

Read each rule on demand. The full text is served by the installed Intent tool via `intent claude rules show <id>`.

| Rule ID         | Slug                   | What it enforces                                                        |
| --------------- | ---------------------- | ----------------------------------------------------------------------- |
| `IN-EX-ASH-001` | `code-interfaces-only` | All web/worker code hits the domain via a code interface, not `Ash.*`.  |
| `IN-EX-ASH-002` | `actor-on-query`       | Actor goes on `for_read/3` or `for_create/3`, not on the terminal call. |

### 2. Additional operational conventions

Not yet first-class rules -- treat as mandatory Ash discipline:

- **Migrations via `mix ash.codegen`.** Never write Ecto migrations by hand for Ash resources. `mix ash.codegen <name>` reads resource definitions and produces correct migrations; `mix ash.migrate` applies them.
- **Code-interface options over manual pipelines.** Prefer `MyApp.Content.list_posts!(query: [filter: [...], sort: [...], limit: 20], actor: user)` over hand-rolled `Ash.Query.filter |> Ash.Query.sort |> Ash.read!` pipelines in web modules.
- **Custom change/validation modules, not anonymous functions.** `change MyApp.Content.Changes.SlugifyTitle` instead of `change fn changeset, _ -> ... end`. Modules are testable and reusable.
- **Atomic changes preferred.** Implement `atomic/3` whenever the change can be expressed as a database-level update. Use `require_atomic? false` only when external I/O (API call, computation on external data) genuinely forces non-atomic behaviour.
- **`require Ash.Query` at module level.** `Ash.Query.filter/2` is a macro. The `require` belongs at the top of the module alongside other requires, never inside a function body.

### 3. Check Ash Usage Rules

When the task deepens, read `deps/ash/usage-rules.md` -- plus any topical sub-rules Ash ships in `deps/ash/usage-rules/*.md` -- for the upstream authoritative contract. Intent's rules are a subset; framework Usage Rules are the ground truth for anything this skill doesn't cover.

## Red Flags

| Rationalisation                                          | Reality                                                                         |
| -------------------------------------------------------- | ------------------------------------------------------------------------------- |
| "I'll just `Ash.get!` here; it's one line."              | See IN-EX-ASH-001. The one-line bypass is how policies die quietly.             |
| "Actor on `Ash.read!` is fine; same effect."             | See IN-EX-ASH-002. Not the same -- calculations and policies see `nil`.         |
| "`mix ecto.gen.migration` is faster than `ash.codegen`." | It is also wrong. Ash needs to read your resource DSL to produce the migration. |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.