n1-hunter

n1-hunter is an agent for Claude Code from sigistry/marketplace. It costs 0 tokens per session (1,514 once invoked), scanned A, original, MIT.

A read-only code-analysis agent that looks for N+1 query patterns in database access code. N+1 means fetching a list and then making one additional database request for each item in that list.

In plain words
What is it for?
Use it to inspect ORM projects across several languages and frameworks for lazy-loaded relations that are accessed one row at a time.
Why use it?
It helps find a performance problem that may be hidden in loops, serializers, templates, or GraphQL resolvers. It reports where the problem occurs and suggests the appropriate eager-loading or batching fix.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the sql-safety-net plugin — 3 skills, 5 commands, 2 agents shipped together

Good fit Use it to inspect ORM projects across several languages and frameworks for lazy-loaded relations that are accessed one row at a time.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/sigistry/marketplace/n1-hunter
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sigistry/marketplace

Made for: Claude Code.

Or install sql-safety-net, the plugin that ships this one along with the rest of its 3 skills, 5 commands, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for n1-hunter

README.md
[![agentmods](https://agentmods.dev/badge/agents/sigistry/marketplace/n1-hunter/github.svg)](https://agentmods.dev/agents/sigistry/marketplace/n1-hunter)
Your own site
<a href="https://agentmods.dev/agents/sigistry/marketplace/n1-hunter"><img src="https://agentmods.dev/badge/agents/sigistry/marketplace/n1-hunter/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for n1-hunter

Your own site · 80×15
<a href="https://agentmods.dev/agents/sigistry/marketplace/n1-hunter"><img src="https://agentmods.dev/badge/agents/sigistry/marketplace/n1-hunter.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,514 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01514
Opus 5 $0.00000 $0.00757
Sonnet 5 $0.00000 $0.00303
Haiku 4.5 $0.00000 $0.00151

Measured 5d ago against content hash e51a18461d0e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

n1-hunter scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/sql-safety-net/agents/n1-hunter.md · 68 lines

How it starts

The opening of the file, as written. The whole thing — 68 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an ORM performance specialist who finds N+1 query patterns by reading source code, no runtime query log, no database connection. The N+1 is the "silent performance killer": a query returns N rows, then code touches a lazy-loaded relation once per row, producing 1 + N queries where 2 would do.

Your Core Responsibilities:

  1. Detect the ORM(s) in use before analyzing, the fix idiom differs per ORM.
  2. Find the two-part signature: a collection-returning query, and a per-element access of a lazy relation (in a loop, comprehension, serializer, template, or GraphQL resolver).
  3. Report each suspected N+1 with exact file:line for both the query and the access, and the idiomatic eager-load/batch fix.
  4. Never modify code, you are read-only. You diagnose and prescribe; a human or the migration flow applies changes.

Analysis Process:

  1. Detect the stack. Glob for manifests and models: models.py, *.rb under app/models, schema.prisma, @Entity classes, gorm.io imports, DbContext subclasses, sequelize/typeorm imports.
  2. Find collection queries. Grep for the query builders that return many rows: .all(), .filter(, .where(, findMany, findAll, getMany, db.Find, .ToList().
  3. Find per-row relation access. For each, look for a following loop/comprehension/map/serializer/to_json/template that reads a related object (order.customer.name, user.posts, invoice.lineItems). That relation access, if lazy, is the N+1.
  4. Confirm laziness. Check whether the query already eager-loads the relation (select_related, prefetch_related, joinedload/selectinload, includes/eager_load/preload, include:/with, .Include(), Preload(, JPA fetch = EAGER / @EntityGraph, JOIN FETCH). If it does, it is not an N+1. If not, flag it.
  5. Rank by hotness. Request handlers, list/index endpoints, and serializers are hot; one-off scripts and admin tasks are cold.

ORM-specific detection and fix patterns (see the schema-antipatterns skill's references/orm-n1-patterns.md for exact code shapes):

  • Django ORM: loop over a queryset touching a FK/M2M → add .select_related('fk') (to-one) or .prefetch_related('m2m') (to-many). Watch to_representation/DRF serializers with SerializerMethodField.
  • SQLAlchemy: default lazy='select' relationship accessed in a loop → joinedload (to-one) or selectinload (to-many) via options(...).
  • Rails ActiveRecord: @records.each { |r| r.assoc.x } without .includes(:assoc) → add includes/preload/eager_load. Watch views and as_json.
  • Sequelize: findAll then reading an association → add include: [{ model: Assoc }].
  • Prisma: findMany then accessing a relation not in include/select → add include: { relation: true }.
  • TypeORM: lazy relation (Promise<> relations or no relations:/leftJoinAndSelect) accessed in a loop → add relations: ['assoc'] or a QueryBuilder join.
  • Hibernate/JPA: @OneToMany(fetch = LAZY) iterated outside the session, or accessed per row → JOIN FETCH / @EntityGraph / batch fetching (@BatchSize).
  • GORM (Go): db.Find(&rows) then db.Model(&row).Association(...) per element → Preload("Assoc").
  • Entity Framework: navigation property accessed in a loop without .Include() (or lazy proxies on) → add .Include(x => x.Assoc) / projection.

Output Format:

N+1 Findings

Read the full file on GitHub · 68 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 68 lines · 0 tokens per session scan A e51a18461d0e

Subscribe to this mod's changes

n1-hunter is an agent published in the GitHub repository sigistry/marketplace (3 stars, last pushed 4d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,514 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other agents, from other repositories

ash-query-optimizer

Ash query optimizer — detects N+1 loads, suggests aggregates over load+Enum, identifies calculation vs load tradeoffs. Use when reviewing Ash queries, LiveView data loading, or domain action efficiency.

oliver-kriska/claude-elixir-phoenix · 45 tokens

d1-debugger

Autonomous diagnostic agent that investigates Cloudflare D1 database issues through 9-phase analysis (config, migrations, queries, bindings, errors, limits, performance, Time Travel, report). Use when encountering D1 query errors, migration failures, binding issues, performance degradation, or limit/quota errors.

secondsky/claude-skills · 65 tokens

performance-optimizer

Performance optimization expert. Identifies N+1 queries, memory leaks, and slow queries.

sd0xdev/sd0x-harness · 22 tokens

doctrine-performance-optimizer

Read-only performance audit of Doctrine usage: N+1 queries, fetch modes, batch processing, missing indexes, and caching opportunities. Use proactively after adding entities, relations, repository queries, or when a page/endpoint is reported slow.

dev-toolings/superpowers-symfony · 53 tokens

ccf-debugger

Investigates ONE assigned root-cause hypothesis/branch — follows the correlation ID across logs, queries the DB read-only to verify, returns evidence + judgment. Does NOT fix code. Used by /ccf:fix to isolate one investigation branch without flooding the main context.

naniiluja/ccf · 59 tokens

codebase-analyzer

Use this agent when you need to understand HOW existing code works, trace implementation details, or document technical architecture.

NikiforovAll/claude-code-rules · 27 tokens