2k
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill apconw/aix-db --skill query-writing- SKILL.md1.7 KB
Overview
This skill helps write and execute SQL queries, from simple single-table lookups to complex multi-table JOINs and aggregations. It guides planning, schema inspection, query construction, execution, and result formatting to turn natural-language data questions into accurate SQL results. The skill is optimized for safe, read-only analysis and clear output.
How this skill works
The skill inspects database schemas to locate relevant tables and columns, then constructs targeted SELECT queries using aliases, WHERE, GROUP BY, ORDER BY, and LIMIT. For multi-table problems it uses a task breakdown to identify joins, foreign keys, and required aggregations, validates JOIN and GROUP BY correctness, and executes the read-only query. Results are formatted into concise tables or summaries for consumption.
When to use it
- Answering a data question that requires fetching or aggregating records from a database.
- Exploring table schemas and relationships before building multi-table JOINs.
- Generating repeatable, safe read-only queries for dashboards or reports.
- Validating hypotheses with aggregated metrics like sums, counts, or averages.
- Extracting a subset of rows for inspection using WHERE and LIMIT.
Best practices
- Inspect schema first: determine which table and columns contain needed data.
- Query only relevant columns; avoid SELECT * to reduce cost and ambiguity.
- Use table aliases to keep JOINs and SELECT lists readable.
- Always apply a LIMIT by default (recommended 5–10) to prevent huge results.
- Break complex tasks into steps (identify tables, map keys, plan JOINs, choose aggregations).
- Never run DML (INSERT/UPDATE/DELETE/DROP); this skill is read-only.
Example use cases
- Compute top 5 countries by total revenue using Invoice and Customer with an INNER JOIN.
- Count active users per region by joining Users and Accounts and applying GROUP BY.
- Filter transactions in a date range, aggregate totals, then order by value and limit results.
- Inspect a table schema to determine which fields are suitable for joining and aggregation.
- Build a multi-step query plan: identify tables, map foreign keys, then produce the final SELECT.
FAQ
No. The skill is designed for read-only queries and explicitly avoids DML statements.
What default LIMIT should I use?
Use a conservative default like 5–10 rows to avoid large result sets; adjust as needed.
How do you handle complex multi-table queries?
Decompose the task into steps: identify tables, inspect schemas, map join keys, plan aggregations, then build and validate the final query.