Skip to main content

Database Components

The Database category includes specialized agents, MCPs, and commands for database architecture, optimization, migrations, and platform-specific integrations.

Browse Database Components

Explore all database components at aitmpl.com

Quick Install

# Install database essentials
npx claude-code-templates@latest \
  --agent database-architect \
  --agent postgres-pro \
  --mcp neon \
  --mcp supabase

# Or install the database template
npx claude-code-templates@latest --template database-project

Database Agents

Database Architect

Expert in database schema design, normalization, and architectureExpertise:
  • Schema design and normalization
  • Data modeling (ER diagrams)
  • Index strategy
  • Partitioning and sharding
  • Replication architecture
  • Backup and recovery planning
Technologies:
  • PostgreSQL, MySQL, MongoDB
  • Redis, Cassandra, DynamoDB
  • Database design patterns
  • Capacity planning
npx claude-code-templates@latest --agent database-architect
Example Usage:
@database-architect Design a multi-tenant database schema for a SaaS
application with 10k tenants. Include user management, subscriptions,
and usage tracking.

Database Administrator

Database administration, maintenance, and operationsExpertise:
  • Database configuration
  • Performance tuning
  • Backup and recovery
  • User and permission management
  • Monitoring and alerting
  • Disaster recovery
npx claude-code-templates@latest --agent database-administrator

Database Optimizer

Query optimization, indexing, and performance tuningExpertise:
  • Query performance analysis
  • Index optimization
  • Query plan analysis (EXPLAIN)
  • Connection pooling
  • Caching strategies
  • Slow query detection
Techniques:
  • Index selection and design
  • Query rewriting
  • Materialized views
  • Partitioning strategies
  • Denormalization when needed
npx claude-code-templates@latest --agent database-optimizer
Example Usage:
@database-optimizer Analyze and optimize this slow query.
It's taking 5 seconds to fetch user orders with related products.

SELECT * FROM orders o
JOIN order_items oi ON o.id = oi.order_id
JOIN products p ON oi.product_id = p.id
WHERE o.user_id = 123

Database Optimization

Systematic database performance optimization
npx claude-code-templates@latest --agent database-optimization

PostgreSQL Specialists

Postgres Pro

PostgreSQL expert for advanced features and optimizationExpertise:
  • Advanced SQL features (CTEs, window functions, LATERAL joins)
  • PostgreSQL-specific features (JSONB, full-text search, arrays)
  • Extensions (PostGIS, pg_stat_statements, pg_cron)
  • Replication (streaming, logical)
  • Connection pooling (PgBouncer)
  • Performance tuning
Use cases:
  • Complex query optimization
  • Full-text search implementation
  • Geospatial queries with PostGIS
  • JSON/JSONB data handling
  • Advanced indexing (GiST, GIN, BRIN)
npx claude-code-templates@latest --agent postgres-pro

NoSQL Specialist

NoSQL databases (MongoDB, Cassandra, Redis)
npx claude-code-templates@latest --agent nosql-specialist

Platform-Specific Agents

Neon Database Specialists

Neon Expert

Neon serverless Postgres specialistExpertise:
  • Neon branching workflows
  • Autoscaling configuration
  • Branch-based development
  • Instant provisioning
  • Connection pooling
  • Cost optimization
npx claude-code-templates@latest --agent neon-expert
Example Usage:
@neon-expert Set up a branching workflow where each PR gets
its own database branch for testing.

Neon Database Architect

Neon-specific architecture and design
npx claude-code-templates@latest --agent neon-database-architect

Neon Auth Specialist

Neon authentication and security
npx claude-code-templates@latest --agent neon-auth-specialist

Database MCPs

Neon MCP

Direct integration with Neon database platformCapabilities:
  • Query databases directly from Claude
  • Create and manage database branches
  • Access Neon Management API
  • Monitor database metrics
  • Manage connection strings
npx claude-code-templates@latest --mcp neon
Setup:
# Add Neon API key to .env
echo "NEON_API_KEY=your_api_key" >> .env
Example Usage:
# In Claude Code chat:
Query my Neon database for all users created in the last 7 days

Create a new database branch called "feature-auth" from main

Show me the current database metrics and connection count

Supabase MCP

Direct integration with Supabase platformCapabilities:
  • Query database
  • Manage authentication
  • Storage operations
  • Realtime subscriptions
  • Edge functions
npx claude-code-templates@latest --mcp supabase
Setup:
# Add Supabase credentials to .env
echo "SUPABASE_URL=https://xxx.supabase.co" >> .env
echo "SUPABASE_KEY=your_service_key" >> .env

