Skills Plugins MCP Prompt Model 博客 我的中心
内容创作 #data #ai

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.

DeepseekModel 官方收录技能 质量 优秀 · 90 v1.0.0

获取

https://deepseekmodel.com/api/download.php?id=anthropics-knowledge-work-plugins-data-skills-write-query-skill-md&format=skill
下载 .skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用
.skill 文件中 system_prompt 字段的实际内容。
name write-query description 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. argument-hint <description of what data you need> /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: Search for relevant tables based on the user's description Inspect column names, types, and relationships Check for partitioning or clustering keys that affect performance 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: The complete query in a SQL code block with syntax highlighting Brief explanation of what each CTE or section does Performance notes if relevant (expected cost, partition usage, potential bottlenecks) 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
Agent 识别该技能的关键词,点击任意一个即可复制。

该技能未提供触发词。

下载的 .skill 包内含以下字段。
字段 说明
format格式标识(skill/v1)
skill_id技能唯一 ID
name技能名称
version版本号
description技能描述
category所属分类(数组)
trigger_words触发词列表
tags标签列表
source来源标识
source_url来源链接(本页地址)
exported_at导出时间(每次下载生成)
system_prompt系统提示词正文
model_config模型参数:provider / model / temperature / max_tokens / top_p
examples示例
install_guide各平台导入说明(Coze / Dify / Claude / 自定义框架)
同一份技能可按不同平台格式导出。
.skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用 下载
.skillpro 增强格式,额外含脚本 / 工具 / 依赖 / 钩子占位 下载
.json 纯 JSON 导出,只含 system_prompt 与模型参数 下载
Coze 带 frontmatter 的 Markdown,Coze 平台导入用 下载
Dify Dify DSL,创建应用后直接导入 下载

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

验证码 --

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。