
Turns natural language data questions into production-ready SQL with proper CTEs, dialect-specific optimizations, and performance considerations baked in. It asks which SQL flavor you're using (Snowflake, BigQuery, Postgres, etc.) then structures queries with early filtering, appropriate joins, and partition awareness. The workflow is practical: it parses your request, discovers schema if you have a warehouse connected, writes the query with meaningful CTE names and comments, then explains each section and how to modify it. The best part is it actively avoids the usual mistakes like SELECT *, correlated subqueries where joins would work, and exploding many-to-many joins. Good for both quick aggregations and complex cohort analyses where you need someone who remembers the performance gotchas.
$ npx -y skills add anthropics/knowledge-work-plugins --skill write-query --agent claude-codeInstalls into .claude/skills of the current project.
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.
/write-query <description of what data you need>
Parse the user's description to identify:
If the user's SQL dialect is not already known, ask which they use:
Remember the dialect for future queries in the same session.
If a data warehouse MCP server is connected:
Follow these best practices:
Structure:
daily_signups, active_users, revenue_by_product)Performance:
SELECT * in production queries -- specify only needed columnsEXISTS over IN for subqueries with large result setsReadability:
a, b, c)Dialect-specific optimizations:
sql-queries skill for details)Provide:
If a data warehouse is connected, offer to run the query and analyze the results. If the user wants to run it themselves, the query is ready to copy-paste.
Simple aggregation:
/write-query Count of orders by status for the last 30 days
Complex analysis:
/write-query Cohort retention analysis -- group users by their signup month, then show what percentage are still active (had at least one event) at 1, 3, 6, and 12 months after signup
Performance-critical:
/write-query We have a 500M row events table partitioned by date. Find the top 100 users by event count in the last 7 days with their most recent event type.
Sponsors