SQL Analysisv1.0.0
Explore a database schema, write safe read-only SQL to answer business questions, and explain the results and the query. Use when the user asks a question about data that lives in a SQL database, wants a query written or debugged, or needs a metric defined in SQL.
- Author
- Velonx
- License
- MIT
- Updated
- Sep 25, 2026
Overview
Answers questions from relational databases (PostgreSQL, MySQL, SQLite, BigQuery, Snowflake…) by learning the schema first and running only read-only queries, then explaining both the answer and the SQL.
When to Use
- "How many users signed up last week?", "top customers by revenue", "why is this query slow?"
- Writing or reviewing SQL, defining a metric precisely.
Installation
velonx install sql-analysisGet the skill folder
The skill isgit clone --depth 1 https://github.com/velonx/agent-skills.gitagent-skills/skills/sql-analysis/. Or open it on GitHub and download the files.Give SKILL.md to your agent as instructions
Add it to the system prompt, custom instructions or rules file your agent reads. Keep the rest of the folder next to it if the skill refers to examples or scripts.Ask for the task in your own words
The agent follows the skill when your request matches it. You can also name it: “use sql-analysis”.
Get the skill folder
The skill isgit clone --depth 1 https://github.com/velonx/agent-skills.gitagent-skills/skills/sql-analysis/. Or open it on GitHub and download the files.Claude Code: copy it into a skills folder
Usecp -R agent-skills/skills/sql-analysis ~/.claude/skills/.claude/skills/inside a project instead to share it with your team through git.Claude apps: upload it
Zip the folder and upload it under Settings → Capabilities → Skills.Ask for the task in your own words
The agent follows the skill when your request matches it. You can also name it: “use sql-analysis”.
Get the skill folder
The skill isgit clone --depth 1 https://github.com/velonx/agent-skills.gitagent-skills/skills/sql-analysis/. Or open it on GitHub and download the files.ChatGPT: add it to a GPT or project
PasteSKILL.mdinto the instructions, and upload files from the folder as knowledge if the skill uses them.API: send it as instructions
UseSKILL.mdas the system / developer message, or as agent instructions in your SDK.Ask for the task in your own words
The agent follows the skill when your request matches it. You can also name it: “use sql-analysis”.
Get the skill folder
The skill isgit clone --depth 1 https://github.com/velonx/agent-skills.gitagent-skills/skills/sql-analysis/. Or open it on GitHub and download the files.Gemini app: create a Gem
PasteSKILL.mdinto the Gem’s instructions.Gemini CLI or API
Add the contents to your project’sGEMINI.md, or pass it as thesystem_instructionin the API.Ask for the task in your own words
The agent follows the skill when your request matches it. You can also name it: “use sql-analysis”.
Get the skill folder
The skill isgit clone --depth 1 https://github.com/velonx/agent-skills.gitagent-skills/skills/sql-analysis/. Or open it on GitHub and download the files.Add it as a project rule
Create.cursor/rules/sql-analysis.mdcand paste the body ofSKILL.md. Use the skill’s description as the rule description so the agent applies it when relevant.Keep the folder in your repo
Only needed if the skill refers to examples or scripts.Ask for the task in your own words
The agent follows the skill when your request matches it. You can also name it: “use sql-analysis”.
Agents move these settings between versions — if a path doesn’t match, check your agent’s docs.
Usage
Read-only by default. Only run SELECT / WITH / EXPLAIN. Never run INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE or GRANT unless the user explicitly asks and confirms the exact statement.
- Learn the schema: list tables and columns (
information_schema), primary/foreign keys, and row counts of the tables you'll touch. Look at a few sample rows. - Define the metric in words before writing SQL ("active user = at least one order in the last 30 days, excluding test accounts"). Confirm ambiguous definitions.
- Write the query with CTEs named for what they hold, explicit join conditions, and explicit time zones for date logic.
- Protect the database: add
LIMITwhile exploring; checkEXPLAINbefore running anything that scans large tables. - Sanity-check results: totals vs known numbers, no join fan-out (compare row counts before/after joins), NULL handling.
- Report: the answer, a small result table, the final SQL, and assumptions.
Examples
Prompt: "What's our 30-day retention for users who signed up in August?"
The agent finds users(created_at) and events(user_id, occurred_at), confirms that "retained" means any event on days 25–35, writes a cohort query with CTEs, and reports the rate with the SQL.
Requirements & compatibility
Your agent needs
- A database connection
Written for
Limitations
- Needs a database connection or tool supplied by the user's environment.
- SQL dialects differ; the agent states which dialect it wrote for.
Files
Changelog
- 1.0.0 — Initial release.
Contributing
This skill lives in velonx/agent-skills. Improvements go through a pull request, reviewed by maintainers.