nl-sql-query
Skill1 starsChanged 56 days agoApache-2.0View on GitHub
Use when a user asks a data question in natural language and wants the SQL built, executed (read-only), and results shown — for PostgreSQL/MySQL/MS-SQL via the nl-sql MCP. Explore the schema with tools, then author and run a dialect-appropriate SELECT and present the results.
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
When the target DB is one of PostgreSQL / MySQL / MS-SQL and the nl-sql MCP is connected.
- Very specific: line 31
If the MCP is absent or unconfigured, stop and point to the install guide (mcp/nl-sql/README.md).
- Very specific: line 36
Use search_objects(keyword) to find candidate tables·columns from NL terms ("order", "member", "post").
- Very specific: line 38
If a join is needed, confirm both tables' FKs with describe_table.
- Very specific: line 39
Author a dialect-appropriate SELECT: write identifier quoting·row limiting (LIMIT vs TOP/OFFSET..FETCH)·placeholders·pagination per the …
- Very specific: line 41
Execute: run a single SELECT/WITH with run_select(sql, params).
- Very specific: line 43
Handle empty results·errors: if the result is 0 rows or a "no such column / ambiguous" error occurs, don't fix it by guessing — re-confirm …
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
nl-sql-query — natural language → SQL query workflow
A repeatable workflow that takes the user's natural-language data question, explores the
DB schema with tools, authors and runs a read-only SELECT matched to the target dialect,
and then presents the results as a table. DB access is handled by the companion MCP server
nl-sql. This skill is a guide for how to drive that MCP, and does not reimplement DB
connection or query execution.
Authority: the truth of the physical schema is the live DB, and
describe_table/search_objectsare the single source for it. Do not guess the schema — confirm it with tools before authoring. Dialect rules are inreference/kb/dialect-differences.md; the deeper rationale is inreference/principles.md·reference/kb/.
Invocation triggers
- Natural-language data questions such as "show me the counts by order status", "how many members signed up last month?", "the 10 posts with the most comments".
- "Build this question into SQL, run it, and show me the results."
- When the target DB is one of PostgreSQL / MySQL / MS-SQL and the
nl-sqlMCP is connected.
Prerequisite: the nl-sql MCP must be installed and configured
- The
nl-sqlMCP connects to a single DB, configured with onedialect∈ {postgres, mysql, mssql} plus connection info (read-only). - Exposed tools:
list_schemas,list_tables(schema),describe_table(schema, table → columns/types/NULL/defaults/PK/FK),search_objects(keyword → matching tables·columns),run_select(sql, params[] → runs a single read-only SELECT/WITH, automatic row cap, returns a markdown table),explain_select(sql → plan only; not supported on MS-SQL — SQL Server has no EXPLAIN, so it is rejected). - The active dialect is reported by the server in the
run_selectdescription. Placeholder syntax differs by dialect (postgres$1,$2/ mysql?/ mssql@p1,@p2). - If the MCP is absent or unconfigured, stop and point to the install guide (
mcp/nl-sql/README.md). Do not fabricate schema or results without the tools.
WORKFLOW — step-by-step procedure
- Confirm the target dialect/DB: confirm the active dialect (postgres/mysql/mssql) from the
run_selectdescription or with the user. If you don't know the dialect, you're blocked at step 1 (wrong-dialect syntax fails immediately). - Explore the schema: map natural-language terms to the schema.
- Use
search_objects(keyword)to find candidate tables·columns from NL terms ("order", "member", "post"). - Narrow the scope with
list_tables(schema), and pin down the exact column names·types·NULL·PK/FK withdescribe_table(schema, table). - If a join is needed, confirm both tables' FKs with
describe_table. (Procedure detail: KBnl-to-sql-workflow)
- Use
- Author a dialect-appropriate SELECT: write identifier quoting·row limiting (
LIMITvsTOP/OFFSET..FETCH)·placeholders·pagination per the dialect rules (KBdialect-differences). Do not produce wrong-dialect syntax. - Bind values as parameters: literal values (search terms·dates·IDs, etc.) must not be embedded by string concatenation into the SQL — bind them via
params[]. Placeholders follow the active dialect's syntax ($1/?/@p1). - Execute: run a single SELECT/WITH with
run_select(sql, params). If a heavy query is suspected, you can first check the plan withexplain_select(sql)(skip it on MS-SQL, which is unsupported). - Present the results: present the result table + the SQL used (code block) + a row count/truncation indicator + a caution about estimates·assumptions (KB
result-presentation). - Handle empty results·errors: if the result is 0 rows or a "no such column / ambiguous" error occurs, don't fix it by guessing — re-confirm the column names with
describe_tableand re-author. If the question is ambiguous, don't assume; ask 1–2 clarifying questions.
Safety — read-only invariant
- This skill and the
nl-sqlMCP are read-only.run_selectallows only SELECT/WITH and rejects writes·DDL·multi-statements. - If the user requests INSERT/UPDATE/DELETE/DDL → author the SQL and show it, but do not execute it. Warn about the change's impact, advise that "this skill·MCP does not execute it, so review it with a separate tool/permission and run it yourself", and then require user confirmation.
Key dialect differences (summary — details in the KB)
| Item | PostgreSQL | MySQL | MS-SQL |
| Identifier quoting | "col" | `col` | [col] |
| Row limiting | LIMIT n | LIMIT n | TOP (n) or OFFSET m ROWS FETCH NEXT n ROWS ONLY |
| Pagination | LIMIT n OFFSET m | LIMIT m, n / LIMIT n OFFSET m | ORDER BY ... OFFSET m ROWS FETCH NEXT n ROWS ONLY |
| Placeholders | $1, $2 | ? | @p1, @p2 |
| String concatenation | a || b | CONCAT(a, b) | a + b or CONCAT(a, b) |
| Current time | now() / CURRENT_TIMESTAMP | NOW() / CURRENT_TIMESTAMP | SYSDATETIME() / GETDATE() |
TOPcannot be used together with OFFSET (MS-SQL pagination isOFFSET..FETCH). Details·date functions·booleans·identifier folding are indialect-differences.md.
Example (PostgreSQL — generic entity)
Question: "show me the order counts by status, most first"
SELECT status, COUNT(*) AS cnt
FROM "order"
GROUP BY status
ORDER BY cnt DESC
LIMIT 50;Question: "find members whose email contains a given string" — bind the value via params:
-- params: ['%@example.com']
SELECT member_id, email, created_at
FROM member
WHERE email LIKE $1
ORDER BY created_at DESC
LIMIT 100;Verify
- Authored after actually confirming column names·types·PK/FK with
describe_table(no guessing). - Followed the active dialect's syntax exactly (quoting·row limiting·placeholders·pagination).
- Bound every literal value via
params[](no value injection by string concatenation). - Ran only read-only SELECT/WITH with
run_select. Writes·DDL were authored only, not executed. - Presented the results together with the SQL used and a row count/truncation·estimate caution.
- On empty results·column misidentification, re-confirmed with
describe_tableand re-authored; on ambiguity, asked clarifying questions.
Related
[[schema-doc-extract]] · postgres-dba · nl-sql MCP(mcp/nl-sql/)
In this repository65 other files it gives its agents.
- agent-evalSkill
- architecture-review-workflowSkill
- backend-code-review-workflowSkill
- code-authoring-routerSkill
- code-diagram-extractSkill
- codex-agent-runtimeSkill
- design-pattern-applySkill
- diagram-stylerSkill
- document-designerSkill
- e2e-evidence-reportSkill
- e2e-report-rendererSkill
- e2e-runnerSkill
- e2e-scenario-authorSkill
- e2e-test-workflowSkill
- entitySkill
- enumSkill
- explore-dead-codeSkill
- flywaySkill
- git-flowSkill
- harness-proposeSkill
- harness-refineSkill
- java-spring-review-workflowSkill
- knowledge-auditSkill
- korean-dev-writerSkill
- kotlin-code-authoringSkill
- kotlin-spring-reviewSkill
- kotlin-spring-review-workflowSkill
- learnSkill
- mapperSkill
- markdown-publisherSkill
- mermaid-diagramsSkill
- mssql-code-authoringSkill
- notion-domain-contextSkill
- oop-design-reviewSkill
- opensearch-code-authoringSkill
- opensearch-optimizationSkill
- opensearch-query-reviewSkill
- opensearch-review-workflowSkill
- opensearch-schema-reviewSkill
- pdf-qaSkill
- playwright-e2eSkill
- postgres-code-authoringSkill
- postgres-query-reviewSkill
- postgres-review-workflowSkill
- postgres-risk-checkSkill
- postgres-schema-designSkill
- product-requirementsSkill
- product-ui-designSkill
- refactoring-catalogSkill
- repositorySkill
- requestSkill
- responseSkill
- retroSkill
- schema-doc-extractSkill
- security-scan-workflowSkill
- serviceSkill
- skill-updaterSkill
- start-taskSkill
- test-authoringSkill
- test-quality-refactoring-workflowSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

