Agent skill · Databases

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.

oliver-kriskagithub.com/oliver-kriskaGitHub ↗
claude-codeMIT
Install
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.

Facts
Files in the skill folder: 3
SKILL.md size: 2 KB
Bundled scripts: none
Path: targets/amp/skills/ecto-n1-check/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 515
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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

What's inside
Steps it walks through
  1. Iron Laws - Never Violate These
  2. Detection Patterns
  3. Pattern 1: Enum.map with Repo
  4. Pattern 2: Association Access Without Preload
  5. Pattern 3: Nested Association Access
  6. Quick Detection Commands
  7. Analysis Command
  8. References
Ships with 2 files
  • references/preload-patterns.md
  • references/query-optimization.md
More from claude-elixir-phoenix
All skills →
About this skill
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.

Keep going