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 AltimateAI/data-engineering-skills --skill optimizing-query-textgit clone --depth 1 https://github.com/AltimateAI/data-engineering-skillsWrote 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/altimateai/data-engineering-skills/optimizing-query-text)<a href="https://agentmods.dev/skills/altimateai/data-engineering-skills/optimizing-query-text"><img src="https://agentmods.dev/badge/skills/altimateai/data-engineering-skills/optimizing-query-text/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/altimateai/data-engineering-skills/optimizing-query-text"><img src="https://agentmods.dev/badge/skills/altimateai/data-engineering-skills/optimizing-query-text.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.00113 | $0.01729 |
| Opus 5.5 | $0.00045 | $0.00692 |
| Sonnet 5.5 | $0.00023 | $0.00346 |
| Haiku 4.5 | $0.00011 | $0.00173 |
Grade A, and why
optimizing-query-text 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 1mo 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 — 167 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Optimize Query from SQL Text
OUTPUT FORMAT
Return ONLY the optimized SQL query. No markdown formatting, no explanations, no bullet points - just pure SQL that can be executed directly in Snowflake.
CRITICAL: Semantic Preservation Rules
The optimized query MUST return IDENTICAL results to the original.
Before returning ANY optimization, verify:
- Same columns: Exact same columns in exact same order with exact same aliases
- Same rows: Filter conditions must be semantically equivalent
- Same ordering: Preserve
ORDER BYexactly as written - Same limits: If original has
LIMIT N, keepLIMIT N. If no LIMIT, do NOT add one.
If you cannot guarantee identical results, return the original query unchanged.
Pattern 1: Function on Filter Column
Problem: Functions on columns in WHERE clause prevent partition pruning and index usage.
CAN Fix
| Original | Optimized | Why Safe |
|---|---|---|
WHERE DATE(ts) = '2024-01-01' |
WHERE ts >= '2024-01-01' AND ts < '2024-01-02' |
Equivalent range |
WHERE YEAR(dt) = 2024 |
WHERE dt >= '2024-01-01' AND dt < '2025-01-01' |
Equivalent range |
WHERE MONTH(dt) = 3 AND YEAR(dt) = 2024 |
WHERE dt >= '2024-03-01' AND dt < '2024-04-01' |
Equivalent range |
WHERE DATE(ts) >= '2024-01-01' AND DATE(ts) < '2024-02-01' |
WHERE ts >= '2024-01-01' AND ts < '2024-02-01' |
Same boundaries |
WHERE YEAR(dt) BETWEEN 1995 AND 1996 |
WHERE dt >= '1995-01-01' AND dt < '1997-01-01' |
Equivalent range |
CANNOT Fix
| Pattern | Why Not |
|---|---|
WHERE YEAR(dt) IN (SELECT year FROM ...) |
Dynamic values, cannot precompute range |
WHERE DATE(ts) = DATE(other_col) |
Comparing two columns, both need function |
WHERE EXTRACT(DOW FROM dt) = 1 |
Day-of-week has no contiguous range |
WHERE DATE_TRUNC('month', dt) = '2024-01-01' in GROUP BY |
Needed for grouping logic |
SELECT YEAR(dt) AS yr ... GROUP BY YEAR(dt) |
Function in SELECT/GROUP BY is fine, only filter matters |
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.
- 1mo ago First seen · 167 lines · 113 tokens per session scan A 5007588fe49f
optimizing-query-text is a skill published in the GitHub repository AltimateAI/data-engineering-skills (128 stars, last pushed 3d ago), licensed MIT. It adds 113 tokens to every session and 1,729 once invoked, about $0.0005 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-08-30.
Other skills, from other repositories
backend-patterns
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
dbt-patterns
The most important design decision in a dbt project is how to organize model layers. A clear layer structure means every model has exactly one place it belongs, and anyone reading the project can understand what each model does.
data-migration
Moving data between systems safely — cutover planning, backfill strategies, dual-write patterns, validation, rollback procedures, and zero-downtime migration techniques. Use this skill whenever the team is migrating from one database or warehouse to another (MySQL → Snowflake, Redshift → BigQuery, on-prem → cloud)…
schema-design
Data modeling for analytical workloads — star schema, snowflake schema, one big table (OBT), slowly changing dimensions (SCD), normalization tradeoffs, grain definition, and surrogate key strategies. Use this skill whenever the user is designing or reviewing a data warehouse schema, planning a fact/dimension table…
sql-patterns
Best-practice SQL for analytical workloads — window functions, CTEs, query optimization, partitioning strategies, and anti-patterns to avoid. Use this skill whenever the user is writing or reviewing a SQL query that goes beyond a basic SELECT, especially on BigQuery, Snowflake, Redshift, or DuckDB. Trigger on mentions…
data-profiling
Profile and map raw data BEFORE designing a schema. One-time exploratory analysis to learn the true shape of a dataset — row/column counts, null rates, cardinality, value distributions, ranges, data types, candidate keys, duplicates, referential relationships — then a source-to-target field mapping and an ER diagram.…