Transforms natural language requests into executable SQL queries based on your database schema.

Install

mkdir -p .claude/skills/query-builder && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2660" && unzip -o skill.zip -d .claude/skills/query-builder && rm skill.zip

Installs to .claude/skills/query-builder

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Convert natural language questions into SQL queries. Activates when users ask data questions in plain English like "show me users who signed up last week" or "find orders over $100".
182 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Queries database schemas to map entities
  • Translates natural language intent to SQL
  • Identifies join conditions and aggregation logic
  • Handles filters for dates, ranges, and patterns
  • Executes SQL queries via helper functions

How it works

It analyzes the database schema through helper functions, maps intent to tables/columns, and constructs a syntactically correct SQL statement.

Inputs & outputs

You give it
Natural language business question
You get back
Executable SQL query string

When to use query-builder

  • Quickly querying user data
  • Finding specific order records
  • Generating reports from raw database tables
  • Checking inventory levels via natural language

About this skill

Query Builder

Convert natural language questions into SQL queries using the database schema.

When to Use

Activate when user asks questions like:

  • "Show me all users who signed up last month"
  • "Find orders greater than $100"
  • "Which products have low inventory?"
  • "Get the top 10 customers by total spend"

Workflow

1. Understand the Schema

Before generating SQL, always check the table structure:

whodb_tables(connection="...") → Get available tables
whodb_columns(table="relevant_table") → Get column names and types

2. Identify Intent

Parse the natural language request:

  • Subject: What entity? (users, orders, products)
  • Filter: What conditions? (last month, > $100, active)
  • Aggregation: Count, sum, average, max, min?
  • Grouping: By what dimension?
  • Ordering: Sort by what? Ascending/descending?
  • Limit: How many results?

3. Map to Schema

  • Match entities to table names
  • Match attributes to column names
  • Identify foreign key joins needed

4. Generate SQL

Build the query following SQL best practices:

SELECT columns
FROM table
[JOIN other_table ON condition]
WHERE filters
[GROUP BY columns]
[HAVING aggregate_condition]
ORDER BY column [ASC|DESC]
LIMIT n;

5. Execute and Present

whodb_query(query="generated SQL")

Translation Patterns

Natural LanguageSQL Pattern
"last week/month/year"WHERE date_col >= DATE_SUB(NOW(), INTERVAL 1 WEEK)
"more than X" / "greater than X"WHERE col > X
"top N"ORDER BY col DESC LIMIT N
"how many"SELECT COUNT(*)
"total" / "sum of"SELECT SUM(col)
"average"SELECT AVG(col)
"for each" / "by"GROUP BY col
"between X and Y"WHERE col BETWEEN X AND Y
"contains" / "like"WHERE col LIKE '%term%'
"starts with"WHERE col LIKE 'term%'
"is empty" / "is null"WHERE col IS NULL
"is not empty"WHERE col IS NOT NULL

Date Handling by Database

PostgreSQL

WHERE created_at >= NOW() - INTERVAL '7 days'
WHERE created_at >= DATE_TRUNC('month', CURRENT_DATE)

MySQL

WHERE created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
WHERE created_at >= DATE_FORMAT(NOW(), '%Y-%m-01')

SQLite

WHERE created_at >= DATE('now', '-7 days')
WHERE created_at >= DATE('now', 'start of month')

Examples

"Show me users who signed up this month"

SELECT * FROM users
WHERE created_at >= DATE_TRUNC('month', CURRENT_DATE)
ORDER BY created_at DESC;

"Find the top 5 products by sales"

SELECT p.name, SUM(oi.quantity) as total_sold
FROM products p
JOIN order_items oi ON p.id = oi.product_id
GROUP BY p.id, p.name
ORDER BY total_sold DESC
LIMIT 5;

"How many orders per customer?"

SELECT customer_id, COUNT(*) as order_count
FROM orders
GROUP BY customer_id
ORDER BY order_count DESC;

Safety Rules

  • Always use LIMIT for exploratory queries (default: 100)
  • Never generate DELETE, UPDATE, or DROP unless explicitly requested
  • Warn if query might return large result sets
  • Use table aliases for readability in JOINs

When not to use it

  • For complex queries involving deeply nested logic
  • When the database schema is not well-defined or lacks documentation

Prerequisites

Active database connectionSchema access

Limitations

  • Limited by the accuracy of schema understanding
  • Does not replace complex data analysis/BI tools
  • Sensitive to ambiguous natural language queries

How it compares

It automates the schema-to-query translation process, removing the need for manual SQL composition.

Compared to similar skills

query-builder side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
query-builder (this skill)47moNo flagsIntermediate
sql-queries185moNo flagsIntermediate
senior-data-engineer217moReviewAdvanced
powerbi-modeling116moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

sql-queries

anthropics

Write correct, performant SQL across all major data warehouse dialects (Snowflake, BigQuery, Databricks, PostgreSQL, etc.). Use when writing queries, optimizing slow SQL, translating between dialects, or building complex analytical queries with CTEs, window functions, or aggregations.

1888

senior-data-engineer

davila7

World-class data engineering skill for building scalable data pipelines, ETL/ELT systems, and data infrastructure. Expertise in Python, SQL, Spark, Airflow, dbt, Kafka, and modern data stack. Includes data modeling, pipeline orchestration, data quality, and DataOps. Use when designing data architectures, building data pipelines, optimizing data workflows, or implementing data governance.

2179

powerbi-modeling

github

Power BI semantic modeling assistant for building optimized data models. Use when working with Power BI semantic models, creating measures, designing star schemas, configuring relationships, implementing RLS, or optimizing model performance. Triggers on queries about DAX calculations, table relationships, dimension/fact table design, naming conventions, model documentation, cardinality, cross-filter direction, calculation groups, and data model best practices. Always connects to the active model first using power-bi-modeling MCP tools to understand the data structure before providing guidance.

1161

data-quality-frameworks

wshobson

Implement data quality validation with Great Expectations, dbt tests, and data contracts. Use when building data quality pipelines, implementing validation rules, or establishing data contracts.

628

fuzzy-matching

dadbodgeoff

Multi-stage fuzzy matching pipeline for entity reconciliation. PostgreSQL trigram pre-filter, salient overlap check, and multi-factor similarity scoring.

825

query-writing

langchain-ai

For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations

723

Search skills

Search the agent skills registry