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.
npx skills add khalilbenaz/claude-skills-collection --skill database-query-optimizergit clone --depth 1 https://github.com/khalilbenaz/claude-skills-collectionWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/khalilbenaz/claude-skills-collection/database-query-optimizer)<a href="https://agentmods.dev/skills/khalilbenaz/claude-skills-collection/database-query-optimizer"><img src="https://agentmods.dev/badge/skills/khalilbenaz/claude-skills-collection/database-query-optimizer.svg" alt="Measured on agentmods" height="20"></a>- NVIDIA SkillSpector pass
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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00099 | $0.02006 |
| Opus 5 | $0.00049 | $0.01003 |
| Sonnet 5 | $0.00020 | $0.00401 |
| Haiku 4.5 | $0.00010 | $0.00201 |
Grade A, and why
database-query-optimizer 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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 207 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Database Query Optimizer
Étape 1 — Collecte d'informations
Demande systématiquement (ne suppose rien) :
- SGBD et version : PostgreSQL 16, MySQL 8, SQL Server 2022, MongoDB 7, SQLite…
- Requête complète (pas un résumé, le SQL brut)
- Schéma : colonnes, types, index existants (
\d tablePG,SHOW CREATE TABLEMySQL) - Volume : lignes dans les tables concernées (ordre de grandeur suffit)
- Temps mesuré : durée actuelle, cible souhaitée, outil de mesure
- Contexte d'exécution : fréquence, OLTP vs OLAP, connexions concurrentes
Étape 2 — Diagnostic avec EXPLAIN
PostgreSQL / MySQL / SQLite
-- PostgreSQL : plan + exécution réelle
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) <requête>;
-- MySQL
EXPLAIN FORMAT=JSON <requête>;
SHOW STATUS LIKE 'Last_Query_Cost';
-- SQL Server
SET STATISTICS IO, TIME ON;
<requête>;
-- ou via SSMS : Query > Include Actual Execution Plan
Signaux d'alarme dans le plan
| Signal | Signification | Priorité |
|---|---|---|
Seq Scan sur grande table |
Pas d'index utilisable | Critique |
Hash Join + rows estimés très faux |
Statistiques obsolètes | Élevée |
Nested Loop × millions de rows |
Potentiel N+1 ou jointure cartésienne | Critique |
Sort sans Index Scan |
Manque d'index sur ORDER BY | Modérée |
cost=... très élevé vs actual rows faibles |
Mauvaise estimation selectivité | Élevée |
rows=1 partout mais slow |
Problème réseau / lock / cache miss | Variable |
Mettre à jour les statistiques
-- PostgreSQL
ANALYZE table_name;
-- MySQL
ANALYZE TABLE table_name;
-- SQL Server
UPDATE STATISTICS table_name;
Étape 3 — Optimisations concrètes
3.1 Index manquants
-- Créer un index couvrant (covering index) : évite un table lookup
CREATE INDEX CONCURRENTLY idx_orders_user_status
ON orders (user_id, status)
INCLUDE (created_at, total_amount); -- PostgreSQL 11+
-- Index partiel : si requête filtre toujours sur une valeur
CREATE INDEX idx_orders_pending
ON orders (created_at)
WHERE status = 'pending';
-- Index composite : ordre des colonnes = sélectivité décroissante
-- Bon : (user_id, status) -- user_id très sélectif
-- Mauvais : (status, user_id) -- status peu sélectif en tête
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.
- 5d ago First seen · 207 lines · 99 tokens per session scan A f7491377e958
database-query-optimizer is a skill published in the GitHub repository khalilbenaz/claude-skills-collection (22 stars, last pushed 14d ago), licensed MIT. It adds 99 tokens to every session and 2,006 once invoked, about $0.0005 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-09-03.
Other skills, from other repositories
frappe-errors-database
Use when handling database errors in Frappe/ERPNext. Covers DuplicateEntryError, LinkValidationError, MandatoryError, TimestampMismatchError, CharacterLengthExceededError, InReadOnlyMode, QueryTimeoutError, SQL injection errors, frappe.db.sql parameter format (% vs %s), getvalue returning None, transaction deadlocks…
sql-optimization-patterns
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.
database-patterns
DB schema design and query tuning: normalization, indexing, N+1, transactions, EXPLAIN. Triggers: schema, index, slow query, N+1, PostgreSQL, MySQL, EXPLAIN, deadlock, query plan.
debug
Systematic debugging via logs, health checks, hypothesis-driven investigation. Triggers: debug, error, trace root cause, fix bug, reproduce symptom, investigation.
introspect
Agent self-debugging and recovery. Use when stuck in loops, making repeated errors, or quality degrades. Triggers: introspect, self-debug, stuck, loop, why failing.
migration-patterns
Zero-downtime DB migrations: expand-contract, double-write, backfill, blue-green. Triggers: migration, schema change, backfill, ALTER TABLE, online DDL.