Skip to main content
skill CX Codex

database-expert — Claude Code skill for database design

The database-expert Claude Code skill covers database schema design, query tuning, and administration. It activates for work with PostgreSQL, MongoDB, and Redis.

MIT 255 installs ★ 114 updated 2026-11-10

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add travisjneuman/.claude --skill database-expert -a claude-code
Open on GitHub

What database-expert does

database-expert provides guidance for shaping database schemas, examining queries, and managing performance. Its PostgreSQL material includes indexes, full-text search, CTEs, and query analysis with EXPLAIN ANALYZE.

Separate reference files cover MongoDB, Redis, and query optimization. There is also a guide to vector databases for AI/RAG workloads, with pgvector, Pinecone, and Chroma. A database-selection table includes SQLite as well.

The skill is meant for schema design, query optimization, and database performance tasks.

What it helps with

  • design tables and relationships in PostgreSQL
  • inspect a SQL query execution plan
  • choose indexes for filtering or sorting
  • compare databases for caching or flexible schemas

Example prompts for the agent

  • Design a PostgreSQL schema for users and posts, including constraints and indexes.
  • Analyze this PostgreSQL query and show how to inspect its execution plan.
  • Compare PostgreSQL, MongoDB, and Redis for storing this data.

How to install database-expert

1Skills CLI (Vercel)

npx skills add travisjneuman/.claude --skill database-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/database-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/database-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about database-expert

How do I install database-expert in Claude Code?

Run npx skills add travisjneuman/.claude --skill database-expert -a claude-code. The skill file is located at ~/.claude/skills/database-expert/SKILL.md.

What does database-expert do?

It provides guidance on database schemas, query tuning, and administration. The materials include PostgreSQL examples and separate references for MongoDB and Redis.

Which databases does database-expert cover?

Its guidance covers PostgreSQL, MongoDB, and Redis. SQLite and vector stores such as pgvector, Pinecone, and Chroma also appear in the materials.

Source text

SKILL.md · MIT
---
name: database-expert
description: Advanced database design and administration for PostgreSQL, MongoDB, and Redis. Use when designing schemas, optimizing queries, managing database performance, or implementing data patterns.
---

# Database Expert

Comprehensive guide for database design, optimization, and administration.

## Database Selection

| Database       | Type       | Best For                            |
| -------------- | ---------- | ----------------------------------- |
| **PostgreSQL** | Relational | Complex queries, ACID, JSON support |
| **MongoDB**    | Document   | Flexible schemas, rapid iteration   |
| **Redis**      | Key-Value  | Caching, sessions, real-time        |
| **SQLite**     | Embedded   | Mobile, desktop, testing            |

---

## PostgreSQL

### Schema Design

```sql
-- Users table with proper constraints
CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    email VARCHAR(255) NOT NULL UNIQUE,
    password_hash VARCHAR(255) NOT NULL,
    full_name VARCHAR(100) NOT NULL,
    status VARCHAR(20) NOT NULL DEFAULT 'active'
        CHECK (status IN ('active', 'inactive', 'suspended')),
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Index for common queries
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_users_status ON users(status) WHERE status = 'active';

-- Automatic updated_at trigger
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
    NEW.updated_at = NOW();
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER update_users_updated_at
    BEFORE UPDATE ON users
    FOR EACH ROW
    EXECUTE FUNCTION update_updated_at_column();

-- Posts with full-text search
CREATE TABLE posts (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    author_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    tags TEXT[] DEFAULT '{}',
    search_vector TSVECTOR,
    published_at TIMESTAMPTZ,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Full-text search index
CREATE INDEX idx_posts_search ON posts USING GIN(search_vector);
```

### Query Optimization

```sql
-- EXPLAIN ANALYZE for query analysis
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT u.full_name, COUNT(p.id) as post_count
FROM users u
LEFT JOIN posts p ON p.author_id = u.id
WHERE u.status = 'active'
GROUP BY u.id
ORDER BY post_count DESC
LIMIT 10;

-- Partial index for filtered queries
CREATE INDEX idx_posts_published
ON posts(published_at)
WHERE published_at IS NOT NULL;

-- Covering index (index-only scan)
CREATE INDEX idx_posts_author_title
ON posts(author_id)
INCLUDE (title, published_at);

-- Expression index
CREATE INDEX idx_users_email_lower
ON users(LOWER(email));
```

