ecto-n1-check
Detect N+1 query anti-patterns specifically — Repo calls inside Enum/for loops, missing preloads on associations. Use when N+1 is explicitly suspected, NOT for unrelated Ecto questions or wider database performance.
npx skills add oliver-kriska/claude-elixir-phoenix --skill ecto-n1-check --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# N+1 Query Detection Identify and fix N+1 query anti-patterns in Ecto/Phoenix applications. ## Iron Laws - Never Violate These 1. **Never access associations without preload** - Always preload before `Enum.map` 2. **No Repo calls inside loops** - Restructure to batch queries 3. **Preload at context boundary** - Load associations in context, not controllers/views 4. **Use joins for filtering** - Use `join` + `preload` when filtering by association ## Detection Patterns ### Pattern 1: Enum.map with Repo ```elixir # BAD: N+1 queries users |> Enum.map(fn user -> Repo.get(Order, user.order_id) end) # GOOD: Single query with preload users |> Repo.preload(:orders) ``` ### Pattern 2: Association Access Without Preload ```elixir # BAD: Lazy loading triggers N queries for user <- users do user.posts # Triggers query for each user! end # GOOD: Eager load first users = Repo.all(User) |> Repo.preload(:posts) for user <- users do user.posts # Already loaded end ``` ### Pattern 3: Nested Association Access ```elixir # BAD: N+1 for nested associations user.posts |> Enum.map(fn post -> post.comments end) # GOOD: Nested preload Repo.preload(user, posts: :comments) ``` ## Quick Detection Commands Us
- Iron Laws - Never Violate These
- Detection Patterns
- Pattern 1: Enum.map with Repo
- Pattern 2: Association Access Without Preload
- Pattern 3: Nested Association Access
- Quick Detection Commands
- Analysis Command
- References
What does the ecto-n1-check skill do?
Detect N+1 query anti-patterns specifically — Repo calls inside Enum/for loops, missing preloads on associations. Use when N+1 is explicitly suspected, NOT for unrelated Ecto questions or wider database performance.
How do I install it?
Run `npx skills add oliver-kriska/claude-elixir-phoenix --skill ecto-n1-check --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From oliver-kriska/claude-elixir-phoenix, a repository with 515 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
