Claude Code Database Subagents — 13 DBA and ORM Specialists | AI Code Toolkit
13 tested agents · DBAs, ORM specialists, and cross-database strategists

Database Specialist Subagents

Senior DBA and ORM specialist configs that pair with the database MCPs to give Claude Code both the mental model and the hands-on access of a real database engineer.

13
DB Agents
4
Specialty Types
Opus
For DBAs
48h
Update SLA

Why database subagents are more valuable when paired with database MCPs

A database MCP gives Claude Code hands — the ability to actually read your schema and run queries. A database subagent gives Claude a mental model — how a senior DBA thinks about that database's specific concerns. Alone, either is useful. Together, they act like a database engineer working with the database open in front of them.

The 13 subagents on this page are calibrated for that pairing. Each one encodes the opinions of a senior specialist for that database: what indexes to reach for first, when to prefer a covering index over a partial one, how to tune the specific config knobs that matter (Postgres work_mem, MySQL innodb_buffer_pool_size, MongoDB readPreference), and the gotchas each database has that trip up generalists.

The lens: A database subagent is a compressed senior-DBA brief. Great ones encode three things: default posture (how to approach a new query), version-specific traps (things that changed in the last release you're likely to trip on), and output shape (what the DBA's response should look like — migration plan, index recommendation, query plan analysis).

Anatomy of postgres-dba

markdown .claude/agents/postgres-dba.md
--- name: postgres-dba description: Postgres database specialist. Use PROACTIVELY for schema design, query tuning, index strategy, migration planning, and EXPLAIN analysis. tools: Read, Grep, Glob, Bash(psql:*), mcp__postgres__query, mcp__postgres__schema model: opus --- You are a senior Postgres DBA. You think in query plans, buffer pool pressure, and MVCC. ## Default posture - Read the schema first. Never suggest a query without confirming column names, types, and existing indexes exist. - Explain, then act. For any non-trivial query, run EXPLAIN (ANALYZE, BUFFERS) and interpret the plan before recommending changes. - Indexes are a commitment. Every index proposal must state the query it serves, its estimated size, and its write cost. - Prefer covering indexes when the query touches 3+ columns and no other query needs them separately. ## Version specifics (Postgres 16-17) - Logical replication supports row filters and column lists. - MERGE is fully supported — prefer it over the INSERT ... ON CONFLICT dance for multi-row upserts. - Parallel VACUUM is default. Set max_parallel_maintenance_workers per environment. ## Do NOT - Do NOT recommend CREATE INDEX (without CONCURRENTLY) on a production-shaped table. - Do NOT suggest schema-mod migrations without a rollback plan. - Do NOT use SELECT * in production code. ## Output For query tuning: quote the before/after EXPLAIN plans with the key row-count and cost deltas highlighted. For migrations: produce up.sql, down.sql, and a risk assessment (locks taken, blocking behaviour, estimated duration).

Notice how the frontmatter references both a raw Bash(psql:*) tool and the specific MCP tools (mcp__postgres__query, mcp__postgres__schema). That's intentional — some queries are easier via psql, others benefit from the MCP's structured typing. The agent picks based on the task.

DBA subagents vs ORM subagents — both, not one

The listing groups these separately for a reason:

  • DBA subagents (postgres-dba, mysql-dba, mongodb-agent) think in the database. They care about query plans, indexes, transaction isolation, MVCC, replication.
  • ORM subagents (prisma-agent, drizzle-agent, sqlalchemy-agent) think in the abstraction layer. They care about schema files, migration file conventions, generated-type correctness, and idiomatic ORM patterns.

Install both for your stack. When you ask "why is this Prisma query slow?" the Prisma agent explains the ORM's translation and the DBA subagent explains the resulting plan. Neither alone answers well; together they're precise.

The pairing pattern in practice

What a Postgres-native workflow looks like once you have all three pieces installed:

Ask "add cursor pagination to the users list" and you get: Claude reads the actual schema via the MCP, notices the existing (created_at DESC, id) composite, the subagent recommends the cursor pattern that uses it, the migration hook keeps generated files clean. That's the shape of a mature database setup.

Complete Listing

All 13 database agents, grouped by specialty type

SQL DBAs, NoSQL specialists, ORM experts, and cross-database strategists. Every agent is version-calibrated and refreshed within 48 hours of a major release.

Decision Framework

Which database agents should I install?

The right set depends on your primary database and how much data lives in it.

