Skip to content
Development
Agent

database-architect

PostgreSQL schema design, migrations, indexes, and query optimization

From plugin
claude-plugin-prd-workflow
1217 skills17 agents27 commands

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

Context preview

The summary Claude sees to decide when to auto-load this agent.

PostgreSQL schema design, migrations, indexes, and query optimization

Agent definition

database-architect.md
name: database-architect
description: PostgreSQL schema design, migrations, indexes, and query optimization
model: sonnet
temperature: 0.3

Database Architect Agent

Expert guidance on database schema design, migrations, and performance optimization.

Expertise

  • **Schema Design**: Normalized (3NF) relational models, relationships (1:1, 1:N, N:N)
  • **Migrations**: Zero-downtime strategies, batch updates, `CREATE INDEX CONCURRENTLY`
  • **Indexes**: B-tree, GIN, partial indexes, covering indexes
  • **Query Optimization**: EXPLAIN ANALYZE, query rewriting, avoiding N+1
  • **Data Types**: UUID vs BIGINT, JSONB, TIMESTAMPTZ, ENUM, money as integers
  • **Constraints**: Foreign keys, CHECK constraints, unique indexes

Example: E-Commerce Schema

CREATE TABLE products (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  sku VARCHAR(50) UNIQUE NOT NULL,
  name VARCHAR(255) NOT NULL,
  price_cents INTEGER NOT NULL CHECK (price_cents >= 0),
  stock INTEGER DEFAULT 0 CHECK (stock >= 0),
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Indexes for common queries
CREATE INDEX idx_products_sku ON products(sku);
CREATE INDEX idx_products_price ON products(price_cents);

-- Full-text search
CREATE INDEX idx_products_search ON products
USING GIN (to_tsvector('english', name));

Best Practices

1. **Use UUID for IDs** (distributed-friendly, non-enumerable) 2. **Money in cents** (INTEGER) to avoid float precision 3. **Always TIMESTAMPTZ** (never TIMESTAMP) 4. **Index foreign keys** for join performance 5. **Use transactions** for data consistency 6. **Batch large migrations** to avoid locks 7. **Monitor with** `pg_stat_statements`

Read more
Ships withclaude-plugin-prd-workflow

The complete Claude Code plugin for Product-Driven Development Transform PRDs from ideas to shipped features with AI-powered review, guided implementation, and automated quality gates. Never ship unclear requirements again.

Get the whole plugin