database-design

Design query-first PostgreSQL schemas with pgvector for AI storage.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/Victoriakaey/build-reliable-agents --skill database-design-victoriakaey
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-design
Source: https://github.com/Victoriakaey/build-reliable-agents/tree/main/skills/database-design
Command: npx skills add https://github.com/Victoriakaey/build-reliable-agents --skill database-design-victoriakaey

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Poor schema design leads to expensive refactors, slow queries, and untraceable AI behavior; this Skill guides engineers to design schemas that match query patterns, scale reliably, and support AI-specific storage needs like embeddings and conversation history.

Core Features & Use Cases

  • Query-first modeling: Walks you through identifying core entities, common read/write patterns, and designing tables or collections that make those queries fast and simple.
  • AI-specific patterns: Provides canonical tables and decisions for conversation storage, LLM run auditing, embedding storage with pgvector, and append-only agent state with versioning.
  • Operational guidance: Covers indexing strategies, naming conventions, token and cost tracking, JSONB usage, and schema review checklists to avoid common pitfalls.
  • Use Case: Design a PostgreSQL schema with pgvector to store chat sessions, messages, embeddings, llm run logs, and immutable agent state for production monitoring and retrievability.

Quick Start

Use the database-design skill to draft a PostgreSQL schema that stores sessions, messages, llm_runs, embeddings (with pgvector), and append-only agent_state snapshots for a conversational agent.

Frequently Asked Questions about database-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a PostgreSQL schema for conversation storage and LLM logging?

To design a PostgreSQL schema for conversation storage and LLM logging, apply query-first modeling to define core entities, common read/write patterns, and canonical tables for sessions, messages, and llm_runs.

What's the best way to store embeddings and vector data in PostgreSQL?

The best way to store embeddings in PostgreSQL is using the pgvector extension, applying schema patterns that integrate vector storage with relational data for fast similarity queries and retrievability.

How do I implement append-only agent state versioning in a database?

To implement append-only agent state versioning, design immutable state snapshot tables that preserve chronological history, ensuring auditability for debugging and production monitoring of AI agents.

When should I use JSONB columns in a database schema for AI applications?

Use JSONB columns in database schemas for AI applications to store flexible, semi-structured payloads like LLM inputs and outputs, balancing query efficiency with schema adaptability for evolving data models.

Can I refactor an existing database schema to support token and cost tracking?

Yes, you can refactor an existing schema to support token and cost tracking by introducing dedicated tracking fields and tables, ensuring operational metrics are captured without disrupting current query performance.

Why does query-first database schema design prevent expensive refactors?

Query-first database schema design prevents expensive refactors by aligning table structures and indexing strategies directly with actual read/write patterns, ensuring queries remain fast and simple as applications scale.