Cookies

With your permission, we use Google Analytics cookies to measure visits and improve the site. Necessary cookies are always on. You can change your choice or withdraw consent anytime in the footer, under Cookie settings. Cookie Policy

Skip to content

Databases with Claude Code: schema, queries and migrations

MCP connectors, agents and skills for schema, SQL queries, migrations and performance.

Almost every project ends up with a database at its center. The problem rarely shows up on day one: it shows up when the orders table reaches millions of rows, when a query that used to run in 20 ms starts holding up the whole page, or when you need to change a column in a database that is in production and cannot stop. At that point the job is no longer writing SQL, it is understanding what the database is really doing.

The components on this page deal with three different things. The connectors (MCP) give Claude Code a real connection to your database, so it can list tables, read the schema and run queries instead of guessing from the application code. The agents and skills bring the method: how to normalize a model, which index to create from an execution plan, how to split a migration into reversible steps.

Start with the connector for the engine you use, because almost everything else improves when Claude Code can see the real schema. Then choose by concrete problem: design from scratch, a slow query, or a schema change in production. Avoid installing everything. Two or three well-chosen components do more than a long list nobody reviews, and most of them only ask for an environment variable with the connection string.

20 hand-picked components, from 4 different angles.

Connectors (MCP) to connect to the database 6

These connectors give Claude Code direct access to the engine, through a connection string stored in an environment variable. Without them, Claude Code only knows the schema it can infer from the code.

  • postgresql-integration

    Built on the @modelcontextprotocol/server-postgres server and connects through POSTGRES_CONNECTION_STRING, the most direct way to explore tables and run queries on an existing Postgres database.

    Connect to PostgreSQL databases for advanced data operations, complex queries, and enterprise database management.

    Connectors2,360
  • mysql-integration

    For projects built on MySQL: it starts with uvx and only asks for MYSQL_CONNECTION_STRING, giving access to the data and to database management within the working session.

    Connect to MySQL databases for direct data access, queries, and database management within Claude Code workflows.

    Connectors737
  • supabase

    Connects to your Supabase project with the --read-only and --project-ref arguments, which keeps the session limited to reads. It authenticates with a personal access token.

    Connect your Claude Code to Supabase using MCP

    Connectors2,120
  • mongodb

    Comes configured with --readOnly, so it works well for inspecting collections and documents in a local MongoDB or an Atlas cluster without the risk of writing by mistake.

    A Model Context Protocol server to connect to MongoDB databases and MongoDB Atlas Clusters.

    Connectors190
  • redis

    The official Redis server for querying and managing data in natural language, useful when the question is what is really in the cache and under which keys.

    Official Redis MCP Server providing natural language interface for Redis databases. Query, manage, and interact with Redis data through Claude.

    Connectors32
  • dbhub

    An alternative worth considering when the project touches several engines: a single connector covers PostgreSQL, MySQL, MariaDB, SQL Server and SQLite from one DSN.

    Zero-dependency, token-efficient database MCP server supporting PostgreSQL, MySQL, MariaDB, SQL Server, and SQLite connections.

    Connectors12

Schema design and data modeling 5

For when the model is still being decided, or when the existing one can no longer handle the way the application accesses data.

  • database-architect

    A starting point for architecture decisions: technology choice, modeling and data patterns in microservices. It plans and designs, handing fine Postgres tuning over to specialized agents.

    Database architecture and design specialist. Use PROACTIVELY for database design decisions, data modeling, scalability planning, microservices data pa

    Agents5,554
  • database-schema-designer

    Describe the domain and get a schema with normalization, constraints and indexes already thought through, for SQL or NoSQL. A good choice to get past the blank page without losing data integrity.

    Design robust, scalable database schemas for SQL and NoSQL databases. Provides normalization guidelines, indexing strategies, migration patterns, cons

    Skills202
  • postgresql

    Specific to Postgres: data types, indexes, constraints and advanced features. Use it once the engine has been chosen, so the schema takes advantage of what is unique to Postgres.

    Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features

    Skills86
  • supabase-schema-architect

    In Supabase projects, the schema cannot be separated from the RLS policies. This agent handles both together, including planning the migrations that result from them.

    Supabase database schema design specialist. Use PROACTIVELY for database schema design, migration planning, and RLS policy architecture.

    Agents1,842
  • nosql-specialist

    When the data does not fit well into tables: modeling and architecture decisions for MongoDB, Redis, Cassandra and other document or key-value stores.

    NoSQL database specialist for MongoDB, Redis, Cassandra, and document/key-value stores. Use PROACTIVELY for schema design, data modeling, performance

    Agents427

Slow queries, indexes and performance 5

