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 tmj-90/gaffer --skill sql-query-performancegit clone --depth 1 https://github.com/tmj-90/gafferWrote 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/tmj-90/gaffer/sql-query-performance)<a href="https://agentmods.dev/skills/tmj-90/gaffer/sql-query-performance"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/sql-query-performance/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/tmj-90/gaffer/sql-query-performance"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/sql-query-performance.svg" alt="Reviewed on agentmods" width="80" 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.1 | $0.00082 | $0.01474 |
| Opus 5.5 | $0.00033 | $0.00590 |
| Sonnet 5.5 | $0.00016 | $0.00295 |
| Haiku 4.5 | $0.00008 | $0.00147 |
Grade A, and why
sql-query-performance 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 16d 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 — 93 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Make a slow query fast
The database already knows why the query is slow; ask it. Read the plan, find the scan,
loop or sort that dominates, change the query or add the index the plan needs, and
measure again on data shaped like production. Most slow queries are an N+1, a missing
or wrong-order index, a function or type cast on an indexed column, a wide SELECT *,
an OFFSET walk, or stale statistics. Sources: PostgreSQL docs ("Using EXPLAIN",
indexes, pg_stat_statements, explicit locking); MySQL 8 reference (EXPLAIN ANALYZE,
optimisation, InnoDB locking); Markus Winand, Use The Index, Luke.
Steps
- Capture the real SQL and its frequency. From the ORM query log, the slow-query
log,
pg_stat_statements(total and mean time) orperformance_schema, with real parameter values. An ORM call is not a query. Count queries per request: fifty fast queries make one slow page. Callsearch_lorefor hot tables and index conventions. - Build production-shaped data. Seed row counts, value distributions and skew
comparable to production (
generate_seriesor the repo's fixture factories, thetest-fixtures-and-factoriesskill), then runANALYZE. A plan on ten rows lies. - Read the plan. Postgres:
EXPLAIN (ANALYZE, BUFFERS); MySQL 8.0.18+:EXPLAIN ANALYZE(orEXPLAIN FORMAT=TREE); SQLite:EXPLAIN QUERY PLAN.ANALYZEexecutes the statement: wrapINSERT/UPDATE/DELETEinBEGIN; … ROLLBACK;. Look for: sequential scans filtering most rows away, nested loops with large outer row counts, sorts or hashes spilling to disk, estimated vs actual rows off by 10× or more (stale or missing statistics; tryANALYZEor extended statistics), and heap fetches on an intended index-only scan (vacuum/visibility map). - Fix N+1 first. Load related rows in one query (join,
IN (…)/= ANY($1)batch, the ORM's eager loading or a dataloader) and pin it with a query-count assertion. - Add the index the plan needs, and only that. Composite order: equality columns,
then the range column, then the sort columns in the query's direction. Covering
(
INCLUDE) for hot read paths, partial for selective predicates. One index per access pattern; every index costs every write. Ship it through the migration path (theadd-db-migrationskill):CREATE INDEX CONCURRENTLYoutside a transaction in Postgres (drop and retry if it leaves anINVALIDindex), online DDL in MySQL. - Make predicates sargable. No function or cast on the indexed column (
WHERE created_at >= :day_start AND created_at < :next_day, notdate(created_at) = :d), or index the expression; match parameter types to column types (MySQL string-vs-int comparisons defeat indexes); no leading-wildcardLIKE(use trigram or full-text); splitORacross different columns intoUNION ALLwhen the plan shows a scan; select only needed columns; replaceOFFSETwalks with keyset pagination (thepagination-and-filteringskill). - Protect the write path and other sessions. Long reports and bulk updates hold
locks and snapshots: set
statement_timeout/lock_timeout(ormax_execution_time), batch largeUPDATE/DELETEin keyed chunks with a commit per chunk, and move heavy reads to a replica, a materialised view refreshed on a schedule (thescheduled-jobsskill;REFRESH MATERIALIZED VIEW CONCURRENTLYneeds a unique index), or a summary table maintained by the writes. - Measure again with the same data and tool: before/after plan and timing over repeated runs (discard the first cold run or report cold and warm separately). If the new index does not appear in the plan, drop it.
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.
- 16d ago Changed · +26 lines 95cd3fa8d799
- 19d ago First seen · 67 lines · 82 tokens per session scan A 0ca3aa794199
sql-query-performance is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 82 tokens to every session and 1,474 once invoked, about $0.0003 per session on Opus 5.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-28.
Other skills, from other repositories
bulwark-brainstorm
Role-based brainstorming with dual modes: --scoped (sequential Task tool, 5 roles) and --exploratory (Agent Teams peer debate, 4 roles). Use for feasibility assessment and idea validation.
plan-creation
Create structured implementation plans via a 4-role scrum team (Product Owner, Architect, Eng/Delivery Lead, QA/Critic) with optional Agent Teams peer debate mode.
anthropic-validator
Validates Claude Code assets (skills, hooks, agents, commands, MCP servers, plugins) against official Anthropic standards. Fetches latest docs dynamically and produces structured validation reports.
create-subagent
Generates single-purpose Claude Code sub-agents for use via the Task tool. Use when creating dedicated sub-agents, scaffolding agent definitions, or generating agents with diagnostics and permissions setup.
test-audit
Audit test suites for T1-T4 violations using AST analysis, mock detection, and multi-stage synthesis. Invoke when user asks to audit tests, check test quality, find mock violations, review test effectiveness, or inspect test suites for over-mocking. Triggers automatic rewrites when quality gates fail.
code-review
Comprehensive code review with distinct aspect based sections. Use when reviewing code, checking for security issues, finding type safety problems, auditing code quality, or when user asks to review code, PRs or changes. Three-phase workflow runs static tools, LLM judgment, and writes diagnostic log.