Agent Skills guide
Skill recipe: your data team's SQL conventions
A worked skill that teaches agents your warehouse dialect, table naming, metric definitions and review rules, so generated SQL matches your team's.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
A SQL conventions skill gives an agent what it cannot infer from the schema: your warehouse dialect, which tables replaced which, how each business metric is defined and the checks every query must pass. Keep the rules in SKILL.md and the metric and table definitions in reference files, so the agent reads only what a question needs.
Agents write competent SQL. They do not know that your “active customer” excludes trial accounts, that orders_v2 replaced orders last year, or that your warehouse is Snowflake and dates are stored in UTC. The result is queries that run and return the wrong number, which is worse than a query that fails. A skill with your conventions fixes the most common causes. This recipe builds one for a data team; it works the same in a coding agent and in the Claude apps. We re-ran it on 25 November 2026: the SKILL.md passes the skills-ref validator from the spec repository, and the active-customer query below parses as Snowflake SQL and returns the expected customers against a small test table.
Start from a general SQL skill
Anthropic’s SQL queries skill already covers good SQL across PostgreSQL, Snowflake, BigQuery, Redshift and Databricks: window functions, cohorts, funnels, deduplication. Install it, and keep your skill to what is specific to you. Two small skills that each do one job trigger more reliably than one large one.
What goes in
- Dialect and environment: which warehouse, which schemas are production, how dates and time zones are stored.
- Naming: table and column conventions, so the agent can guess names and you can spot made-up ones.
- Which tables to use: the approved models, and the deprecated ones to avoid.
- Metric definitions: the exact SQL for the numbers people argue about.
- Review rules: what every query must do before anyone trusts its output.
SKILL.md
---
name: acme-sql
description: >-
Acme SQL conventions for our Snowflake warehouse: tables, naming, metrics
and review checks. Use when writing or reviewing SQL on Acme data, or when
asked for a number like active customers or MRR.
metadata:
owner: data-platform
---
# Acme SQL conventions
Warehouse: Snowflake. Query only the ANALYTICS database. Never query RAW
unless the user asks and says why.
## Tables
- Use models in ANALYTICS.MARTS (prefixed `fct_` for events, `dim_` for
entities). Read references/tables.md for the list and their grain.
- Deprecated, do not use: `orders` (use `fct_orders`), `users_legacy`.
## Naming
- snake_case everywhere. Booleans start with `is_` or `has_`.
- Timestamps end in `_at` and are UTC. Dates end in `_date`.
- Convert to local time only in the final SELECT, with `CONVERT_TIMEZONE`.
## Metrics
Use the definitions in references/metrics.md exactly. If a request uses a
metric name that is not defined there, ask which definition the person means
before writing the query.
## Every query
1. State the grain of the result ("one row per customer per month").
2. Filter test and internal accounts: `where not is_internal`.
3. Check for duplicates after every join that could fan out.
4. For a reported number, also run a count of rows behind it.
5. Add a comment block with the question, the date range and the author.
references/metrics.md
This file is where the skill earns its keep. Write each metric once, as SQL, with the edge cases decided:
-- Active customer: paid subscription, not a trial, not internal,
-- at least one billable event in the period.
select distinct c.customer_id
from analytics.marts.dim_customers c
join analytics.marts.fct_billable_events e
on e.customer_id = c.customer_id
where c.plan_type <> 'trial'
and not c.is_internal
and e.event_at >= :period_start
and e.event_at < :period_end;
Use the same parameter style your team uses (:period_start here). Add a line on who owns each definition and when it last changed. If you already define metrics in a semantic layer or dbt, generate this file from there instead of maintaining two copies.
references/tables.md
One entry per approved model: what one row means, the key columns, and known traps. For example, “fct_orders: one row per order line, not per order. Use count(distinct order_id) for order counts.” That single sentence prevents the most common inflated number in any orders table. A short file in that style:
# Approved tables (ANALYTICS.MARTS)
## dim_customers
Grain: one row per customer, current state only.
Keys: customer_id. Filter: not is_internal.
Trap: plan_type is today's plan. For the plan in a past month, join
fct_subscription_months instead.
## fct_orders
Grain: one row per order line, not per order.
Keys: order_line_id, order_id, customer_id. Timestamps in UTC.
Trap: count(distinct order_id) for order counts; sum(line_amount) for
revenue, never sum(order_total), which repeats on every line.
## fct_billable_events
Grain: one row per billable event.
Keys: event_id, customer_id, event_at.
Trap: event_at is when the usage happened, billed_at is when it was
invoiced. Activity questions use event_at; revenue questions use billed_at.
Write the traps from real incidents. Every wrong number your team has shipped is a line in this file, and it is the line most likely to stop the next one.
Testing it
Start each test in a fresh session and do not name the skill. These should load it:
How many active customers did we have in October 2026?
Write a query for monthly recurring revenue by plan for the last six
months, one row per plan per month.
Review this query before I send the number to finance:
select count(*) from orders where created_at >= '2026-10-01'
For each, check that the agent used fct_ and dim_ models (the review should flag orders as deprecated), filtered internal accounts, stated the grain and asked which definition you meant if a metric was not in metrics.md. The third prompt is the most useful: a skill that catches a deprecated table and a missing filter in someone else’s SQL is doing its job.
These should not load it:
Fix the pandas warning in notebooks/cohorts.ipynb about chained assignment.
Write a Postgres migration that adds an index on users.email.
Then the real test. Collect five questions your team was asked last month, with the answers you shipped, and ask each without naming the skill. Compare the agent’s query with yours: same tables, same filters, same number. Where it differs, the fix is usually a missing line in metrics.md or tables.md.
Keeping it current
The skill goes wrong the same way a wiki page does: a table is renamed, a metric is redefined, and nobody updates the text. Give the folder an owner (the metadata.owner line), keep it in the same repository as your dbt project or warehouse code so a model change and a skill change can land in one pull request, and add a line to your review checklist: “does this change a table or metric in the SQL skill?”. When a definition changes, write the date in metrics.md, because last quarter’s report used the old one.
Using it outside the IDE
Because the skill uses only spec fields and its description is under the 200 characters the Claude apps allow on upload, it uploads as is. Analysts can then ask questions in chat with the same definitions engineers use. Pair it with statistical analysis for reading the results carefully and build dashboard for sharing them. For the upload steps, see Agent Skills in the Claude API and claude.ai.
If this is your first skill, what Agent Skills are and how to create a Claude skill cover the basics, and testing and evaluating Agent Skills shows how to prove the skill fixes the wrong-number problem rather than just loading. Reference files that load on demand are the idea behind the router in Agent Skill design patterns.
Related
- Data analysis with AI
Cleaning, exploring and charting data with an AI assistant and a repeatable method.
- Agent Skill best practices: nine design patterns with real examples
Agent skill best practices as nine design patterns, from checklists and routers to script-backed and gated skills, each with a real example and when to use it.
- Clean and analyse a messy spreadsheet with AI
Clean a messy spreadsheet with ChatGPT or Claude without losing rows: profile it, agree the rules, keep a cleaning log and reconcile totals before any chart.