Agent skill · data analytics · anthropics
write-query
Write optimized SQL for your dialect with best practices. Use when translating a natural-language data need into SQL, building a multi-CTE query with joins and aggregations, optimizing a query against a large partitioned table, or getting dialect-specific syntax for Snowflake, BigQuery, Postgres, etc.
Why this skill is useful
Provides optimized SQL generation tailored to specific dialects, including performance considerations and best practices that the AI wouldn't reliably generate on its own.
What it needs
About 3k tokens when loaded. Last updated 2026-08-07. 23,345 stars on the source repository.
What this skill does
/write-query - Write Optimized SQL If you see unfamiliar placeholders or need to check which tools are connected, see CONNECTORS.md. Write a SQL query from a natural language description, optimized for your specific SQL dialect and following best practices. Usage Workflow 1. Understand the Request Parse the user's description to identify: Output columns: What fields should the result include? Filters: What conditions limit the data (time ranges, segments, statuses)? Aggregations: Are there GROUP BY operations, counts, sums, averages? Joins: Does this require combining multiple tables? Ordering: How should results be sorted? Limits: Is there a top-N or sample requirement? 2. Determine SQL Dialect If the user's SQL dialect is not already known, ask which they use: PostgreSQL (including Aurora, RDS, Supabase, Neon) Snowflake BigQuery (Google Cloud) Redshift (Amazon) Databricks SQL MySQL (including Aurora MySQL, PlanetScale) SQL Server (Microsoft) DuckDB SQLite Other (ask for specifics) Remember the dialect for future queries in the same session. 3. Discover Schema (If Warehouse Connected) If a data warehouse MCP server is connected: 1. Search for relevant tables based on the user's description 2. Inspect column names, types, and relationships 3. Check for partitioning or clustering keys that affect performance 4. Look for pre-built views or materialized views that might simplify the query 4. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills anthropics/write-query