The group to open when the application already works but some pages are slow, or database load is rising with no clear explanation.

  • sql-pro

    For complex SQL that spans PostgreSQL, MySQL, SQL Server and Oracle. It handles rewriting heavy queries and index strategies once performance has become the problem.

    Use this agent when you need to optimize complex SQL queries, design efficient database schemas, or solve performance issues across PostgreSQL, MySQL,

    Agents1,696
  • database-optimization

    Works from measurements instead of guesses: it profiles first, uses EXPLAIN ANALYZE to read the execution plan and only then designs indexes based on real access patterns.

    Database performance optimization and query tuning specialist. Use PROACTIVELY for slow queries, indexing strategies, execution plan analysis, and dat

    Agents1,918
  • supabase-postgres-best-practices

    Brings together Postgres performance practices published by Supabase, which apply when writing, reviewing or tuning queries, schema designs and database configuration.

    Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema des

    Skills1,017
  • postgresql-optimization

    A complete workflow for query tuning in Postgres, with performance analysis, indexing strategies and management of the database in production.

    PostgreSQL database optimization workflow for query tuning, indexing strategies, performance analysis, and production database management.

    Skills76
  • mongodb-performance-advisor

    On the MongoDB side, it analyzes database performance and returns concrete recommendations on queries and indexes, instead of generic modeling advice.

    Analyze MongoDB database performance, offer query and index optimization insights and provide actionable recommendations to improve overall usage of t

    Agents84

Migrations and schema changes in production 4

Changing the schema of a live database is the riskiest part. These components handle versioning, rollback and steps that do not stop the service.

  • database-migration

    Covers schema and data migrations in Sequelize, TypeORM and Prisma, with rollback strategies and steps that avoid service interruption. It also helps when switching ORMs.

    Master database schema and data migrations across ORMs (Sequelize, TypeORM, Prisma), including rollback strategies and zero-downtime deployments.

    Skills45
  • create-database-migrations

    Detects the ORM from package.json or requirements.txt, looks for the migrations that already exist in the repository and creates the new one with versioning and rollback from the start.

    Create and manage database migrations with proper versioning and rollback support

    Commands142
  • supabase-migration-assistant

    Generates and manages Supabase migrations with automatic testing and validation, a good fit for anyone whose project and schema are already built on Supabase.

    Generate and manage Supabase database migrations with automated testing and validation

    Commands469
  • prisma-expert

    In Prisma projects, the problems concentrate in four places: the schema, failing migrations, poorly modeled relations and slow queries. That is exactly the scope of this skill.

    Prisma ORM expert for schema design, migrations, query optimization, relations modeling, and database operations. Use PROACTIVELY for Prisma schema is

    Skills97

How to install each type of component

The four types are installed in different ways. Agents go in .claude/agents/, skills in .claude/skills/ and commands in .claude/commands/, inside the project or in your home folder, and Claude Code loads them in the next session. The connectors (MCP) are not markdown files: they are a JSON block with the mcpServers key, which specifies the command to run (npx or uvx) and the environment variables it needs. The connection string should not be written in plain text in a shared repository. Store it in a system environment variable or in a .env file outside version control, and confirm the connection with a read query before giving any write instruction.

Always start in read mode

The connectors on this page take different stances on writing. The MongoDB one comes with --readOnly and the Supabase one with --read-only in its arguments, which limits the session to queries. The PostgreSQL, MySQL and dbhub ones, however, depend entirely on the permissions of the user you put in the connection string. The prudent way to start is to create a database user with SELECT only and point the connector at that user. You keep the part that matters, which is Claude Code seeing the real schema and the real data, without a misread request turning into an UPDATE with no WHERE clause.

How to combine these components in one task

These components do more when chained than when used alone. A common example: the PostgreSQL connector gives access to the schema and the execution plans, the optimization agent reads those plans and proposes an index, and the migrations skill turns that index into a versioned file with rollback, instead of a command typed by hand in the console. The same chain works for design from scratch, with the architecture agent deciding the engine and the model and the Postgres-specific skill fine-tuning types and constraints. Avoid loading two components that do the same thing, because Claude Code ends up with competing instructions for the same decision.

Keep reading

Frequently asked questions

They are different things. An agent or a skill brings method and knowledge, but only works with what it can read in the project's code. A connector (MCP) connects Claude Code to the engine and lets it list tables, query the schema and run queries. To design from scratch, the agent is enough. To diagnose a slow query in a database that already exists, the connector makes the difference.

Sources

Prompts and resources curated from international sources, normalized and categorized: over 11 thousand. A Doutor AI bot checks the sources every day and brings in what is new.

  • Daily updates
  • Over 11 thousand resources
  • Normalized and categorized

Need a tailor-made solution?

Not sure where to start with AI in your business? Get a free assessment and a tailored plan - no commitment.

Save hours every week with AI, no hassle

Doutor AI gives you 1,859 ready-to-copy AI prompts, by industry and in plain English - plus a complete technical library for those who want to go further.

See plans