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 ibm-self-serve-assets/building-blocks --skill text2sql-query-optimizergit clone --depth 1 https://github.com/ibm-self-serve-assets/building-blocksWrote 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/ibm-self-serve-assets/building-blocks/text2sql-query-optimizer)<a href="https://agentmods.dev/skills/ibm-self-serve-assets/building-blocks/text2sql-query-optimizer"><img src="https://agentmods.dev/badge/skills/ibm-self-serve-assets/building-blocks/text2sql-query-optimizer.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.1 | $0.00061 | $0.01323 |
| Opus 5 | $0.00030 | $0.00661 |
| Sonnet 5 | $0.00012 | $0.00265 |
| Haiku 4.5 | $0.00006 | $0.00132 |
Grade A, and why
text2sql-query-optimizer scanned grade A with 1 finding 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 7d 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.
Makes network callslowCapability
Not a fault in itself. Listed so you know the mod talks to something, and to what.
resp = requests.post(url, headers={"Authorization": f"Bearer {token}"}, params=params, json=payload) How it starts
The opening of the file, as written. The whole thing — 155 lines — stays where its author put it; the contents beside it link to each section on GitHub.
watsonx.data Intelligence Text2SQL Query Optimizer
Purpose
Expert guidance for evaluating IBM watsonx.data Intelligence Text2SQL output quality, diagnosing poor query results, tuning model parameters, and implementing feedback loops to iteratively improve accuracy.
IBM Cloud Product Coverage
| IBM Cloud Product | Usage |
|---|---|
| watsonx.data Intelligence | Text2SQL API: /semantic_automation/v1/text_to_sql |
| IBM watsonx.ai | LLM selection: ibm/granite-3-8b-instruct, meta-llama/llama-3-3-70b-instruct |
| IBM Cloud IAM | Bearer token authentication |
Rules
- Model selection:
ibm/granite-3-8b-instructfor SQL-specialist tasks;meta-llama/llama-3-3-70b-instructfor complex multi-join queries - Always validate generated SQL before execution (syntax check, table/column existence)
- Dialect must match target system:
presto,postgresql,mssql,oracle,snowflake - Set
"raw_output": falseto get structured response with explanation - Enrich metadata before changing model — metadata quality has highest impact on accuracy
Scope
- Text2SQL model selection and parameter tuning
- Generated SQL validation and safety checks
- Error pattern diagnosis and remediation
- Quality evaluation metrics (exact match, execution accuracy)
- Feedback loop implementation for iterative improvement
Procedure
Phase 1: Model Selection Guide
| Model | Strengths | Use Case |
|---|---|---|
ibm/granite-3-8b-instruct |
SQL-specialist, fast | Standard OLAP queries |
meta-llama/llama-3-3-70b-instruct |
Complex reasoning | Multi-table JOINs, sub-queries |
ibm/granite-20b-code-instruct |
Code generation | Complex aggregations |
Phase 2: Text2SQL API Request
import requests
def run_text2sql(query: str, dialect: str, model_id: str, project_id: str, token: str) -> dict:
url = f"https://api.ca-tor.dai.cloud.ibm.com/semantic_automation/v1/text_to_sql"
params = {
"container_id": project_id,
"container_type": "project",
"dialect": dialect,
"model_id": model_id,
}
payload = {"query": query, "raw_output": False}
resp = requests.post(url, headers={"Authorization": f"Bearer {token}"}, params=params, json=payload)
resp.raise_for_status()
return resp.json()
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.
- 7d ago First seen · 155 lines · 61 tokens per session scan A 9be1233dfa8d
text2sql-query-optimizer is a skill published in the GitHub repository ibm-self-serve-assets/building-blocks (24 stars, last pushed 12d ago), licensed Apache-2.0. It adds 61 tokens to every session and 1,323 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
natural-language-postgres
Chat app that lets you ask questions in plain English and query your PostgreSQL database.
embeddings
Vector embeddings with HNSW indexing, sql.js persistence, and hyperbolic support. 75x faster with agentic-flow integration. Use when: semantic search, pattern matching, similarity queries, knowledge retrieval. Skip when: exact text matching, simple lookups, no semantic understanding needed.
llm-app-patterns
Production-ready patterns for building LLM applications. Covers RAG pipelines, agent architectures, prompt IDEs, and LLMOps monitoring. Use when designing AI applications, implementing RAG, building agents, or setting up LLM observability.
prompt-optimization
Improve a prompt on the evaluations workbench through a measured loop. Score the baseline first, then duplicate the target column, form a hypothesis from failing rows, edit the copy's prompt draft, run, compare pass rate and cost, and repeat until the numbers hold. Use when the user asks to optimize or improve a…
enhance-prompt
Transforms vague UI ideas into polished, Stitch-optimized prompts. Enhances specificity, adds UI/UX keywords, injects design system context, and structures output for better generation results.
prompt-engineer
Writes, refactors, and evaluates prompts for LLMs — generating optimized prompt templates, structured output schemas, evaluation rubrics, and test suites. Use when designing prompts for new LLM applications, refactoring existing prompts for better accuracy or token efficiency, implementing chain-of-thought or few-shot…