From active-skills
Use this skill when interacting with Google Cloud services using the gcloud CLI. Use when managing cloud resources, querying configurations, or troubleshooting issues via gcloud.
How this skill is triggered — by the user, by Claude, or both
Slash command
/active-skills:gcloudThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This document provides essential guidelines and best practices for AI agents interacting with the Google Cloud SDK (`gcloud` CLI). Following these rules is critical to avoid hallucinated commands, flags, flag values, and positional argument syntax, prevent destructive actions, and minimize context window usage.
This document provides essential guidelines and best practices for AI agents interacting with the Google Cloud SDK (gcloud CLI). Following these rules is critical to avoid hallucinated commands, flags, flag values, and positional argument syntax, prevent destructive actions, and minimize context window usage.
If the gcloud executable is missing, refer to the official Google Cloud CLI Installation Guide to install it on your platform (Linux, macOS, Windows, etc.).
Authenticate the CLI with Google Cloud. Choose the flow that matches your running environment:
gcloud auth login. Follow the browser prompts to sign in.--no-browser flag: gcloud auth login --no-browser. Copy the URL, sign in on another machine, and return the authentication code.gcloud auth application-default login (append --no-browser for headless environments).gcloud auth activate-service-account --key-file=path/to/key.json. Note that some organizations may restrict access to JSON key files for security reasons.gcloud config set auth/impersonate_service_account SERVICE_ACCT_EMAILSeparation of Privilege (Critical): Both service account approaches ensure the agent's permissions remain strictly distinct from the human user's wide access limits (enforcing least privilege), and ensure actions are properly audited under the agent's focused identity. (Impersonation requires roles/iam.serviceAccountTokenCreator).
For more detailed strategies and authentication types (such as Workload Identity Federation), see Authorizing the gcloud CLI.
Your internal knowledge of gcloud may be stale or prone to hallucination (e.g., hallucinating commands, flags, flag values, or positional argument syntax). You are FORBIDDEN from executing commands until you have validated the exact syntax at the leaf level.
gcloud help <command> for the exact command you intend to run (e.g., gcloud help compute instances create).To save context window space and reduce latency, always minimize the volume of data returned by gcloud.
Projection: Use --format=json(key1, key2, ...) to select only the specific fields needed for your task. To understand the advanced projection and formatting syntax, refer to gcloud topic projections and gcloud topic formats.
Limiting: Use --limit=N to cap the number of resources returned.
Filtering: Use --filter to narrow down results server-side. Prioritize : for pattern matching and never quote the right side of the colon. Treat the entire filter flag as a singular string without quoting or escaping characters. To study the filter expression syntax, refer to gcloud topic filters.
Schema Discovery: Unconstrained resource lists can quickly exhaust your context window with redundant data. To prevent this, discover a resource's schema before executing queries. If you are unsure of the JSON key path for projecting fields (--format) or filtering (--filter), run the targeted resource's list command (if supported) with a single-item limit:
gcloud <GROUP> <RESOURCE> list --limit=1 --format=json
Examine this single instance's JSON structure to safely identify the correct schema keys before requesting full or filtered datasets.
gcloud command at a time. No command chaining or sequencing.$(...)), pipes (|), or redirection (>, >>, <). This is to increase command safety and ensure commands are more easily understandable and reviewable by users.gcloud interactive). You must enforce non-interactive mode by appending --quiet (or -q) to your commands. This ensures that defaults are used or errors are raised if input is required.To ensure commands are deterministic, non-interactive, and target the correct environment, you must explicitly manage project and location scoping.
--project=<PROJECT_ID> to all resource-manipulating and querying commands (unless running pure local config commands). This avoids accidental execution against the wrong project.--region, --zone, or --location), gcloud will trigger an interactive prompt to select a zone/region. This violates the No Interactivity rule. Always provide explicit location flags if the command requires them.gcloud compute regions list --project=<PROJECT_ID>gcloud compute zones list --project=<PROJECT_ID>locations list command:
gcloud <GROUP> locations list --project=<PROJECT_ID>gcloud artifacts locations list, gcloud kms locations list, gcloud secrets locations list.[!CAUTION] Destructive actions (delete, update, remove) MUST be explicitly authorized by the user. Never invoke them autonomously unless explicitly instructed to do so in the context of a safe, pre-approved workflow.
You are strictly prohibited from executing the following commands autonomously. These require explicit human-in-the-loop authorization:
gcloud * delete (Destructive): Irreversible resource destruction (e.g., project deletion) or data wiping.gcloud billing * (Financial): Risk of service disruption or unbounded costs.gcloud organizations * (Governance): Org-level changes affect security posture for all users.gcloud kms * (Encryption): Risk of permanently locking data.gcloud infra-manager deployments apply (Destructive): Autonomous IaC execution can destroy managed resources.--dry-run (or equivalent) first if it exists, before executing the actual command, to preview changes.--async flag is highly recommended for long-running operations to avoid blocking the agentic flow. Note that not every command has an --async flag. For commands that return an operation ID (whether via --async or by default), you are responsible for polling for completion if the operation status is needed for the next step.--project: Commands run without --project may target the wrong active configuration, leading to errors or unintended resource modification.--region or --zone often triggers an interactive prompt, which causes agents to hang or fail.list without --limit or --filter in a large environment can crash the agent session by exhausting the context window.gcloud will fail if the underlying API is not enabled. Check API status if commands fail with 'permission denied' or 'api not enabled' errors.--filter expressions often leads to syntax errors. Treat the entire filter as a single string.| Component | Reality |
|---|---|
Assumption: Flags for gcloud compute instances create are already known. | gcloud syntax changes frequently. Hallucinated flags lead to execution failure. Always run help. |
| Shortcut: Listing all buckets is safe because the project is currently small. | Projects grow. Unconstrained lists are a scalability trap. Always use --limit=1 for discovery. |
| Config Dependency: The project is already set in the active configuration. | Global state is unreliable in agentic environments. Always be explicit with --project. |
Piping: Piping output to grep is easier than writing a --filter. | Pipes and shell operators are prohibited for safety and reviewability. Use --filter instead. |
gcloud help before execution.| grep instead of --filter.| awk or | jq instead of --format.delete, remove) without explicit user permission.gcloud commands in a single shell string.When asked to perform a task on a service you are not familiar with:
gcloud help <COMMAND>) before invoking it.gcloud help compute) to discover available subcommands and groups.gcloud <GROUP> <RESOURCE> list --limit=1 --format=json to safely discover the schema. Never run a raw list command without scoping constraints (like --limit=1), as unconstrained results will pollute and exhaust your context window.| Task | Command Template |
|---|---|
| Discover Schema | gcloud <GROUP> <RESOURCE> list --limit=1 --format=json |
| Filtered List | gcloud <GROUP> <RESOURCE> list --filter="status:RUNNING" |
| Specific Columns | gcloud <GROUP> <RESOURCE> list --format="json(name, id)" |
| Learn Filters | gcloud topic filters |
| Learn Formats | gcloud topic formats |
| Learn Projections | gcloud topic projections |
| Asynchronous Op | gcloud <COMMAND> --async |
| Check Operation | gcloud operations describe <OPERATION_ID> |
| Common commands | gcloud cheat-sheet |
| List Regions (GCE) | gcloud compute regions list --project=<PROJECT_ID> |
| List Zones (GCE) | gcloud compute zones list --project=<PROJECT_ID> |
| List Locations | gcloud <GROUP> locations list --project=<PROJECT_ID> |
Refer to the gcloud CLI Scripting Guide for guidance on using the gcloud CLI in automation.
Guides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Resolves in-progress git merge or rebase conflicts by analyzing history, understanding intent, and preserving both changes where possible. Runs automated checks after resolution.
2plugins reuse this skill
First indexed Jul 18, 2026
npx claudepluginhub mlarkin00/plugins --plugin active-skills