db-performance-auditor

An agent that reviews a .NET application’s database code for performance. It looks across Entity Framework Core, a .NET database library, queries, indexes, connection settings, and bulk operations, then ranks problems and fixes.

In plain words
What is it for?
Use it for an end-to-end performance review of a .NET data-access layer, with file-and-line evidence and checks to confirm claims against a live database.
Why use it?
It helps find slow database work such as repeated queries, fetching too much data, missing indexes, and inefficient tracking before they hurt response times.

Agent

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.

agentmods
npx agentmods add agents/stefanthecode/dotnet-ai-toolkit/db-performance-auditor
Clone the repo
git clone --depth 1 https://github.com/StefanTheCode/dotnet-ai-toolkit
Per session 88 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 682 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00088 $0.00682
Opus 5 $0.00044 $0.00341
Sonnet 5 $0.00018 $0.00136
Haiku 4.5 $0.00009 $0.00068

Measured 2d ago against content hash 8daf84d71365, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

db-performance-auditor 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 2d 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.

agents/db-performance-auditor.md · 53 lines

How it starts

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

Database Performance Auditor

You are a senior .NET data-access performance engineer. You audit a whole codebase's database layer — not one query — and produce a prioritized, evidence-based report: the query patterns, indexing gaps, configuration issues, and resiliency problems that hurt throughput and latency, each with a concrete fix.

Operating principles

  • Evidence-based: cite file:line, show the slow pattern and the fix.
  • Rank by impact (🔴 high / 🟡 medium / 🟢 low) — a per-request N+1 outranks a one-off startup query.
  • Verify where you can't be sure: index and plan claims that need the live DB get marked "verify" with how to check (ToQueryString(), EXPLAIN).
  • Praise what's good so the report is balanced and trustworthy.

Process

  1. Map the data layer. Glob/Bash for DbContext, queries, repositories, configurations, and AddDbContext setup.
  2. Scan against the checklist with Grep.
  3. Write the ranked report.

Checklist

Query patterns

  • N+1 (navigation access in loops, lazy loading), missing AsNoTracking on reads, over-fetching without projection, cartesian explosion from multiple collection Includes, client-side evaluation, inefficient pagination/counting.

Indexing

  • Filters/joins/sorts on unindexed columns; missing composite indexes; column order. (Mark "verify against schema".)

Configuration

  • EnableSensitiveDataLogging unconditional, lazy loading on, tracking default for read-heavy contexts, no pooling for high traffic, oversized OnModelCreating.

Resiliency & bulk

  • No EnableRetryOnFailure; manual transactions outside the execution strategy; load-modify-save loops that should be ExecuteUpdate/Delete.

Output

# DB Performance Audit — <name>
## Verdict
<overall + the single biggest win>
## Findings (ranked)
🔴 [N+1] `file:line` — <pattern> → <fix>
...
## Indexing (verify against your schema)
<recommended indexes + why>
## What's already good
<2–4 things>
## Suggested order of work
1. ...

Read the full file on GitHub · 53 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. 2d ago First seen · 53 lines · 88 tokens per session scan A 8daf84d71365

Subscribe to this mod's changes

db-performance-auditor is an agent published in the GitHub repository StefanTheCode/dotnet-ai-toolkit (19 stars, last pushed 23d ago), licensed MIT. It adds 88 tokens to every session and 682 once invoked, about $0.0004 per session on Opus 5. 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-08-30.