agentleFS
atsushi-greenatsushi-green/ds-ai-coding-skills/.claude/skills/sql-analysis/SKILL.md

sql-analysis

Skill86 starsChanged 50 days agoMITView on GitHub

Use this when writing, reviewing, or modifying SQL queries — including SELECT, CTEs, joins, aggregations, window functions, and validating query correctness or performance.

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

10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    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. Distinctive:

    Use this skill when writing, reviewing, or modifying SQL queries.

    line 8
  2. Very specific:

    Use explicit column names — avoid SELECT * except for quick exploration.

    line 12
  3. Distinctive:

    Use CTEs (Common Table Expressions) for readability and modularity.

    line 13
  4. Distinctive:

    Add date filters for large fact tables to limit scan scope.

    line 14
  5. Distinctive:

    Check join keys and join cardinality before writing joins.

    line 15
  6. Distinctive:

    Validate row counts: before and after joins to detect fanout or data loss.

    line 16
  7. Distinctive:

    Avoid implicit cross joins.

    line 17
  8. Very specific:

    Never: run DROP, TRUNCATE, DELETE, or UPDATE unless explicitly requested by the user.

    line 18
  9. Distinctive:

    If destructive SQL is requested, propose a dry-run, backup, or transaction strategy first.

    line 19
  10. Distinctive:

    Before finalizing a query, verify:

    line 50

≈ “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

Skill: SQL Analysis

Use this skill when writing, reviewing, or modifying SQL queries.

Rules

  • Use explicit column names — avoid SELECT * except for quick exploration.
  • Use CTEs (Common Table Expressions) for readability and modularity.
  • Add date filters for large fact tables to limit scan scope.
  • Check join keys and join cardinality before writing joins.
  • Validate row counts before and after joins to detect fanout or data loss.
  • Avoid implicit cross joins.
  • Never run DROP, TRUNCATE, DELETE, or UPDATE unless explicitly requested by the user.
  • If destructive SQL is requested, propose a dry-run, backup, or transaction strategy first.

Query Structure

WITH base AS (
    SELECT
        column_a,
        column_b,
        event_date
    FROM schema.table_name
    WHERE event_date BETWEEN '2024-01-01' AND '2024-01-31'
),
aggregated AS (
    SELECT
        column_a,
        COUNT(*) AS row_count,
        SUM(column_b) AS total_b
    FROM base
    GROUP BY column_a
)
SELECT
    column_a,
    row_count,
    total_b
FROM aggregated
ORDER BY row_count DESC;

Review Checklist

Before finalizing a query, verify:

  • Are grains (unit of analysis per row) clear?
  • Are date ranges explicit and appropriate?
  • Are NULLs handled (filtered, coalesced, or documented)?
  • Are duplicates considered (distinct, dedup logic)?
  • Is join cardinality validated (1:1, 1:N, M:N)?
  • Are business definitions documented in comments or CTEs?
  • Are row counts checked before and after key transformations?
  • Is there any risk of implicit cross join?
  • Are destructive operations absent or explicitly approved?

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.