db-optimization

A database performance guide for PostgreSQL, MySQL, MariaDB, MongoDB, and Redis. It focuses on examining queries and making safe changes to indexes, schemas, and data migrations.

In plain words
What is it for?
Use it to investigate database bottlenecks, assess indexes, fix N+1 query patterns, and plan changes to tables or fields while the application remains in use.
Why use it?
It helps find the actual cause of slow queries, lock waits, connection problems, and repeated database requests before changing the database.

Skill for Claude CodeCodex

Part of the hydraia plugin — 16 skills, 15 commands, 26 agents, 4 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/jdanigo/hydraia/db-optimization
Any agent
npx skills add jdanigo/hydraia --skill db-optimization
Clone the repo
git clone --depth 1 https://github.com/jdanigo/hydraia

Made for: Claude Code, Codex.

Or install hydraia, the plugin that ships this one along with the rest of its 16 skills, 15 commands, 26 agents, 4 hooks.

Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 736 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00065 $0.00736
Opus 5 $0.00032 $0.00368
Sonnet 5 $0.00013 $0.00147
Haiku 4.5 $0.00006 $0.00074

Measured 3d ago against content hash d098b208e001, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

db-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/db-optimization/SKILL.md · 46 lines

How it starts

The opening of the file, as written. The whole thing — 46 lines — stays where its author put it; the contents beside it link to each section on GitHub.

DB Optimization — EXPLAIN before you touch anything

Playbook for the DB half of the Hydraia perf route. The db-performance-tuner agent does the diagnosis; this skill sets the rules the route runs under.

Expand-contract migration protocol

  1. Expand: add the new column/table/index alongside the old — additive, backward-compatible, online.
  2. Dual-write + backfill: application writes both shapes; backfill history in batches (bounded, throttled, resumable).
  3. Switch reads to the new shape behind a verified flag; watch metrics.
  4. Contract: only after a full bake period, remove the old shape in a later release. Contract is its own plan task, never bundled with expand.

Index design guidance

  • Composite order: equality columns first, then range, then sort — match the query, not intuition.
  • Covering indexes to eliminate lookups for hot read paths; weigh write amplification (every index taxes every write).
  • Partial/filtered indexes for skewed predicates (WHERE deleted_at IS NULL).
  • Hunt UNUSED indexes too (pg_stat_user_indexes, sys.schema_unused_indexes) — dropping one is also an optimization.
  • The index is not always the answer: sometimes it is the query shape, the schema, or the caller (N+1, missing cache).

Read the full file on GitHub · 46 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 46 lines · 65 tokens per session scan A d098b208e001

Subscribe to this mod's changes

db-optimization is a skill published in the GitHub repository jdanigo/hydraia (8 stars, last pushed 13d ago), licensed MIT. It adds 65 tokens to every session and 736 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

moai-domain-database

Database specialist covering PostgreSQL, MongoDB, Redis, Oracle, and cloud database platforms (Neon, Supabase, Firestore). Use for schema design, query optimization, indexing strategies, data modeling, or cloud database selection. Cloud vendor guide absorbed from moai-platform-database-cloud.

modu-ai/moai-adk · 64 tokens

demo-data

Seed a Mendix app's PostgreSQL database directly, bypassing the runtime — Mendix's internal ID system, association storage, and bulk import from an external database. Use when populating test or demo data, when data is needed before the UI exists, or for imports too large for the runtime.

mendixlabs/mxcli · 66 tokens

ck:databases

Design schemas, write queries for MongoDB and PostgreSQL. Use for database design, SQL/NoSQL queries, aggregation pipelines, indexes, migrations, replication, performance optimization, psql CLI.

manhvann/codexkit · 44 tokens

azure-cosmos-db

Expert knowledge for Azure Cosmos DB development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when using Cosmos DB SQL/Mongo/Cassandra APIs, change feed, multi-region HA, vector…

MicrosoftDocs/Agent-Skills · 120 tokens

database-backup-and-restore-strategies

Cross-database backup tooling and restore-testing discipline: pgdump/pgbasebackup for PostgreSQL, mysqldump/Percona XtraBackup for MySQL/MariaDB, and mongodump/mongorestore for MongoDB — logical vs. physical backup trade-offs, point-in-time recovery, and why an untested restore is not a real backup. Use when the user…

selvarajmurugesan90/ops-engineering-skills · 139 tokens

nosql-database-design

Designs a NoSQL data model by leading with access pattern analysis. Covers DynamoDB single-table design (PK/SK/GSI) and MongoDB embedding vs referencing, consistency models, and capacity planning. Invoked when the user asks to design a DynamoDB schema, MongoDB data model, or NoSQL data model.

soulcodex/agentic · 71 tokens