database-expert

Diagnose and optimize database queries, schemas, indexes, and connections across PostgreSQL, MySQL, MongoDB, and SQLite.

3|Updated Jan 15, 2026
One-click install
npx skills add https://github.com/trudyan141/my-antigravity-agents-kit --skill database-expert-trudyan141
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-expert
Source: https://github.com/trudyan141/my-antigravity-agents-kit/tree/main/templates/.agent/skills/database-expert
Command: npx skills add https://github.com/trudyan141/my-antigravity-agents-kit --skill database-expert-trudyan141

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database issues like slow queries, connection pool exhaustion, deadlocks, and risky migrations are hard to diagnose without deep expertise. This Skill provides a structured diagnostic workflow that detects your database environment, categorizes the problem, and applies progressive fixes with safety guardrails. ## Core Features & Use Cases - Query Performance Optimization: Analyze EXPLAIN plans, eliminate sequential scans and N+1 queries, and design composite or partial indexes for PostgreSQL, MySQL, MongoDB, and SQLite. - Schema Design & Safe Migrations: Enforce constraints, normalization, and zero-downtime migration strategies with rollback planning. - Connection & Transaction Management: Configure pooling (PgBouncer, ProxySQL), resolve deadlocks, and tune isolation levels. - ORM Integration: Optimize Prisma, TypeORM, Sequelize, and Mongoose usage with eager loading and query monitoring. - Use Case: Your PostgreSQL-backed API times out under load. The Skill detects the environment, identifies missing indexes and connection pool exhaustion via pg_stat_activity, then applies minimal-to-complete fixes with validation. ## Quick Start Ask the assistant to analyze why your database queries are slow and to review your schema, indexes, and connection pool configuration for your specific database and ORM.

Frequently Asked Questions about database-expert

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

FAQPage Schema
How do I fix slow database queries in PostgreSQL?

Run EXPLAIN (ANALYZE, BUFFERS) on the slow query to find sequential scans, then add indexes on WHERE clause columns and rewrite subqueries as JOINs. Use pg_stat_statements to identify the most time-consuming queries overall.

How to prevent N+1 queries with Prisma or TypeORM?

Use eager loading instead of separate queries per record. In Prisma, pass include or select to fetch relations in one query; in TypeORM, mark relations with eager: true or use joins in the query builder.

Why does PostgreSQL run out of connections?

PostgreSQL uses a process per connection consuming roughly 9MB each, so pools exhaust quickly under load. Deploy a connection pooler like PgBouncer, size pools appropriately, and monitor pg_stat_activity for idle connections.

Does this approach support MongoDB and SQLite?

Yes, the workflow covers MongoDB document design, aggregation pipelines, and sharding, plus SQLite WAL mode and VACUUM operations. Environment detection uses connection strings, config files, and package dependencies to select the right guidance.

How do I run zero-downtime migrations on large tables?

Test migrations on production-sized data, create indexes CONCURRENTLY where supported, and provide rollback scripts. Always verify backups exist before schema changes and avoid destructive operations like DROP or unqualified DELETE.

What index strategy works best for composite queries?

Place the most selective columns first in composite indexes, except when matching ORDER BY requirements. Use covering indexes that include all SELECT columns and partial indexes with WHERE clauses for filtered queries.