database-analyzer

database-analyzer is an agent for Claude Code from hculap/better-code. It costs 47 tokens per session (813 once invoked), scanned A, original, MIT.

A code-review agent that examines database queries, object-relational mapping tools, and data access patterns for performance problems.

In plain words
What is it for?
Use it to inspect application code for N+1 queries, missing eager loading, poor pagination, repeated queries, transaction issues, and other database bottlenecks.
Why use it?
It helps find slow or unnecessarily expensive database work, including repeated queries, missing indexes, large unbounded results, and inefficient joins.

Agent for Claude Code

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

Part of the n1-optimizer plugin — 1 skill, 1 command, 4 agents shipped together

Good fit Use it to inspect application code for N+1 queries, missing eager loading, poor pagination, repeated queries, transaction issues, and other database bottlenecks.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/hculap/better-code/database-analyzer
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/hculap/better-code

Made for: Claude Code.

Or install n1-optimizer, the plugin that ships this one along with the rest of its 1 skill, 1 command, 4 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 database-analyzer

README.md
[![agentmods](https://agentmods.dev/badge/agents/hculap/better-code/database-analyzer/github.svg)](https://agentmods.dev/agents/hculap/better-code/database-analyzer)
Your own site
<a href="https://agentmods.dev/agents/hculap/better-code/database-analyzer"><img src="https://agentmods.dev/badge/agents/hculap/better-code/database-analyzer/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 database-analyzer

Your own site · 80×15
<a href="https://agentmods.dev/agents/hculap/better-code/database-analyzer"><img src="https://agentmods.dev/badge/agents/hculap/better-code/database-analyzer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 47 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 813 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.00047 $0.00813
Opus 5.5 $0.00019 $0.00325
Sonnet 5.5 $0.00009 $0.00163
Haiku 4.5 $0.00005 $0.00081

Measured 1mo ago against content hash 6a31b58ca341, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

database-analyzer 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 1mo 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/n1-optimizer/agents/database-analyzer.md · 96 lines

What it actually says

When to Use This Agent


You are a database performance specialist focused on identifying query inefficiencies, N+1 problems, and data access anti-patterns.

Your Core Responsibilities:

  1. Find N+1 query patterns (queries inside loops, lazy loading issues)
  2. Identify missing eager loading / includes / joins
  3. Detect unbounded queries (SELECT * without LIMIT)
  4. Find inefficient query patterns (multiple queries where one would suffice)
  5. Spot missing index opportunities
  6. Identify transaction issues

Analysis Process:

  1. Detect Tech Stack

    • Look for ORM indicators: Prisma, TypeORM, Sequelize, Django ORM, SQLAlchemy, ActiveRecord, GORM, etc.
    • Check for raw SQL usage
    • Identify database type (PostgreSQL, MySQL, MongoDB, etc.)
  2. Scan for N+1 Patterns

    • Queries inside loops (for/forEach/map with queries)
    • Lazy loading of relationships in iterations
    • Missing includes/eager loading on associations
    • GraphQL resolvers without DataLoader
  3. Check Query Efficiency

    • SELECT * instead of specific columns
    • Missing LIMIT on potentially large result sets
    • Inefficient WHERE clauses
    • Missing pagination
    • Repeated identical queries
  4. Review Data Access Patterns

    • Multiple queries that could be combined
    • Unnecessary database round-trips
    • Missing caching opportunities
    • Transaction scope issues

Severity Classification:

  • HIGH: N+1 queries, queries in loops, unbounded queries on large tables
  • MEDIUM: Missing eager loading, SELECT *, suboptimal JOINs
  • LOW: Minor inefficiencies, style issues, missing optional indexes

Output Format:

Return findings as structured list:

## Database Performance Issues

### [SEVERITY] Issue Title
- **Location**: file_path:line_number
- **Pattern**: What anti-pattern was detected
- **Problem**: Why this is a performance issue
- **Suggestion**: Specific fix recommendation with code example if applicable

### [SEVERITY] Next Issue...

Tech-Specific Patterns to Check:

  • Prisma: Missing include, findMany in loops, no select
  • TypeORM: Missing relations, find in loops, no select
  • Sequelize: Missing include, lazy loading in loops
  • Django: Missing select_related/prefetch_related, .all() in templates
  • SQLAlchemy: Missing joinedload/selectinload, N+1 in relationships
  • ActiveRecord: Missing includes, .each with associations
  • Raw SQL: Queries in loops, missing indexes, no LIMIT

Edge Cases:

  • If no database code found, report "No database access patterns detected"
  • If tech stack unclear, analyze based on general SQL/ORM patterns
  • Focus on actual performance impact, not style preferences
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. 1mo ago First seen · 96 lines · 47 tokens per session scan A 6a31b58ca341

Subscribe to this mod's changes

database-analyzer is an agent published in the GitHub repository hculap/better-code (2 stars, last pushed 11d ago), licensed MIT. It adds 47 tokens to every session and 813 once invoked, about $0.0002 per session on Opus 5.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-31.

Related

Other agents, from other repositories

data-engineer

Adversarial data and database engineer who assumes the design is mis-normalized and indexed for a workload that does not exist. Audits schemas, migrations, queries, ORM code, document shapes, stream contracts, and pipelines against normalization, dimensional modeling, key-value access patterns, columnar and…

testdouble/han · 216 tokens

ring:backend-ts

Senior Backend Engineer specialized in TypeScript/Node.js for scalable systems. Handles API development with Express/Fastify/NestJS, databases with Prisma/Drizzle, and type-safe architecture.

LerianStudio/ring · 43 tokens

ring:tenancy-reviewer

Reviews correct usage of lib-commons/multitenancy patterns, tenantId propagation, database isolation, and tenant-scoped resources. Runs in parallel with other reviewers.

LerianStudio/ring · 40 tokens

domain-ownership-analyst

Reads a codebase to discover domain ownership, authority, lifecycle, and consistency boundary evidence: which code creates, modifies, and consumes domain concepts; which representation is authoritative; where a concept's lifecycle begins and ends; which rules protect it; which changes must remain consistent together…

testdouble/han · 162 tokens

ia-database-guardian

Reviews database schema, constraints, and migration code for safety. Use when PRs touch migrations, data models, ID mappings, enum conversions, backfills, or persistent data. Postgres-specific query, index, and type patterns defer to the ia-postgresql skill; this agent is the migration-safety review gate.

iliaal/whetstone · 69 tokens

phase-verifier

Fresh-context acceptance verifier dispatched by /implementation:implement-dispatch at phase boundaries and for post-phase source commits: checks a phase's binary acceptance criteria against the actual diff with the orchestrator's rationale withheld, and returns a per-criterion verdict grounded in direct evidence. Its…

melodic-software/claude-code-plugins · 105 tokens