Track Snowflake credits by warehouse and catch the queries that burn them

Every Monday: Snowflake credits used in the last 7 days against the week before, by warehouse, with the most expensive queries and who ran them.

Runs
Mondays at 8:00
Posts
Stat tile

What lands on your board

Acme SnowflakeCredits used, last 7 days412.6+13% vs previous period, worsevs last report
Estimated cost$1,238
vs last week13%
Top warehouseTRANSFORM_WH
An example with made-up numbers. Your agent posts your real ones.

What it does

Snowflake spend creeps: a warehouse resized for one backfill and never resized back, a dashboard that refreshes every five minutes, a dbt model that started scanning the full table. The admin pages show credits by warehouse, but not which queries inside the warehouse used them.

The agent reads the account usage views every Monday, sums credits by warehouse for the week, and uses query attribution history to rank the queries and users behind the spend. Repeated queries are grouped by their parameterized hash, so one dashboard tile that ran 2,000 times shows up as one line.

How it works

  1. 1Credits by warehouse

    select warehouse_name, sum(credits_used) from snowflake.account_usage.warehouse_metering_history where start_time >= dateadd(day, -7, current_date) and start_time < current_date group by 1 order by 2 desc, and the same for the 7 days before.

  2. 2Total billed credits

    From snowflake.account_usage.metering_daily_history, sum credits_billed by service_type for the same days. This adds serverless features (tasks, Snowpipe, clustering) and applies the cloud services adjustment, so it is the number to quote.

  3. 3Rank the expensive queries

    From snowflake.account_usage.query_attribution_history, sum credits_attributed_compute by query_parameterized_hash, user_name and warehouse_name for the week, top 10. Join query_history on query_id for a sample of the text. Queries under about 100 ms are not attributed.

  4. 4

    4Turn credits into money

    Multiply by your price per credit from the prompt (it depends on edition, region and contract). Flag a warehouse up more than 25%, and a query whose credits doubled.

  5. 5

    5Report

    Credits and estimated cost with the weekly change, warehouses ranked, the top queries with user and warehouse, and one line on where to save.

  6. Post it to the board

    With BRIEFKIN_TOKEN set, the agent sends the result as one card that updates in place every run. Without it, you get the report in the chat.

What you get

  • Credits billed in the last 7 days and the estimated cost, with the weekly change.
  • By warehouse: credits and change.
  • Costliest queries: a shortened query, user, warehouse, runs and credits.
  • Serverless: credits used by tasks, Snowpipe and other services.
  • One line on the biggest saving, such as a warehouse to shrink or a schedule to slow down.

Install and run it

Pick your agent, where the data comes from and how to schedule it; the commands below follow.

Agent
Data
Schedule
  1. Install the skill

    One command. It puts the SKILL.md in ~/.claude/skills and in ~/.agents/skills, which Codex, Cursor, Gemini CLI, Copilot CLI and OpenCode read too.

    shellcurl -fsSL https://briefkin.dev/skills/snowflake-weekly-credit-usage/install | sh
  2. Run it

    Ask Claude Code:

    promptRun the snowflake-weekly-credit-usage skill

    Or paste the prompt instead of installing:

    promptIn Snowflake (read only, using the SNOWFLAKE.ACCOUNT_USAGE views), give me credits for the last 7 full days and the 7 before: by warehouse from WAREHOUSE_METERING_HISTORY (credits_used), and the billed total by service type from METERING_DAILY_HISTORY (credits_billed). From QUERY_ATTRIBUTION_HISTORY, sum credits_attributed_compute by query_parameterized_hash, user and warehouse for the week and list the top 10, with a sample of the query text from QUERY_HISTORY and the number of runs. Convert credits to dollars at $3 per credit unless I give another price. Flag warehouses up more than 25% and queries whose credits doubled. Note that account usage views lag by up to a few hours.
  3. Put it on a schedule

    Mondays at 8:00, from cron on any machine where Claude Code is signed in:

    crontab0 8 * * 1 claude -p "Run the snowflake-weekly-credit-usage skill"

    Add it with crontab -e. A laptop asleep at that time runs it when it wakes if you use launchd or Task Scheduler instead; GitHub Actions works for the API route.

  4. Send it to your board

    Connect Briefkin once with curl -fsSL https://briefkin.dev/install | sh and every run lands on your board as a stat tile. How setup works

View the SKILL.mdRaw file
SKILL.md---
name: snowflake-weekly-credit-usage
description: "Every Monday: Snowflake credits used in the last 7 days against the week before, by warehouse, with the most expensive queries and who ran them. Use when the user asks for this, or when it runs on a schedule."
---

# Snowflake credit usage this week

Every Monday: Snowflake credits used in the last 7 days against the week before, by warehouse, with the most expensive queries and who ran them.

Snowflake spend creeps: a warehouse resized for one backfill and never resized back, a dashboard that refreshes every five minutes, a dbt model that started scanning the full table. The admin pages show credits by warehouse, but not which queries inside the warehouse used them.

The agent reads the account usage views every Monday, sums credits by warehouse for the week, and uses query attribution history to rank the queries and users behind the spend. Repeated queries are grouped by their parameterized hash, so one dashboard tile that ran 2,000 times shows up as one line.

## Two ways to get the data

Use the API or MCP route when you have an MCP server, a CLI or an API token for the app. Otherwise, if you can drive a browser the user is signed in to (Claude in Chrome, a Playwright or Chrome DevTools MCP server), use the browser route. Say which one you used.

## Route A: API or MCP server

### What you need

- A role with the `USAGE_VIEWER` and `GOVERNANCE_VIEWER` database roles in the `SNOWFLAKE` database (or imported privileges on it), and a small warehouse to run the queries.
- Access through the Snowflake CLI (`snow sql -q`) or a Snowflake-managed MCP server with a read-only SQL execution tool.

If something is missing, say what and stop; do not invent numbers.

### Steps

1. **Credits by warehouse** (Snowflake): `select warehouse_name, sum(credits_used) from snowflake.account_usage.warehouse_metering_history where start_time >= dateadd(day, -7, current_date) and start_time < current_date group by 1 order by 2 desc`, and the same for the 7 days before.
2. **Total billed credits** (Snowflake): From `snowflake.account_usage.metering_daily_history`, sum `credits_billed` by `service_type` for the same days. This adds serverless features (tasks, Snowpipe, clustering) and applies the cloud services adjustment, so it is the number to quote.
3. **Rank the expensive queries** (Snowflake): From `snowflake.account_usage.query_attribution_history`, sum `credits_attributed_compute` by `query_parameterized_hash`, `user_name` and `warehouse_name` for the week, top 10. Join `query_history` on `query_id` for a sample of the text. Queries under about 100 ms are not attributed.
4. **Turn credits into money**: Multiply by your price per credit from the prompt (it depends on edition, region and contract). Flag a warehouse up more than 25%, and a query whose credits doubled.
5. **Report**: Credits and estimated cost with the weekly change, warehouses ranked, the top queries with user and warehouse, and one line on where to save.

## Route B: the browser

### What you need

- Signed in to Snowsight with a role that can see Cost Management: ACCOUNTADMIN, or a role with the `USAGE_VIEWER` and `GOVERNANCE_VIEWER` database roles, and a warehouse to run worksheets.

If something is missing, say what and stop; do not invent numbers.

### Steps

Start at https://app.snowflake.com/. The user is signed in already; never type passwords or codes, and ask if a sign-in page appears.

1. **Open Cost Management in Snowsight**: Snowsight asks for the account if you have several; pick it, then switch your role to one with usage access (ACCOUNTADMIN, or a role granted `USAGE_VIEWER`). In the left menu open **Admin** > **Cost Management**.
2. **Credits by warehouse**: On the **Consumption** tab set the date range to **Last 7 days**, the usage type to **Compute**, and group by **Warehouse**. Read credits per warehouse; then move the range to the 7 days before for the comparison. Switch the grouping to **Service** to see serverless credits (tasks, Snowpipe, clustering) next to warehouse compute.
3. **The expensive queries**: The **Account Overview** tab lists **Most expensive queries** for the chosen range with credits, user and warehouse. Click a query to open it in **Query History** for the text. Repeated queries show as separate rows here; group them by the text yourself.
4. **Run the SQL when the UI rounds too much**: Open **Projects** > **Worksheets**, create a worksheet and run the account usage queries: credits by warehouse from `WAREHOUSE_METERING_HISTORY`, billed credits by service type from `METERING_DAILY_HISTORY`, and the top 10 from `QUERY_ATTRIBUTION_HISTORY` grouped by `query_parameterized_hash`. Download the results as CSV if you need them later.
5. **Report**: Credits and the dollar estimate at your price per credit, warehouses ranked with their change (flag any up more than 25%), the top queries with user and warehouse, serverless credits, and one line on where to save.

Note: Cost Management rounds to a decimal and shows the account's local time zone, so figures differ a little from a worksheet query. Account usage views lag: warehouse metering up to 3 hours, query attribution up to 8. Most expensive queries lists individual runs, not parameterized groups, so a dashboard tile that ran 2,000 times is spread across many rows.

## The report

- **Credits billed** in the last 7 days and the estimated cost, with the weekly change.
- **By warehouse**: credits and change.
- **Costliest queries**: a shortened query, user, warehouse, runs and credits.
- **Serverless**: credits used by tasks, Snowpipe and other services.
- One line on the biggest saving, such as a warehouse to shrink or a schedule to slow down.

## Post it to Briefkin

When `BRIEFKIN_TOKEN` is set, or `~/.config/briefkin/env` exists (the installer from https://briefkin.dev/docs writes it), also send the result to the user's Briefkin board as one card. Keep the `item_key` the same on every run so the card updates in place, use a new `event_id` per run, and put today's real numbers in place of the example ones. If the request fails, say so once and carry on.

```bash
[ -n "${BRIEFKIN_TOKEN:-}" ] || . ~/.config/briefkin/env
curl -sS -X POST "${BRIEFKIN_URL:-https://briefkin.dev}/v1/events" \
  -H "authorization: Bearer $BRIEFKIN_TOKEN" \
  -H "content-type: application/json" \
  -d @- <<'JSON'
{
  "v": 1,
  "event_id": "snowflake-weekly-credit-usage/<date of this run, e.g. 2026-10-16>",
  "item_key": "snowflake-weekly-credit-usage",
  "project": "Acme Snowflake",
  "source": "Snowflake credit usage this week skill",
  "kind": "metric",
  "title": "412.6 credits this week, up 13%",
  "metric": {
    "label": "Credits used, last 7 days",
    "value": 412.6,
    "better": "lower",
    "period_start": "<start of the period, ISO 8601>",
    "period_end": "<end of the period, ISO 8601>"
  },
  "glance": [
    {
      "type": "Grid",
      "props": {
        "columns": 3
      },
      "children": [
        {
          "type": "Stat",
          "props": {
            "label": "Estimated cost",
            "value": 1238,
            "prefix": "$",
            "better": "lower"
          }
        },
        {
          "type": "Stat",
          "props": {
            "label": "vs last week",
            "value": 13,
            "unit": "%"
          }
        },
        {
          "type": "Stat",
          "props": {
            "label": "Top warehouse",
            "value": "TRANSFORM_WH"
          }
        }
      ]
    }
  ],
  "widget": [
    {
      "type": "Bars",
      "props": {
        "unit": "credits",
        "items": [
          {
            "label": "TRANSFORM_WH",
            "value": 198.4
          },
          {
            "label": "BI_WH",
            "value": 121.7
          },
          {
            "label": "LOAD_WH",
            "value": 58.3
          },
          {
            "label": "ADHOC_WH",
            "value": 21.9
          },
          {
            "label": "Serverless",
            "value": 12.3
          }
        ]
      }
    },
    {
      "type": "Table",
      "props": {
        "columns": [
          "Query",
          "User",
          "Runs",
          "Credits"
        ],
        "align": [
          "left",
          "left",
          "right",
          "right"
        ],
        "rows": [
          [
            "merge into analytics.fct_events using ...",
            "DBT_PROD",
            168,
            46.2
          ],
          [
            "select * from raw.events where event_date >= ?",
            "MAYA",
            4,
            18.9
          ],
          [
            "select count(distinct user_id) from analytics.sessions ...",
            "LOOKER",
            2016,
            14.6
          ],
          [
            "create or replace table analytics.dim_users as ...",
            "DBT_PROD",
            7,
            9.8
          ]
        ]
      }
    },
    {
      "type": "Callout",
      "props": {
        "text": "TRANSFORM_WH rose 31% after fct_events switched to a full merge on Tuesday. An incremental filter on event_date would cut most of it.",
        "tone": "warn"
      }
    }
  ],
  "size": "md"
}
JSON
```

Widgets come from the Briefkin catalog (https://briefkin.dev/v1/catalog). Without a token, just give the user the report.

Set `period_start` and `period_end` to the window the number covers: the tile names it from them ("Last 7 days", "Today", "This month"). For a count right now (open items, a balance), send `"period_label": ""` so no period shows; for another name, send it as `period_label` (at most 24 characters).

## Run it on a schedule

Suggested: Mondays at 8:00 (`0 8 * * 1`). From cron, with the agent signed in on that machine:

```bash
0 8 * * 1 claude -p "Run the snowflake-weekly-credit-usage skill"
# Codex: codex exec, Gemini CLI: gemini -p, Copilot CLI: copilot -p, OpenCode: opencode run
```

Or use the agent's own scheduler (Claude Code routines, Codex automations, Claude or ChatGPT scheduled tasks): https://briefkin.dev/skills/snowflake-weekly-credit-usage#schedule

Source: https://briefkin.dev/skills/snowflake-weekly-credit-usage

What your agent needs

  • A role with the USAGE_VIEWER and GOVERNANCE_VIEWER database roles in the SNOWFLAKE database (or imported privileges on it), and a small warehouse to run the queries.

  • Access through the Snowflake CLI (snow sql -q) or a Snowflake-managed MCP server with a read-only SQL execution tool.

Connecting Snowflake

  1. Snowflake-managed MCP server. You create it in your account with CREATE MCP SERVER ... FROM SPECIFICATION, listing tools such as SYSTEM_EXECUTE_SQL (with read_only: true in its config), Cortex Analyst, Cortex Search or a Cortex Agent. Its URL is https://<account_url>/api/v2/databases/<db>/schemas/<schema>/mcp-servers/<name>. Snowflake is in Claude's connector directory, and in Claude you can also add the URL as a custom connector with the client ID and secret from a Snowflake OAuth security integration, since Snowflake doesn't support dynamic client registration. In Claude Code, the simplest route is a programmatic access token for a least-privileged role: claude mcp add --transport http snowflake <url> --header "Authorization: Bearer <PAT>". Cursor takes the URL with an OAuth client ID and secret (docs). The older open-source Snowflake Labs MCP server is deprecated.
  2. Snowflake CLI. With a connection named in ~/.snowflake/config.toml, snow sql -q "SELECT ..." -c reporting --format json returns rows an agent can read.
  3. Drivers or the SQL API with a service user and a programmatic access token; the skill reads SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, SNOWFLAKE_PAT, SNOWFLAKE_ROLE and SNOWFLAKE_WAREHOUSE.

Create a reporting role with USAGE on one small warehouse and SELECT on the reporting schema, add the SNOWFLAKE.USAGE_VIEWER database role for the cost views, and grant the MCP server and its tools to that role only. Snowflake notes that tool annotations are hints, not controls: the role is what limits the agent.

Questions

Why do warehouse credits and billed credits differ?

credits_used in the metering history includes all cloud services credits, while billing only charges cloud services above 10% of daily compute. credits_billed in metering_daily_history applies that adjustment and adds serverless features, so it is the figure that matches the invoice.

How fresh is the data?

Warehouse metering lags up to 3 hours (cloud services up to 6), and query attribution up to 8 hours. A Monday 8:00 run that reports up to the end of Sunday has complete numbers for the week except the last hours of Sunday night, which the next run picks up.

Do I need Briefkin to use the Snowflake credit usage this week skill?

No. The skill runs with your own agent and gives you the report in the chat. With a Briefkin token set, each run also posts it to your board as a stat tile, so you can glance at it instead of asking again.

Which agents can run it?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, OpenCode, Windsurf and Amp all read SKILL.md files. The install command puts it in ~/.claude/skills and ~/.agents/skills, where they look. ChatGPT, the Claude app and Grok take the prompt instead. Pick your agent under "Install and run it" and the commands change to match.

Can it work without an API or MCP server, from my browser?

Yes. Switch the data source to "Your browser" and the steps change to the Snowflake pages themselves: the agent opens app.snowflake.com in a browser you are signed in to and reads the numbers off the page. Claude Code, Codex, Cursor, Claude app and ChatGPT can drive a browser out of the box; Gemini CLI, Copilot CLI and OpenCode need a Playwright or Chrome DevTools MCP server first. It is slower than the API and needs you signed in, so it suits a report you run by hand or from a scheduler on your own computer.

Watch credits used, last 7 days on your board, run after run

Skills are free to use with any agent. Briefkin is where their results land: one board for every report, number and question your agents send, with a ping when something needs you.

Free during the open beta. No card.