sql-analysis
What it does
This skill turns a business question into a checked SQL query and a small result table. It is for analysts and managers who need numbers from a database without writing the query themselves.
When to use it
- βWhen you ask how many, what the trend is, or what the top items are in a database.
- βWhen you want to compare two groups or two time periods using the data.
- βWhen you need a result table along with the query that produced it.
Skill link
https://github.com/agentscope-ai/agentscope-java/blob/main/agentscope-examples/agents/agentscope-dataagent/src/main/resources/shared/agents/data-agent/skills/sql-analysis/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow many new customers did we get each month last year, by region? Show me the query and the table.β
5 new skills a week. 1 minute to read.
How it works
The skill restates the question as a metric with a grouping, a time window and a filter. It drafts the SQL, runs it, checks that the row count and results make sense, and then reports the table with the query.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
SQL Analysis Skill
Repeatable SOP for turning a business question into a verifiable SQL answer.
Steps
Restate the question as a metric. In one sentence, write: "<metric> by <grouping> over <time window>, filtered by <filter>". If any of those four (metric / grouping / window / filter) is missing or ambiguous, ask one clarifying question and stop. Do not guess.
Locate the source. Decide where the data lives:
- Look in
knowledge/first for any schema notes, data-dictionary entries, or prior query examples uploaded by the user. - If the right table is not obvious, delegate to the
data-explorersub-agent with the metric definition as the prompt β its job is to identify the canonical source.
- Look in
Draft the query. Write the SQL in a fenced
sqlblock. Conventions:- Always include the time window in a
WHEREclause β never query the full history "just in case". - Always
SELECTan explicit column list β neverSELECT *in an answer. - Use CTEs (
WITH x AS (...)) over nested subqueries for anything beyond two levels of nesting. - Comment any non-obvious filter (
-- excludes internal test accounts).
- Always include the time window in a
Validate before reporting. Run the query and check:
- Row count is in the ballpark you expected (1 row, 10 rows, ~30 daily buckets, etc.). A surprising row count is almost always a bug β investigate.
- No
NULLs in the grouping column unless that is the intended cohort. - At least one numeric sanity check: a known total, a known reference value, or a min/max range that matches reality.
- If anything looks off, do not report the number β fix the query first.
Write the report. Use this exact structure:
## Answer <one-sentence direct answer with the headline number(s)> ## Result <small markdown table β at most ~15 rows; for longer results, summarise and offer to render a chart or attach the full CSV> ## Query ```sql <the exact query you ran>Sources & validation
- Table(s):
schema.table_name(row count, freshness if known) - Validation: <which sanity checks you ran and the result>
- Caveats: <known data quality issues, missing dates, etc.>
- Table(s):
Anti-patterns
- β Reporting a number without the query that produced it.
- β Using
LIMIT Nto "make the output fit" without explaining what got cut. - β Reading a single row and reporting it as a trend.
- β Inventing a table or column name. If unsure, delegate to
data-explorer.
When to delegate
- The user's question requires probing several candidate tables / sources
before any query can be written β spawn
data-explorer. - The user wants a polished written deliverable summarising several analyses
(e.g. "weekly health report") β spawn
report-writerafter you have the underlying numbers ready.
FAQ
Does it guess missing details?
No, if the metric, grouping, time window or filter is unclear, the skill asks one clarifying question.
Will it show the query?
Yes, it presents the SQL along with the result table.
Does it check the answer?
Yes, it checks that the number of rows and values look reasonable before reporting.
Details
Original description by the author
Answer a quantitative business question by writing a SQL query against the data warehouse, validating it, and presenting the result. Use when the user asks "how many...", "what's the trend of...", "compare X vs Y over...", "what's our top N...", or anything that resolves to a query against tabular data. Produces a small result table plus the underlying query.
Popularity
- GitHub stars
- 6.2k
- Ranking position
- #14391
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
agentscope-java
6.2kHelps your agent write non-blocking Java code for AgentScope, a multi-agent framework built on Project Reactor.
data-report
6.2kHelps your agent summarize a dataset into a report with averages, totals, ranges and trends, saved as a Markdown file.
data-transform
6.2kHelps your agent convert a data file between formats such as CSV and JSON, so the data can be used in other tools.
git-changelog
6.2kHelps your agent write a changelog or release notes from a Git history, grouped into features, fixes and other changes.
Similar skills
discrawl
394kLets your agent search and summarize a saved local archive of Discord messages, check how fresh it is, and read direct messages.
clickhouse-io
280kHelps your agent optimize queries and schemas in ClickHouse databases. It applies best practices for high-performance analytical workloads. Use when analytical queries are too slow.
scientific-db-pubmed-database
280kHelps your agent search for scientific articles in the biomedical field. It's useful for research needing specific medical information.