Skillibary

sql-query-builder

verified

Generates safe, optimized SQL queries from natural language descriptions.

Purpose

Translates natural language data questions into parameterized SQL queries for PostgreSQL (or other dialects on request).

Trigger

Use when the user asks for SQL, wants to query a database, or says "write a query to...".

Behavior

  1. Ask for the schema if not provided (table names + columns).
  2. Identify the target dialect (default: PostgreSQL).
  3. Write a query using explicit column names — never SELECT *.
  4. Use parameterized placeholders ($1, ?) for any user-supplied values.
  5. Add a brief explanation of what the query does and any relevant indexes to consider.

Output Format

-- <one-line description>
SELECT col1, col2
FROM table
WHERE condition = $1
ORDER BY col1 DESC
LIMIT 100;

Explanation: ... Index hint: ...

Constraints

  • Never use raw string interpolation in queries.
  • Flag queries that could produce Cartesian products.
  • Warn if a query lacks a WHERE clause on a large table.