agentleFS
PradnyeshpPradnyeshp/Claude-Skills/.claude/skills/sql/SKILL.md

sql

Skill2 starsChanged 4 months agoMITView on GitHub

Write, explain, or optimize a SQL query from a plain-English description or an existing query, with attention to correctness, indexes, and dialect. Use when the user says "write a SQL query for", "explain this query", "why is this query slow", "optimize this SQL", "convert this to SQL", or pastes a query and asks what it does.

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use react, terraform and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 6 projects that use this

  • ihiteshguptaSkill

    terraform

    Expert in Infrastructure as Code with Terraform. Use for creating, managing, and versioning infrastructure across cloud providers.

    Also in 3 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Look at any schema/migration files above for real table and column names.

    line 20
  2. Distinctive:

    Prefer set-based logic over correlated subqueries where it's clearer and faster.

    line 25
  3. Distinctive:

    Never guess at table/column names silently — verify against the schema or state the assumption.

    line 41
  4. Very specific:

    Don't suggest destructive statements (DELETE/UPDATE/DROP) unless explicitly asked.

    line 42

“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “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

Schema hints (if the project defines one)

!find . -type d \( -name node_modules -o -name .git -o -name dist -o -name build -o -name vendor \) -prune -o -type f \( -iname '*.sql' -o -iname 'schema.*' -o -iname '*migration*' -o -iname 'models.py' \) -print 2>/dev/null | head -20

Instructions

Handle the SQL request in $ARGUMENTS. The request is one of: write a query from a description, explain a given query, or optimize a slow query. If none is given, ask which.

Determine the dialect and schema first

  • Infer the database (PostgreSQL, MySQL, SQLite, SQL Server, BigQuery, …) from migrations, ORM config, or connection strings in the repo. If it can't be determined, ask — dialects differ on quoting, limits, date functions, and window-function support.
  • Look at any schema/migration files above for real table and column names. Don't invent columns; if the schema is unknown, state your assumptions explicitly.

Writing a query

  1. Produce a correct, readable query: uppercase keywords, meaningful aliases, explicit JOIN ... ON, and LIMIT where a sample is implied.
  2. Prefer set-based logic over correlated subqueries where it's clearer and faster. Use CTEs to make multi-step logic legible.
  3. Handle the tricky cases the request implies: NULLs, duplicates (DISTINCT vs GROUP BY), timezones, and inclusive/exclusive date ranges. Call out the assumption.
  4. Briefly explain what the query returns and any assumption made about the schema.

Explaining a query

Walk through it from the innermost subquery/CTE outward: what each join, filter, grouping, and window does, and what the final result set represents. Flag anything surprising (implicit cross joins, fan-out from one-to-many joins, NULL semantics).

Optimizing a query

  1. Identify the likely cost: missing index, full scan, fan-out join, SELECT *, function on an indexed column, OR defeating an index, or N+1 from the app side.
  2. Suggest concrete fixes (the index to add, the rewrite, the predicate pushdown) and show the improved query.
  3. Recommend running EXPLAIN/EXPLAIN ANALYZE to confirm, and show the exact command for the detected dialect.

Rules

  1. Never guess at table/column names silently — verify against the schema or state the assumption.
  2. Don't suggest destructive statements (DELETE/UPDATE/DROP) unless explicitly asked; if you do, wrap with a SELECT to preview affected rows and a transaction.
  3. Note dialect-specific syntax when it matters so the query isn't silently non-portable.

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.