enforcing-resource-attribution

Applies attribution labels to bq and gcloud CLI commands for resource tracking.

Updated Jul 7, 2026
One-click install
npx skills add https://github.com/ricardolui/gcp-custom-agent-skills --skill enforcing-resource-attribution-ricardolui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: enforcing-resource-attribution
Source: https://github.com/ricardolui/gcp-custom-agent-skills/tree/main/enforcing-resource-attribution
Command: npx skills add https://github.com/ricardolui/gcp-custom-agent-skills --skill enforcing-resource-attribution-ricardolui

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents running BigQuery and Google Cloud CLI commands often create or modify cloud resources without any attribution, making it impossible to track which environment or client originated the changes. This Skill enforces consistent labeling so resource usage can be traced back to its source. ## Core Features & Use Cases - BigQuery Label Enforcement: Adds the mandatory --label datacloud:<ide> flag to supported bq subcommands (query, load, extract, mk, update, cp) while explicitly avoiding invalid flags on read-only commands like bq show or bq ls. - gcloud Metrics Attribution: Prepends CLOUDSDK_METRICS_ENVIRONMENT=datacloud.<ide> to every gcloud command, covering both read-only and mutation operations. - Environment Deduction: Provides rules for detecting the current client (vscode, cursor, cloud-shell, gemini-cli, etc.) with an ai-agent fallback. - Use Case: When an AI agent runs bq query against an analytics dataset during a data preparation workflow, the command is automatically tagged with datacloud:vscode so platform teams can attribute the resulting jobs and resources. ## Quick Start Ask the agent to run a BigQuery query or any gcloud command and it will automatically attach the correct attribution label for your environment.

Frequently Asked Questions about enforcing-resource-attribution

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add attribution labels to bq query commands?

Add the --label datacloud:<ide> flag to bq query, substituting <ide> with your environment such as vscode or cursor. For example: bq query --use_legacy_sql=false --label datacloud:vscode "SELECT 1". Labels cannot contain dots or spaces.

How do I tag gcloud commands for resource attribution?

Prepend every gcloud command with the CLOUDSDK_METRICS_ENVIRONMENT environment variable, for example CLOUDSDK_METRICS_ENVIRONMENT=datacloud.vscode gcloud compute disks create my-disk. This applies to all gcloud commands, both read-only and mutations.

Which bq subcommands support the --label flag?

Only bq query, load, extract, mk, update, and cp accept job or resource labels. Do not add --label to bq show, ls, version, rm, cancel, or head, as these subcommands do not support the flag and will fail.

When should I omit attribution labels on CLI commands?

Omit labels for generic administrative commands unrelated to Data Cloud or Analytics, such as managing Compute Engines for web apps or standard IAM policies. Labels apply only to Data Agent Kit workflows and analytics infrastructure operations.

What value should I use if my environment cannot be determined?

Use ai-agent as the fallback identifier when the client environment cannot be detected. For bq labels use datacloud:ai-agent, and for gcloud use CLOUDSDK_METRICS_ENVIRONMENT=datacloud.ai-agent, since gcloud values require dots rather than colons.