sql-generator

A helper that turns plain-language requests into SQL statements for MySQL, Doris, ClickHouse, and PostgreSQL databases. It can inspect available databases, tables, and columns before writing the query.

In plain words
What is it for?
Use it to create queries for filtering, sorting, counting, grouping, or combining data. It is also useful when you need to check the database structure before writing a query.
Why use it?
It reduces the need to remember SQL syntax and prevents queries from using the wrong table or column. You can describe the data you need in everyday language.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/ccfos/nightingale/sql-generator
Any agent
npx skills add ccfos/nightingale --skill sql-generator
Clone the repo
git clone --depth 1 https://github.com/ccfos/nightingale

Made for: Claude Code, Codex.

Per session 23 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,013 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00023 $0.01013
Opus 5 $0.00012 $0.00507
Sonnet 5 $0.00005 $0.00203
Haiku 4.5 $0.00002 $0.00101

Measured 2d ago against content hash 0d8ce8b2aad6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sql-generator 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 2d 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.

aiagent/skill/embedded/builtin/sql-generator/SKILL.md · 132 lines

How it starts

The opening of the file, as written. The whole thing — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SQL Generation Expert

You are a SQL expert who generates correct SQL query statements based on the user's natural language description. Supports databases such as MySQL, Doris, ClickHouse, and PostgreSQL.

Workflow

  1. Understand the user's intent: Analyze what data the user wants to query, under what conditions, and in what order.
  2. Explore the database structure: Use list_databases to view the available databases.
  3. View the table list: Use list_tables to view the tables in a database.
  4. Understand the table structure: Use describe_table to get the column information of a table.
  5. Build the SQL: Build an accurate SQL query based on the table structure.

Available Tools

list_databases

List all databases in the data source.

  • No parameters

list_tables

List all tables in the specified database.

  • database: database name (required)

describe_table

Get the column structure of a table (column name, type, comment).

  • database: database name (required)
  • table: table name (required)

SQL Syntax Essentials

Basic Query

SELECT column1, column2 FROM database.table WHERE condition;

Aggregate Functions

  • COUNT(*), COUNT(DISTINCT column)
  • SUM(column), AVG(column)
  • MAX(column), MIN(column)

Grouping and Sorting

SELECT column, COUNT(*) as cnt
FROM table
GROUP BY column
HAVING cnt > 10
ORDER BY cnt DESC
LIMIT 100;

Time Handling

  • MySQL: DATE(column), DATE_SUB(NOW(), INTERVAL 7 DAY)
  • ClickHouse: toDate(column), now() - INTERVAL 7 DAY
  • Doris: DATE(column), DATE_SUB(NOW(), INTERVAL 7 DAY)

Join Query

SELECT a.*, b.name
FROM table_a a
LEFT JOIN table_b b ON a.id = b.a_id;

Differences Between Databases

MySQL

  • String concatenation: CONCAT(a, b)
  • Pagination: LIMIT offset, count or LIMIT count OFFSET offset

ClickHouse

  • String concatenation: concat(a, b)
  • Pagination: LIMIT count OFFSET offset
  • Approximate deduplication: uniqExact(column)
  • Time functions: toStartOfHour(), toStartOfDay()

Read the full file on GitHub · 132 lines

Changes

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.

  1. 2d ago First seen · 132 lines · 23 tokens per session scan A 0d8ce8b2aad6

Subscribe to this mod's changes

sql-generator is a skill published in the GitHub repository ccfos/nightingale (13,271 stars, last pushed today), licensed Apache-2.0. It adds 23 tokens to every session and 1,013 once invoked, about $0.0001 per session on Opus 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.