PostgreSQL MCP

Direct PostgreSQL database connection
npx claude-code-templates@latest --mcp postgresql-integration

MySQL MCP

Direct MySQL database connection
npx claude-code-templates@latest --mcp mysql-integration

Database Commands

Supabase Management Commands

Migration Assistant

Create and manage Supabase migrations
npx claude-code-templates@latest --command supabase-migration-assistant

Schema Sync

Sync local schema with Supabase
npx claude-code-templates@latest --command supabase-schema-sync

Performance Optimizer

Optimize Supabase database performance
npx claude-code-templates@latest --command supabase-performance-optimizer

Security Audit

Audit Supabase security and RLS policies
npx claude-code-templates@latest --command supabase-security-audit

Data Explorer

Explore and analyze Supabase data
npx claude-code-templates@latest --command supabase-data-explorer

Backup Manager

Manage Supabase backups
npx claude-code-templates@latest --command supabase-backup-manager

Realtime Monitor

Monitor Supabase realtime connections
npx claude-code-templates@latest --command supabase-realtime-monitor

Type Generator

Generate TypeScript types from Supabase schema
npx claude-code-templates@latest --command supabase-type-generator

Database Workflows

Schema Design Workflow

# 1. Design schema
@database-architect Design a schema for a social media platform
with users, posts, comments, and likes. Include proper indexing.

# 2. Implement in database
@postgres-pro Implement the schema with appropriate indexes,
constraints, and triggers.

# 3. Optimize
@database-optimizer Review the schema and suggest optimizations
for queries that fetch a user's feed.

Migration Workflow

# Install Supabase tools
npx claude-code-templates@latest \
  --agent supabase-schema-architect \
  --command supabase-migration-assistant

# Create migration
/supabase-migration-assistant create add_user_profiles

# Apply migration
/supabase-migration-assistant apply

# Verify
/supabase-schema-sync verify

Performance Optimization Workflow

# Identify slow queries
@database-optimizer Analyze slow queries in the application

# Create indexes
@postgres-pro Add appropriate indexes for the identified queries

# Test performance
@database-optimizer Measure query performance improvements

# Monitor
/supabase-performance-optimizer monitor

Best Practices

1. Schema Design

@database-architect Design schema with:
- Proper normalization (3NF for transactional data)
- Strategic denormalization for performance
- Appropriate data types
- Constraints for data integrity
- Indexes for common queries

2. Query Optimization

@database-optimizer Review queries for:
- Index usage (check EXPLAIN plans)
- N+1 query problems
- Unnecessary joins
- Large result sets
- Missing WHERE clauses

3. Security

# Use RLS with Supabase
@supabase-schema-architect Implement Row Level Security policies
for multi-tenant isolation

# Audit security
/supabase-security-audit

4. Monitoring

# Monitor performance
/supabase-performance-optimizer monitor

# Monitor realtime
/supabase-realtime-monitor

# Regular backups
/supabase-backup-manager schedule

Real-World Examples

Example 1: E-commerce Database

# Install tools
npx claude-code-templates@latest \
  --agent database-architect \
  --agent postgres-pro \
  --mcp neon

# Design schema
@database-architect Design an e-commerce database with:
- Products with variants and inventory
- Shopping carts and orders
- Payment transactions
- Customer reviews
- Order fulfillment tracking

# Implement
@postgres-pro Implement the schema with:
- JSONB for product attributes
- Partial indexes for active products
- Triggers for inventory updates
- Full-text search for products

Example 2: Multi-Tenant SaaS

# Install Supabase tools
npx claude-code-templates@latest \
  --agent supabase-schema-architect \
  --command supabase-security-audit

# Design tenant isolation
@supabase-schema-architect Design multi-tenant schema with:
- Tenant-scoped data access
- RLS policies for isolation
- Shared and tenant-specific tables

# Audit security
/supabase-security-audit

Example 3: Analytics Database

# Install specialists
npx claude-code-templates@latest \
  --agent database-architect \
  --agent database-optimizer

# Design analytics schema
@database-architect Design a time-series analytics schema
with partitioning by date and appropriate aggregation tables.

# Optimize queries
@database-optimizer Optimize queries for dashboard that shows:
- Daily active users (last 30 days)
- Top 10 features by usage
- User cohort retention

Database Template

npx claude-code-templates@latest --template database-project
Includes:
  • Database architect agent
  • Database optimizer agent
  • Postgres pro agent
  • Neon MCP
  • Supabase MCP
  • Migration commands
  • Performance monitoring

Next Steps