Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

database-architect

БесплатноЗапускает вложенные скриптыНе проверен

Database design and optimization specialist. Schema design, query optimization, indexing strategies, data modeling, and migration planning for relational and…

oimiragieoот oimiragieo★ 48 звёзд на GitHub

Об этом скилле

Database Architect Skill

Database Architect Skill - Designs efficient database schemas, optimizes queries, plans indexes, and creates migration strategies for both relational (PostgreSQL, MySQL) and NoSQL (MongoDB, Redis) databases. - Designing normalized and denormalized schemas - Query optimization and execution plan analysis - Index strategy planning - Data modeling (ER diagrams, relationships) - Migration planning and versioning - Performance troubleshooting

Step 1: Understand Data Requirements

Gather requirements:

  1. Entities: What data needs to be stored?
  2. Relationships: How do entities relate (1:1, 1:N, N:M)?
  3. Access Patterns: How will data be queried?
  4. Volume: Expected data size and growth rate
  5. Consistency: ACID requirements vs eventual consistency

Step 2: Design Schema

For Relational Databases:

  1. Normalize: Start with 3NF to reduce redundancy
  2. Define Primary Keys: Use surrogate keys (UUID/SERIAL) or natural keys
  3. Define Foreign Keys: Establish referential integrity
  4. Consider Denormalization: Only for proven performance needs

For NoSQL Databases:

  1. Model for Queries: Design documents/collections around access patterns
  2. Embed vs Reference: Embed for 1:1/1:few, reference for 1:many
  3. Shard Key Selection: Choose keys that distribute evenly

Step 3: Plan Indexes

Index strategy based on query patterns:

-- Example: Users table with common queries
CREATE INDEX idx_users_email ON users(email);           -- Exact match
CREATE INDEX idx_users_name ON users(last_name, first_name);  -- Range/sort
CREATE INDEX idx_users_created ON users(created_at DESC);     -- Ordering

Index Guidelines:

  • Index columns used in WHERE, JOIN, ORDER BY
  • Consider composite indexes for multi-column queries
  • Avoid over-indexing (slows writes)
  • Use covering indexes for read-heavy queries

Step 4: Plan Migrations

Create versioned migrations:

migrations/
  001_create_users.sql
  002_add_email_index.sql
  003_create_orders.sql

Migration Best Practices:

  • Always include up and down migrations
  • Test migrations on production-like data
  • Plan for zero-downtime migrations
  • Backup before running migrations

Step 5: Optimize Queries

Analyze and improve slow queries:

  1. Use EXPLAIN ANALYZE: Understand execution plans
  2. Identify Table Scans: Replace with index scans
  3. Optimize JOINs: Ensure indexes on join columns
  4. Batch Operations: Use bulk inserts/updates
  5. Connection Pooling: Reduce connection overhead

Step 6: PostgreSQL 17 Features (2024–2026)

Leverage PostgreSQL 17 capabilities where applicable:

Performance improvements:

  • New VACUUM memory management — up to 20x lower memory footprint; vacuum now runs faster on busy systems
  • Streaming I/O interface accelerates sequential scans on large datasets
  • BRIN indexes support parallel builds
  • B-tree indexes are more efficient for IN clause queries
  • Optimized CTE (Common Table Expression) planning

SQL/JSON enhancements (PG 17):

  • JSON_TABLE() — converts JSON data into relational table representation
  • JSON constructors and identity functions (JSON(), JSON_SCALAR(), JSON_ARRAY(), JSON_OBJECT())
  • Use jsonpath for expressive path-based queries over JSONB columns

Incremental backups:

  • pg_basebackup supports incremental backup; combine with pg_upgrade for zero-data-loss major version upgrades

Logical replication improvements:

  • Failover control for logical replication slots
  • pg_createsubscriber creates logical replicas from physical standbys
  • pg_upgrade now preserves logical replication slots across major version upgrades

Security:

  • New MAINTAIN privilege — grants targeted maintenance rights without full superuser access
  • sslnegotiation=direct client option for direct TLS handshake (avoids round-trip)

COPY improvements:

  • COPY ... ON_ERROR ignore — continues import on row-level errors instead of aborting

Step 7: pgvector for AI Embeddings

Store and query vector embeddings alongside relational data to avoid a separate vector database:

-- Install extension
CREATE EXTENSION IF NOT EXISTS vector;

-- Table with embedding column (1536 dims for OpenAI text-embedding-3-small)
CREATE TABLE documents (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    content TEXT NOT NULL,
    embedding vector(1536),
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- IVFFlat index for approximate nearest neighbor (ANN) search
-- lists = sqrt(row_count) is a good starting value
CREATE INDEX idx_documents_embedding ON documents
    USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);

-- HNSW index (faster queries, more memory; preferred for < 1M vectors)
CREATE INDEX idx_documents_embedding_hnsw ON documents
    USING hnsw (embedding vector_cosine_ops) WITH (m = 1
Полный SKILL.md на GitHub

Установить database-architect в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Write
Edit
Bash
Glob
Grep

Вложенные файлы

commands/database-architect.mdhooks/post-execute.cjshooks/pre-execute.cjsreferences/research-requirements.mdrules/database-architect.mdschemas/input.schema.jsonschemas/output.schema.jsonscripts/main.cjstemplates/implementation-template.md

FAQ

Что делает скилл database-architect?

Database design and optimization specialist. Schema design, query optimization, indexing strategies, data modeling, and migration planning for relational and NoSQL databases.

Как установить скилл database-architect?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл database-architect запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить database-architect с