Your project uses one primary database
Install the matching DBA agent. Pair it with the corresponding database MCP (read-only connection). That's the highest-leverage pair for a project.
Your project uses an ORM (Prisma, Drizzle, SQLAlchemy)
Install both the DBA agent and the ORM agent. The DBA agent thinks in query plans; the ORM agent thinks in schema files. You need both perspectives.
You're planning a significant schema change
Delegate to migration-planner. It designs zero-downtime migrations using expand/contract, produces up.sql/down.sql pairs, and estimates lock behaviour. Use it before writing migration files by hand.
You suspect index bloat or missing indexes
Delegate to index-analyst. It reads pg_stat_user_indexes (or the MySQL/Mongo equivalent) and returns a ranked list: unused, redundant, and missing. Common outcome is 20-30% write speedup after removing unused indexes.
You use multiple databases (Postgres + Redis, MongoDB + Postgres)
Install one agent per database. Give each a directory-scoped tool restriction so, e.g., the Postgres agent can't inadvertently issue Redis commands. Multiple specialists coexist cleanly.
You use Cassandra, ScyllaDB, or DynamoDB at scale
Install the matching specialist — these databases have very different data-modelling conventions from SQL. A generalist Claude produces plausible but often anti-pattern designs; the specialist catches these before they ship.

🐛 Hit an error while using these?

Our sister site AI Error Hub covers Claude Code errors, MCP connection failures, and stack traces — cross-referenced with everything on this site.

Visit AI Error Hub →
FAQ

Frequently asked questions

The questions developers ask most about database specialists.

You get most of the value with both together, but each is useful alone:

  • The MCP gives Claude the ability to actually read your schema and test queries — the biggest single quality lift for database code.
  • The subagent adds a senior-DBA mental model on top: which indexes to reach for, how to interpret EXPLAIN, when to prefer MERGE over ON CONFLICT.

Alone, the MCP is a tool without a specialist. Alone, the subagent is a specialist without hands. Together, they behave like a DBA working with the database open.

Opus. DBA work is analytical, multi-step, and consequential — the wrong index choice can produce a silent 50x write-cost regression that takes weeks to detect.

The token cost delta between Sonnet and Opus is small relative to the cost of an unnoticed schema mistake. This is the same argument for /review-security using Opus: correctness matters more than routing efficiency.

Because they think in different units:

  • DBA agent — query plans, tuples, buffers. What actually happens in the engine.
  • ORM agent — schema files, migration conventions, generated types. What the abstraction layer produces.

A slow Prisma query needs both: the Prisma agent explains what SQL got generated, the DBA agent explains why that SQL is slow. Combining them into one agent produces a middling generalist; keeping them separate produces two sharp specialists.

Read-oriented plus MCP query tools. For postgres-dba:

  • Read, Grep, Glob
  • Bash(psql:*) — narrow psql access
  • mcp__postgres__query, mcp__postgres__schema — MCP tools

Do not give it Write access to source files by default — a DBA agent should recommend schema changes, not implement them silently. Point it at a read-only MCP connection; for actual migration work, invoke migration-planner which has narrower write scope.

Yes, scoped to your migrations directory. That's the whole point — it produces up.sql and down.sql pairs plus a risk assessment.

Configure:

  • Write(prisma/migrations/**)
  • Write(migrations/**)
  • Write(db/migrate/**)

Do not give it general Write access; a migration planner that can rewrite arbitrary source files is a bug factory.

It reads the database's own statistics:

  • Postgrespg_stat_user_indexes gives per-index scan counts.
  • MySQLsys.schema_unused_indexes.
  • MongoDB — the $indexStats aggregation.

The analyst joins these stats with index size and estimated write cost to rank recommendations, so you see the highest-impact removals first.

Yes, and it works cleanly. Each agent's description names the database it specializes in, so Claude Code's auto-routing sends the right work to the right agent.

Give each a database-specific tool restriction so they can't cross into each other's territory. Common for full-stack projects where Postgres is the primary store, Redis is the cache, and MongoDB holds the event log.

Hooks fire regardless of who calls the tool. If you have:

  • A PostToolUse hook that runs pg_format
  • A PreToolUse hook that blocks CREATE INDEX without CONCURRENTLY on large tables

… they apply uniformly whether the SQL came from postgres-dba, migration-planner, or your main conversation.

This is the layered-defense pattern: agent for expertise, hook for enforcement, MCP for reality.

Yes, the underlying database is still Postgres or MySQL. Install the DBA agent for the actual engine.

On top of it, install the platform-specific MCP (Supabase's own, Neon's own, PlanetScale's own) rather than the generic Postgres/MySQL MCP — you get platform features (auth, branches, deploy requests) plus the standard SQL surface.

The DBA agent doesn't care whether the connection is direct or platform-mediated.

Just the DBA agent for your primary database, paired with the read-only MCP. That's it.

Skip the ORM agent, migration-planner, and index-analyst until the project is large enough that a wrong choice actually costs something.

As the project grows:

  • Schema changes get consequential → add migration-planner.
  • Queries slow down → add index-analyst.
  • ORM patterns get complex → add the matching ORM agent.

Share with