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.
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install elixir-phoenix-elixir-phoenix-n1-checkManual setup by platform
Claude Code
~/.claude/skills/elixir-phoenix-elixir-phoenix-n1-check/SKILL.md
Instructions
N+1 Query Detection
Identify and fix N+1 query anti-patterns in Ecto/Phoenix applications.
Iron Laws - Never Violate These
- Never access associations without preload - Always preload before
Enum.map - No Repo calls inside loops - Restructure to batch queries
- Preload at context boundary - Load associations in context, not controllers/views
- Use joins for filtering - Use
join+preloadwhen filtering by association
Detection Patterns
Pattern 1: Enum.map with Repo
# 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
# 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
# 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
Use Grep with context lines (-B 5 -A 5) to find Enum.map near Repo. calls in lib/**/*.ex.
Use Grep to find association access patterns (.posts, .comments, .orders) in lib/**/*.ex.
Use Grep with context (-B 3) to find Repo.get or Repo.one near loop patterns (for, Enum) in lib/**/*.ex.
Analysis Command
Use Grep to find all Repo. calls in a context module, then verify each query has appropriate preloads.
References
For detailed patterns, see:
${CLAUDE_SKILL_DIR}/references/preload-patterns.md- Efficient preloading strategies${CLAUDE_SKILL_DIR}/references/query-optimization.md- Query batching techniques
Security
Reviews (0)
Related skills
Browse all →More from Elixir & Phoenix
View source →More Build skills
Browse category →Frequently asked questions about n1-check
What does the 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. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the n1-check skill?
Run `npx @skills-hub-ai/cli install elixir-phoenix-elixir-phoenix-n1-check` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/elixir-phoenix-elixir-phoenix-n1-check/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does n1-check work with?
n1-check runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the n1-check skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use n1-check after installing it?
In Claude Code, type `/elixir-phoenix-elixir-phoenix-n1-check` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the n1-check skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.