### Advanced Features

```sql
-- Common Table Expression (CTE)
WITH active_authors AS (
    SELECT DISTINCT author_id
    FROM posts
    WHERE published_at > NOW() - INTERVAL '30 days'
),
author_stats AS (
    SELECT
        u.id,
        u.full_name,
        COUNT(p.id) as total_posts
    FROM users u
    JOIN active_authors aa ON aa.author_id = u.id
    LEFT JOIN posts p ON p.author_id = u.id
    GROUP BY u.id
)
SELECT * FROM author_stats
ORDER BY total_posts DESC;

-- Window functions
SELECT
    id,
    title,
    author_id,
    published_at,
    ROW_NUMBER() OVER (PARTITION BY author_id ORDER BY published_at DESC) as author_rank,
    LAG(published_at) OVER (PARTITION BY author_id ORDER BY published_at) as prev_post_date
FROM posts
WHERE published_at IS NOT NULL;

-- JSON operations
SELECT
    id,
    metadata->>'source' as source,
    metadata->'stats'->>'views' as views
FROM posts
WHERE metadata @> '{"featured": true}';

-- Recursive CTE (for hierarchies)
WITH RECURSIVE category_tree AS (
    SELECT id, name, parent_id, 0 as depth
    FROM categories
    WHERE parent_id IS NULL
    UNION ALL
    SELECT c.id, c.name, c.parent_id, ct.depth + 1
    FROM categories c
    JOIN category_tree ct ON c.parent_id = ct.id
    WHERE ct.depth < 10
)
SELECT * FROM category_tree ORDER BY depth;
```

---

## Reference files

Detailed material is in separate files so this overview stays short. Read only the file whose topic matches the task; each one is self-contained. Paths are relative to the folder that holds this `SKILL.md` (in the full toolkit install, `~/.claude/skills/database-expert/`).

| Topic | File | Covers |
| --- | --- | --- |
| MongoDB | [`references/mongodb.md`](references/mongodb.md) | Schema Design Patterns; Aggregation Pipeline; Indexes |
| Redis | [`references/redis.md`](references/redis.md) | Data Structures; Caching Patterns; Pub/Sub |
| Query Optimization Checklist | [`references/query-optimization-checklist.md`](references/query-optimization-checklist.md) | PostgreSQL; MongoDB; Redis |
| Vector Databases for AI/RAG Workloads | [`references/vector-databases-for-ai-rag-workloads.md`](references/vector-databases-for-ai-rag-workloads.md) | Overview; pgvector (PostgreSQL Extension); Pinecone (Managed); Chroma (Local/Embedded); Embedding Storage and Indexing Best Practices |

© travisjneuman · MIT · travisjneuman/.claude

Similar skills

All skills for Data and databases →

From the same set117

The whole set →
audio-production The audio-production skill for Claude Code guides recording, mixing, mastering, and sound design for music, podcasts, and video. CX Codex +1 328installs ui-animation The ui-animation Claude Code skill guides interface animation, from micro-interactions to page transitions. It applies to motion work on web and mobile screens. CX Codex +1 304installs macos-native The macos-native Claude Code skill guides native macOS app development with AppKit, Catalyst, and system APIs. It activates for Mac apps, menu bar utilities, system extensions, and macOS-specific features. CX Codex +1 298installs health-wellness health-wellness is a Claude Code skill that brings together corporate frameworks for employee wellness programs, workplace ergonomics, safety metrics, and healthcare plan design. CX Codex +1 281installs generic-react-ux-designer generic-react-ux-designer — a skill for designing React interfaces: interaction patterns, accessibility, forms, micro-interactions with Framer Motion. CX Codex +1 253installs event-planner event-planner structures event planning with 12-month timelines, budget allocation models, venue matrices, and day-of run sheets. CX Codex +1 253installs leadership Executive leadership frameworks covering decision-making, organizational changes, crisis response, and board relations for coding agents. CX Codex +1 249installs video-production video-production — a skill that walks a video from script and shot list through lighting, sound and codecs, then installs in Claude with a single command. CX Codex +1 237installs

Project sponsors

Companies that keep this analytics open