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.

skills.sh installs
3.1K
GitHub stars
35.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add anthropics/knowledge-work-plugins --skill write-query --agent claude-code

Installs into .claude/skills of the current project.

Files

/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

/write-query <description of what data you need>

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:

Sponsors

Details

Repository
github.com/anthropics/knowledge-work-plugins
Category
Databases
First seen
Apr 16, 2026

More from anthropics/knowledge-work-plugins

All 198

Recommended

More Databases
1oracle avatardboracle/skillsOracle Database guidance for SQL, PL/SQL, SQLcl, ORDS, administration, app development, performance, security, migrations, and agent-safe database workflows. Us3.1Kskills.sh installs
2semgrep avatarcode-securitysemgrep/skillsSecurity guidelines for writing secure code. Use when writing code, reviewing code for vulnerabilities, or asking about secure coding practices like 'check for 2.8Kskills.sh installs
3davila7 avatarsenior-backenddavila7/claude-code-templatesComprehensive backend development skill for building scalable backend systems using NodeJS, Express, Go, Python, Postgres, GraphQL, REST APIs. Includes API scaf2.7Kskills.sh installs
4runablehq avatarmemrunablehq/memoryStore and retrieve memories (notes, facts, decisions, snippets, images) using a local SQLite database with full-text search. Use when you need to remember infor2.4Kskills.sh installs
5mrgoonie avatarbackend-developmentmrgoonie/claudekit-skillsBuild robust backend systems with modern technologies (Node.js, Python, Go, Rust), frameworks (NestJS, FastAPI, Django), databases (PostgreSQL, MongoDB, Redis),2.3Kskills.sh installs
6bmad-labs avatartypescript-e2e-testingbmad-labs/skillsE2E and integration testing for TypeScript/NestJS projects using Jest, supertest, and real infrastructure via Docker (Kafka, PostgreSQL, MongoDB, Redis) with th2.3Kskills.sh installs