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 agentmods add skills/vasilyu1983/ai-agents-public/data-sql-optimizationnpx skills add vasilyu1983/AI-Agents-public --skill data-sql-optimizationgit clone --depth 1 https://github.com/vasilyu1983/AI-Agents-publicWrote 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/vasilyu1983/ai-agents-public/data-sql-optimization)<a href="https://agentmods.dev/skills/vasilyu1983/ai-agents-public/data-sql-optimization"><img src="https://agentmods.dev/badge/skills/vasilyu1983/ai-agents-public/data-sql-optimization.svg" alt="Measured on agentmods" height="20"></a>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 | $0.00041 | $0.03927 |
| Opus 5 | $0.00020 | $0.01963 |
| Sonnet 5 | $0.00008 | $0.00785 |
| Haiku 4.5 | $0.00004 | $0.00393 |
Grade A, and why
data-sql-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 today.
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 — 256 lines — stays where its author put it; the contents beside it link to each section on GitHub.
SQL Optimization
Operational guidance for transactional SQL systems. This skill is strongest on PostgreSQL, MySQL, and SQL Server for query tuning, plan analysis, index strategy, connection pressure, lock contention, and safe production changes.
Primary coverage: PostgreSQL, MySQL, SQL Server Lighter coverage: Oracle, SQLite Out of scope: OLAP engines and lakehouse tuning. Use data-lake-platform for ClickHouse, DuckDB, Doris, StarRocks, Iceberg, Delta Lake, or Hudi.
Quick Reference
Scripts
| Script | What it does | Usage |
|---|---|---|
| scripts/pg_slow_query_triage.sql | Five-section triage report from pg_stat_statements: top by total time, mean time, I/O, variance, and cache-hit ratio |
Copy-paste into psql or any SQL client; requires pg_stat_statements extension |
| scripts/explain_collector.py | Runs EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) on a list of queries via psql, outputs JSONL |
DATABASE_URL=postgresql://... python explain_collector.py --queries slow.txt |
# Triage: paste directly into psql
psql $DATABASE_URL -f frameworks/shared-skills/skills/data-sql-optimization/scripts/pg_slow_query_triage.sql
# Collect EXPLAIN plans for top queries (production-safe mode):
python scripts/explain_collector.py --queries queries.txt --no-analyze --output plans.jsonl
# Collect with ANALYZE (executes queries — use on a replica):
DATABASE_URL=postgresql://user:pass@replica:5432/db \
python scripts/explain_collector.py --queries queries.txt --output plans.jsonl
| Need | Start Here | Use When |
|---|---|---|
| Slow query triage | template-slow-query.md | You need a safe intake before changing anything |
| Plan review | references/explain-analysis.md | You already have EXPLAIN, EXPLAIN ANALYZE, Query Store, or Performance Schema evidence |
| Index design or index removal | references/index-patterns.md | You are deciding whether to add, reshape, make invisible, or drop an index |
| Query rewrite | references/query-tuning-patterns.md | A query shape or estimation problem is the likely bottleneck |
| Connection saturation | references/connection-pooling-patterns.md | App pools, PgBouncer, RDS Proxy, Supavisor, or Cloud SQL pooling are involved |
| Monitoring and alerting | references/monitoring-alerting-patterns.md | You need dashboards, baselines, or alerts for database performance |
| Locking / deadlocks | template-lock-analysis.md | The issue is blocking, deadlocks, or long transactions rather than raw query cost |
| Partitioning | references/partition-strategies.md | Retention, pruning, or table growth is driving the change |
| Backup and recovery design | references/recovery-strategy-design.md | You need a recovery capability mapped to failure scenarios, not just a backup job |
| Security or RLS review | template-security-audit.md | You are reviewing least privilege, SQL injection controls, or tenant isolation |
What ships with it
40 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- agents/openai.yaml 309 B
- assets/cross-platform/template-backup-restore.md 5.2 KB
- assets/cross-platform/template-diagnostics.md 4.9 KB
- assets/cross-platform/template-explain-analysis.md 3.2 KB
- assets/cross-platform/template-index.md 3.7 KB
- assets/cross-platform/template-lock-analysis.md 6.0 KB
- assets/cross-platform/template-migration.md 5.2 KB
- assets/cross-platform/template-performance-tuning-worksheet.md 6.8 KB
- assets/cross-platform/template-query-tuning.md 3.4 KB
- assets/cross-platform/template-schema-design.md 6.3 KB
- assets/cross-platform/template-security-audit.md 5.7 KB
- assets/cross-platform/template-slow-query.md 4.7 KB
- assets/mssql/template-mssql-explain.md 11 KB
- assets/mssql/template-mssql-index.md 10 KB
- assets/mysql/template-mysql-explain.md 3.5 KB
- assets/mysql/template-mysql-index.md 3.4 KB
- assets/mysql/template-replication-ha.md 14 KB
- assets/oracle/template-oracle-explain.md 10 KB
- assets/postgres/template-pg-explain.md 3.3 KB
- assets/postgres/template-pg-index.md 3.6 KB
- assets/postgres/template-pg-rls.md 28 KB
- assets/postgres/template-replication-ha.md 15 KB
- assets/sqlite/template-sqlite-optimization.md 10 KB
- data/sources.json 19 KB
- data/versions.json 2.3 KB
- learnings.consolidated.md 597 B
- learnings.md 357 B
- references/connection-pooling-patterns.md 10 KB
- references/explain-analysis.md 12 KB
- references/index-patterns.md 10 KB
- references/monitoring-alerting-patterns.md 3.5 KB
- references/operational-patterns.md 15 KB
- references/partition-strategies.md 16 KB
- references/query-optimization-research-runtime.md 4.4 KB
- references/query-tuning-patterns.md 18 KB
- references/recovery-strategy-design.md 16 KB
- references/sql-antipatterns.md 14 KB
- references/sql-best-practices.md 2.7 KB
- scripts/explain_collector.py 9.2 KB runs code
- scripts/pg_slow_query_triage.sql 11 KB
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.
- today Changed · +2 lines 79a673987aa2
- 3d ago First seen · 254 lines · 41 tokens per session scan A 4480c554aab3
data-sql-optimization is a skill published in the GitHub repository vasilyu1983/AI-Agents-public (82 stars, last pushed yesterday), licensed MIT. It adds 41 tokens to every session and 3,927 once invoked, about $0.0002 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-30.
Other skills, from other repositories
prisma-postgres-setup
Set up a new Prisma Postgres database and connect it to a local project using the Management API. Use when asked to "set up a database", "create a Prisma Postgres project", "get a connection string", "connect my app to Prisma Postgres", or "provision a database".
prisma-client-api
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
graph-db-writes
Writing to the Neo4j attack-surface graph in RedAmon: the tenant-isolation MERGE key every entity node must carry, where graph methods live (mixins, not the client), and the schema places that must be updated together. A MERGE missing the tenant key silently merges one project's data into another's. Trigger: editing…
vellum-migration-checklist
Validate Vellum Assistant database and workspace migrations. Use when adding, editing, reviewing, or testing migrations, release-note migrations, persisted schemas, workspace file formats, or data backfills.
prisma-mongodb-upgrade
Decision and migration guide for Prisma ORM MongoDB projects on v6, which have no upgrade path to v7. Use when a MongoDB project asks about upgrading Prisma, when "upgrade to prisma 7" comes up in a project with provider = "mongodb", or when evaluating a move to Prisma Next. Triggers on "upgrade prisma mongodb"…
system-design-data-architecture
Choose and scale the data layer: SQL versus NoSQL per access pattern, single data ownership, replication and read scaling, partition key choice, hot partition and celebrity key mitigation. Use when selecting a store, planning sharding, or fixing a data-tier bottleneck.