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.
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.
Anatomy of postgres-dba
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:
- postgres MCP (read-only) — lets Claude read schema and test queries without a mistake changing anything.
- postgres-dba subagent — encodes the mental model. Auto-invoked for schema, index, tuning, and migration questions.
- secrets-scan-on-write hook — catches accidental credential leaks in generated migration files.
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.
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.
Which database agents should I install?
The right set depends on your primary database and how much data lives in it.
Related sub-categories in Subagents
Database agents pair naturally with code review, framework specialists, DevOps, and AI/ML agents — the specialist categories most complex projects install together.
🐛 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.
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 preferMERGEoverON 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,GlobBash(psql:*)— narrow psql accessmcp__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:
- Postgres —
pg_stat_user_indexesgives per-index scan counts. - MySQL —
sys.schema_unused_indexes. - MongoDB — the
$indexStatsaggregation.
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
PostToolUsehook that runspg_format - A
PreToolUsehook that blocksCREATE INDEXwithoutCONCURRENTLYon 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.
Get the weekly Claude Code digest
Every Tuesday: new database specialists, Anthropic release recap, and the best community submission. 13,000+ developers read it.