borghei/Claude-Skills / engineering/sql-database-assistant
sql-database-assistant
VerifiedReview SQL queries for index and scan problems, document schemas from DDL, and generate migrations with rollback and destructive-change flags. Use when tuning a query, documenting a schema, or diffing two schemas.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.5 KB |
| examples/queries.sql | other | 3.1 KB |
| examples/schema.sql | other | 3.3 KB |
| examples/schema_additive.sql | other | 3.3 KB |
| examples/schema_v2.sql | other | 2.9 KB |
| references/sql-optimization.md | markdown | 3.9 KB |
| scripts/migration_generator.py | script | 14.1 KB |
| scripts/query_optimizer.py | script | 14.9 KB |
| scripts/schema_explorer.py | script | 11.5 KB |
examples/schema_v2.sql
View on GitHub-- schema_v2.sql: target schema that adds users.timezone, drops users.phone and drops
-- the inventory_log table. migration_generator.py flags the drops as destructive (exit 1).
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
full_name VARCHAR(150) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
last_login_at TIMESTAMP,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
role VARCHAR(20) NOT NULL DEFAULT 'customer',
timezone VARCHAR(64)
);
CREATE TABLE products (
id SERIAL PRIMARY KEY,
sku VARCHAR(50) NOT NULL UNIQUE,
name VARCHAR(255) NOT NULL,
description TEXT,
price_cents INTEGER NOT NULL CHECK (price_cents >= 0),
currency VARCHAR(3) NOT NULL DEFAULT 'USD',
category VARCHAR(100),
stock_quantity INTEGER NOT NULL DEFAULT 0,
is_published BOOLEAN NOT NULL DEFAULT FALSE,
weight_grams INTEGER,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_products_category ON products(category);
CREATE INDEX idx_products_sku ON products(sku);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
status VARCHAR(30) NOT NULL DEFAULT 'pending',
subtotal_cents INTEGER NOT NULL,
tax_cents INTEGER NOT NULL DEFAULT 0,
shipping_cents INTEGER NOT NULL DEFAULT 0,
total_cents INTEGER NOT NULL,
shipping_address TEXT,
billing_address TEXT,
notes TEXT,
placed_at TIMESTAMP NOT NULL DEFAULT NOW(),
shipped_at TIMESTAMP,
delivered_at TIMESTAMP
);
CREATE INDEX idx_orders_user_id ON orders(user_id);
CREATE INDEX idx_orders_status ON orders(status);
CREATE TABLE order_items (
id SERIAL PRIMARY KEY,
order_id INTEGER NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
product_id INTEGER NOT NULL REFERENCES products(id),
quantity INTEGER NOT NULL CHECK (quantity > 0),
unit_price_cents INTEGER NOT NULL,
total_cents INTEGER NOT NULL
);
CREATE INDEX idx_order_items_order_id ON order_items(order_id);
CREATE TABLE reviews (
id SERIAL PRIMARY KEY,
product_id INTEGER NOT NULL REFERENCES products(id),
user_id INTEGER NOT NULL REFERENCES users(id),
rating SMALLINT NOT NULL CHECK (rating BETWEEN 1 AND 5),
title VARCHAR(200),
body TEXT,
is_verified BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
-- Note: no index on reviews.product_id or reviews.user_id (design issue)
-- Note: no index on inventory_log.product_id (design issue for frequent lookups)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |