Skip to content

Guide · Agent skill

How to use the GKE Cost Analysis agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The gke-cost-analysis skill is an instruction package for an AI agent, such as Claude, that teaches it how to answer cost questions about Google Kubernetes Engine (GKE). It tells the agent to pull costs from your BigQuery billing export, check whether cost allocation labels are on, and compare live pod usage against requests. This guide covers what the skill does, how to install it, how to phrase requests so it triggers, and what it needs and touches, so you can ask questions like 'which namespace is most expensive' and get a sourced answer.

GKE Cost Analysisgoogle/skills · Apache-2.0

Quick start

  1. 1Download and unzip the skill. Download the ZIP from this page and unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder. Alternatively, upload the ZIP under Settings → Capabilities → Skills in the Claude apps.
  2. 2Confirm your prerequisites. Make sure gcloud, the bq CLI and kubectl are installed and can reach your cluster. Confirm you have read access to your GCP Billing detailed BigQuery export.
  3. 3Find your billing export table. Note the full path to your billing export table, meaning the dataset and table name that contain your Billing Account ID. The agent needs this to run queries.
  4. 4Ask a natural question. Describe what you want to know, such as the most expensive namespace or a cost spike, and name the cluster or time period if relevant.
  5. 5Enable cost allocation if labels are empty. If namespace or workload breakdowns come back empty, approve the gcloud container clusters update command with --enable-cost-allocation. Remember that labels only populate from that point forward.
  6. 6Review the findings. Compare pod requests with live usage from kubectl top and check whether your cluster is billed per pod or per node.

What is an agent skill and what does this one do?

An agent skill is a folder containing a SKILL.md file and optional reference files. When the skill is installed, the agent reads it when a request matches the skill's description, then follows its guidance. This skill is focused on GKE cost analysis: it helps the agent explain costs, query billing data and diagnose cost drivers.

Once installed, the agent can answer questions such as which namespace or workload is most expensive on GKE, and why a cluster's cost is spiking. The skill also explains whether a cluster is billed per pod (Autopilot) or per VM node (Standard).

  • Queries your BigQuery billing export using bq
  • Checks whether GKE cost allocation labels are enabled
  • Compares live pod usage (kubectl top) with requested resources to find waste
  • Explains Autopilot versus Standard billing drivers
  • Does not apply cost fixes; rightsizing is handled by the separate gke-cost-optimization skill

Install the gke-cost-analysis skill

Download the ZIP file for this skill from this page. Unzip it into your personal skills folder, ~/.claude/skills/, so it is available in all your projects. To limit it to one project, unzip it into the .claude/skills/ folder inside that project instead.

If you use the Claude apps rather than a local setup, open Settings, go to Capabilities, then Skills, and upload the ZIP there.

  • Personal install: ~/.claude/skills/
  • Project install: .claude/skills/ inside your project folder
  • Claude apps: Settings → Capabilities → Skills, then upload the ZIP

Set up the prerequisites

The skill assumes you already have several Google Cloud tools and data in place. The most important is a GCP Billing detailed BigQuery export with read access. The skill cannot create this export for you, and its core analysis depends on it. You also need to give the agent the full path to your billing export table, which means the dataset and table name that contain your Billing Account ID.

Other requirements: the Google Cloud SDK (gcloud) and the bq CLI, kubectl with access to the cluster, and the Cost Management API enabled if you want budget listing. You need permission to run gcloud container clusters update only if cost allocation must be turned on.

  • Google Cloud SDK (gcloud) and bq CLI
  • kubectl with access to your cluster
  • GCP Billing detailed BigQuery export with read access (required for the core analysis)
  • Cost Management API enabled, for budget listing
  • Permission to run gcloud container clusters update, only if you need to enable cost allocation

Trigger the skill with natural requests

You do not need special syntax. Ask a cost question in plain language and mention GKE, your cluster or your billing data. Good requests name what you want to know and the scope, such as a namespace, workload, cluster or time period. The skill's defaults assume the last 30 days, a row limit of 10, and results sorted by cost from highest to lowest, unless you say otherwise.

The skill also triggers on requests about billing reports in BigQuery, cluster cost budgets, and pod requests versus actual utilization.

  • What is my most expensive namespace on GKE this month?
  • Why did my cluster cost spike last week? Check the billing export.
  • Compare pod CPU and memory requests with actual usage in the payments namespace.
  • Show the cost of workload checkout-api in cluster prod-east over the last 30 days.
  • Is my cluster billed per pod or per node?

