Claude Marketplaces
SkillsMCP serversMarketplacesDigestTools
Submit

This week in Claude

Every Monday: Claude Code, Agent SDK, MCP, and the Anthropic platform moves worth your time.

Skills by category
Frontend DevelopmentBackend & APIsTesting & QASecurityDevOps & CI/CDGit & Pull RequestsDocumentationCode Review & QualityAI & Agent BuildingSkill Development
MCP servers by category
Sales & MarketingWeb & Browser AutomationDatabasesAI & LLM ToolsCloud & InfrastructureCommunication & MessagingDeveloper ToolsDesign & CreativeDocuments & KnowledgeSearch & Web Crawling
Marketplaces by category
AI Agents & OrchestrationLLM IntegrationDevelopment ToolsFrontend & UIBackend & APIsDatabasesTesting & Code QualityDevOps & CloudSecurity & ComplianceGit & Version Control
Claude Marketplaces

An independent directory of skills, plugins and MCP servers for Claude Code. Not affiliated with Anthropic.

Browse

  • Skills
  • MCP servers
  • Marketplaces
  • Weekly digest
  • Skill index
  • MCP index
  • Marketplace index

Site

  • About
  • Tools
  • Submit
  • Feedback
  • Privacy
  • llms.txt
  • Plugins reference

Maker

  • Snug
  • Agent Caffeine
  • knobs
  • Wax
  • Vectoys
  • mertduzgun.com
Crafted at
Skills/Databases
anthropics avatar

Write Query

anthropics/knowledge-work-pluginsOfficial

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.

installs
3K
GitHub stars
33.3K
last updated
Aug 21, 2026
View on GitHubSave

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:

  • 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. Write the Query

Follow these best practices:

Structure:

  • Use CTEs (WITH clauses) for readability when queries have multiple logical steps
  • One CTE per logical transformation or data source
  • Name CTEs descriptively (e.g., daily_signups, active_users, revenue_by_product)

Performance:

  • Never use SELECT * in production queries -- specify only needed columns
  • Filter early (push WHERE clauses as close to the base tables as possible)
  • Use partition filters when available (especially date partitions)
  • Prefer EXISTS over IN for subqueries with large result sets
  • Use appropriate JOIN types (don't use LEFT JOIN when INNER JOIN is correct)
  • Avoid correlated subqueries when a JOIN or window function works
  • Be mindful of exploding joins (many-to-many)

Readability:

  • Add comments explaining the "why" for non-obvious logic
  • Use consistent indentation and formatting
  • Alias tables with meaningful short names (not just a, b, c)
  • Put each major clause on its own line

Dialect-specific optimizations:

  • Apply dialect-specific syntax and functions (see sql-queries skill for details)
  • Use dialect-appropriate date functions, string functions, and window syntax
  • Note any dialect-specific performance features (e.g., Snowflake clustering, BigQuery partitioning)

5. Present the Query

Provide:

  1. The complete query in a SQL code block with syntax highlighting
  2. Brief explanation of what each CTE or section does
  3. Performance notes if relevant (expected cost, partition usage, potential bottlenecks)
  4. Modification suggestions -- how to adjust for common variations (different time range, different granularity, additional filters)

6. Offer to Execute

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.

Examples

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.

Tips

  • Mention your SQL dialect upfront to get the right syntax immediately
  • If you know the table names, include them -- otherwise Claude will help you find them
  • Specify if you need the query to be idempotent (safe to re-run) or one-time
  • For recurring queries, mention if it should be parameterized for date ranges
SKILL.md on GitHub

Sponsors

SnugThe clipboard manager you and your agent can use, safelyAgent CaffeineClose your lid, come back to finished workWaxBlock anything with supervision, without erasing your iPhoneOpen StepsSponsoredFree and open-source skills that make AI coding agents easier to understand, verify, and control.

Details

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

More from anthropics/knowledge-work-plugins

All 198
  • Journal Entry Prep3K
  • Performance Report3K
  • Ticket Triage3K
  • Meeting Briefing3K
  • Process Doc3K
  • Compliance Tracking3K
  • Guideline Generation3K
  • Create An Asset2.9K
  • Discover Brand2.9K
  • Recruiting Pipeline2.9K
  • Email Sequence2.9K
  • Stakeholder Update2.9K
  • Metrics Review2.9K
  • Draft Content2.9K
  • Enrich Lead2.9K
  • Org Planning2.9K
  • Prospect2.9K
  • Call Summary2.9K
  • Compose Outreach2.9K
  • Contact Research2.9K
  • Customer Escalation2.9K
  • Create Cowork Plugin2.9K
  • Change Request2.9K
  • Comp Analysis2.8K

Recommended

More Databases
1getsentry avatardjango-perf-reviewgetsentry/skillsDjango performance code review. Use when asked to "review Django performance", "find N+1 queries", "optimize Django", "check queryset performance", "database pe2.9Kinstalls
2oracle avatardboracle/skillsOracle Database guidance for SQL, PL/SQL, SQLcl, ORDS, administration, app development, performance, security, migrations, and agent-safe database workflows. Us2.9Kinstalls
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.7Kinstalls
4semgrep 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.6Kinstalls
5runablehq 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.4Kinstalls
6mrgoonie avatarbackend-developmentmrgoonie/claudekit-skillsBuild robust backend systems with modern technologies (Node.js, Python, Go, Rust), frameworks (NestJS, FastAPI, Django), databases (PostgreSQL, MongoDB, Redis),2.3Kinstalls