agentleFS
velonxvelonx/agent-skills/skills/sql-analysis/SKILL.md

sql-analysis

Skill1 starsChanged 48 days agoMITView on GitHub

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.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read-only by default: Only run SELECT / WITH / EXPLAIN.

    line 29
  2. Distinctive:

    Define the metric in words: before writing SQL ("active user = at least one order in the last 30 days, excluding test accounts").

    line 32
  3. Very specific:

    Protect the database: add LIMIT while exploring.

    line 34

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SQL Analysis

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.

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.

  1. 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.
  2. 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.
  3. Write the query with CTEs named for what they hold, explicit join conditions, and explicit time zones for date logic.
  4. Protect the database: add LIMIT while exploring; check EXPLAIN before running anything that scans large tables.
  5. Sanity-check results: totals vs known numbers, no join fan-out (compare row counts before/after joins), NULL handling.
  6. 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.

Limitations

  • Needs a database connection or tool supplied by the user's environment.
  • SQL dialects differ; the agent states which dialect it wrote for.

Changelog

  • 1.0.0 — Initial release.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.