Check and enable cost allocation

Namespace, label and workload-level breakdowns need GKE cost allocation enabled on the cluster. Without it, queries can return empty labels. Enabling it changes the cluster, so the skill asks for your explicit confirmation first. Labels only appear in the billing export from the time you enable cost allocation onward; there is no historical backfill.

  • Cost allocation populates the goog-k8s-cluster-name, k8s-namespace, k8s-workload-name and k8s-workload-type labels in BigQuery
  • Checking that goog-k8s-cluster-name exists also scopes the billing data to GKE costs
gcloud container clusters update {cluster_name} \ --enable-cost-allocation \ --region {region}

Read cost drivers and find waste

The skill explains how pricing differs by mode. On Autopilot, you are billed on pod resource requests, so over-requested pods raise cost even if they do not use those resources. On Standard, you are billed on the VM nodes in your node pools, so idle nodes and many low-utilization clusters add cost. Both modes carry a cluster management fee, and the free tier waives it for one eligible cluster per billing account.

To find waste, the skill compares live usage with requests. The read-only commands below show node and pod utilization. When reviewing the results, compare what pods request with what they actually use. When reading cost versus cost_before_credits, remember that Committed Use Discounts and Spot VMs appear as credits or reduced rate charges.

  • Autopilot: billed on requests.cpu, requests.memory and ephemeral storage
  • Standard: billed on provisioned node pool VMs plus control plane fees
  • Read budgets with gcloud billing budgets list, which needs the Cost Management API
gcloud billing budgets list --billing-account={billing_account} --quiet kubectl top nodes kubectl top pods --all-namespaces --containers

Safety notes: scripts and network access

This skill runs scripts and uses the network. Its commands call Google Cloud services through gcloud, bq and kubectl, so they use your credentials and access your billing data and cluster. The skill's guidance is to use read-only inspection commands wherever possible. The one command that changes state is gcloud container clusters update with --enable-cost-allocation, which needs your confirmation.

The skill also asks the agent to tag gcloud commands it runs in the terminal with a usage attribution environment variable, set inline on each command rather than with gcloud config set. Review each command before the agent runs it.

  • Read-only by default; enabling cost allocation modifies the cluster
  • Commands run with your own gcloud and kubectl credentials
  • Review the agent's commands before approving them

What people use it for

  • Explain to finance which namespace or team drove most of last month's GKE spend
  • Investigate a sudden cost spike by breaking it down by workload and cluster in the billing export
  • Find over-requested pods on Autopilot by comparing requests with live usage
  • Check whether a Standard cluster's cost is driven by idle node pool VMs
  • Get a ready-to-adapt bq query for the cost of one workload in one cluster

Frequently asked questions

How do I install the gke-cost-analysis skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into .claude/skills/ inside a project. In the Claude apps, you can instead upload the ZIP under Settings → Capabilities → Skills.

What are the requirements for the GKE cost analysis skill?

You need the Google Cloud SDK (gcloud) with the bq CLI, kubectl with access to your cluster, and a GCP Billing detailed BigQuery export with read access. The Cost Management API is needed for budget listing, and permission to run gcloud container clusters update is needed only if you enable cost allocation.

Is the GKE cost analysis skill free?

The source does not state a licence fee for the skill. It is published under the Apache-2.0 licence. Note that Google Cloud charges for the services it queries, and the cluster management fee applies to GKE clusters.

Can this skill create my billing export or fix my costs?

No. The skill cannot create a BigQuery billing export, and the core analysis depends on one. It only analyses costs. Applying changes such as rightsizing is handled by the separate gke-cost-optimization skill.

Why are my namespace or workload costs empty in BigQuery?

GKE cost allocation may not be enabled on the cluster. Enable it with gcloud container clusters update and the --enable-cost-allocation flag. Labels populate only from that point onward, with no historical backfill.

How does this compare with just writing bq queries myself?

The skill gives the agent the table placeholders, default time range, row limit and sorting, plus guidance on Autopilot versus Standard pricing and on checking live usage. If you already know the queries and billing model well, you may not need it.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

This skill suits platform or DevOps engineers who already export Google Cloud billing to BigQuery and need to explain or investigate GKE spend. It is a poor fit if you have no billing export set up, or if you want the agent to apply cost fixes, since it only analyses and hands optimisation work to gke-cost-optimization.

Download the skill