{"id":"eb968ad7-a0bb-4fa0-aab7-02e1159ed8d2","slug":"gcloud","kind":"skill","name":"gcloud","summary":"Provides safety-critical validation, guardrails, and data reduction for gcloud CLI operations across Google Cloud Platform (GCP) services and infrastructure. Use when planning, generating, constructin","owner":"google","repoUrl":"https://github.com/google/skills/tree/HEAD/plugins/cloud/google-cloud-developer/skills/gcloud","license":"Apache-2.0","licenseTier":"permissive","trust":"official","stars":21260,"match":null,"fewStars":false,"format":"skill","createdAt":null,"addedAt":"2026-10-14T05:33:08.525Z","logoUrl":"https://avatars.githubusercontent.com/u/1342004?v=4","linkOnly":false,"collection":{"name":"skills","repo":"google/skills"},"skillPath":"plugins/cloud/google-cloud-developer/skills/gcloud","categories":["cloud-infra","developer-tools","data-analytics"],"tags":["google","googlecloud"],"runtime":"binary","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-14T05:33:08.520Z","sample":false,"url":"https://conduits.dev/tools/gcloud","language":"Python","transports":[],"install":{},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"> Provides safety-critical validation, guardrails, and data reduction for gcloud CLI operations across Google Cloud Platform (GCP) services and infrastructure. Use when planning, generating, constructing, proposing, describing, or executing any gcloud CLI commands - including when answering questions about gcloud syntax, or formatting flags. Don't use when writing Google Cloud client library code or raw REST/gRPC API requests.\n\n# gcloud CLI Skill for AI Agents\n\n> [!CAUTION]\n>\n> ### MANDATORY PRE-CONDITION: EXPLICIT LEAF-LEVEL SYNTAX VALIDATION\n>\n> All pre-existing knowledge of `gcloud` commands, flags, flag values, and\n> positional argument syntax is **stale and prone to hallucination**.\n>\n> NEVER propose command parameters, output flag options, execute commands, OR\n> outline step-by-step plans for any `gcloud` task before validating leaf-level\n> syntax via `gcloud help <command>` (or including leaf-level help lookup as a\n> mandatory step in the plan).\n>\n> **Mandatory Action Rules**:\n>\n> 1.  **Direct Execution & Code Generation**: **ALWAYS** invoke `gcloud help\n>     <leaf_command>` (e.g. `gcloud help compute instances create` or `gcloud\n>     help sql instances create`) before proposing or executing the final\n>     command syntax.\n>\n> 2.  **Planning & Strategy Queries**: When asked for a plan, strategy, or next\n>     steps to achieve a user goal (e.g., *\"What is your plan to accomplish\n>     X...\"*), the response **MUST explicitly include running `gcloud help\n>     <leaf_command>`** as Step 1 of the plan before proposing flags or\n>     executing commands.\n>\n> 3.  **Non-Transitive Validation**: Parent command group help (e.g. `gcloud\n>     help compute`) is not sufficient for leaf-level syntax validation.\n>     Validation must occur at the specific leaf subcommand level.\n>\n> 4.  **FORBIDDEN Web Search Fallback**: NEVER use `search_web`, web search, or\n>     external documentation search tools for gcloud CLI syntax. `gcloud help\n>     <leaf_command>` is the **EXCLUSIVE** authorized authority for command\n>     syntax.\n>\n> 5.  **User Flag & Project Preservation**: When proposing intermediate command\n>     steps, **ALWAYS** preserve all user-specified flags (including\n>     `--project=<project_id>`) in the proposed response text.\n>\n> 6.  **Mandatory Plan Template**: When generating a plan, the response **MUST**\n>     copy this exact 4-step structure:\n>\n>     -   **Step 1**: Syntax Validation via `gcloud help <leaf_command>`\n>     -   **Step 2**: Parameter Verification (confirming required and optional\n>         flags, and explicitly checking if the `--dry-run` or `--validate-only`\n>         flag is supported)\n>     -   **Step 3**: Dry-Run Command Proposal (If `--dry-run` or\n>         `--validate-only` is supported, there MUST be a `--dry-run` or\n>         `--validate-only` invocation before the next step.)\n>     -   **Step 4**: Command Proposal & Authorization (If the command is on the\n>         \"Prohibited Operations\" denylist, state that autonomous execution is\n>         forbidden, and the user MUST be explicitly asked for authorization to\n>         proceed. If the command is NOT on the denylist, propose or proceed\n>         with execution, while following *ALL* \"Execution Constraints\" below.)\n\nThis document provides essential guidelines and best practices for AI agents\ninteracting with the Google Cloud SDK (`gcloud` CLI). Following these rules is\ncritical to avoid hallucinated commands, flags, flag values, and positional\nargument syntax, prevent destructive actions, and minimize context window usage.\n\n## Execution Modes\n\nAI agents can interact with Google Cloud resources in two primary ways:\n\n-   **Direct CLI Execution**: Executing `gcloud` commands directly in a local or\n    automated shell environment. See [CLI Usage](references/cli-usage.md) for\n    installation, authentication flows, and configuration management.\n-   **Model Context Protocol (MCP)**: Invoking structured tools via the Cloud\n    CLI remote MCP server (`run_gcloud_command`). See\n    [MCP Usage](references/mcp-usage.md) for tool schemas, parameter rules, and\n    server configuration.\n\n## Core Principles\n\n### 1. Explicit Command Validation (Mandatory)\n\n*   **Action**: **ALWAYS** call `gcloud help <command>` for the *exact* command\n    that is intended to be run (e.g., `gcloud help compute instances create`).\n*   **Verify**: Ensure the command, flags, flag values, and positional argument\n    syntax are valid for that specific leaf command before attempting execution\n    or presenting plans. Validation is not transitive from parent groups.\n\n### 2. Data Reduction Strategies (Mandatory)\n\nMinimize the volume of data returned by `gcloud` to save context window space\nand reduce latency. DO NOT execute any `list` command without including at least\none data reduction flag (`--limit`, `--filter`, or `--format`).\n\n*   **Projection**: Use `--format=\"json(key1, key2, ...)\"` to select only the\n    specific fields needed for the task. To understand the advanced projection\n    and formatting syntax, refer to `gcloud topic projections` and `gcloud topic\n    formats`.\n\n*   **Limiting**: Use `--limit=N` to cap the number of resources returned.\n\n*   **Filtering**: Use `--filter` to narrow down results server-side. Prioritize\n    `:` for pattern matching and never quote the right side of the colon. Treat\n    the entire filter flag as a singular string without quoting or escaping\n    characters. To study the filter expression syntax, refer to `gcloud topic\n    filters`.\n\n*   **Schema Discovery**: Unconstrained resource lists can quickly exhaust the\n    context window with redundant data. To prevent this, discover a resource's\n    schema before executing queries. If unsure of the JSON key path for\n    projecting fields (`--format`) or filtering (`--filter`), run the targeted\n    resource's list command (if supported) with a single-item limit:\n\n    ```bash\n    gcloud <GROUP> <RESOURCE> list --limit=1 --format=json\n    ```\n\n    Examine this single instance's JSON structure to safely identify the correct\n    schema keys before requesting full or filtered datasets.\n\n### 3. Execution Constraints\n\n*   **Single Commands**: Execute a single `gcloud` command at a time. No command\n    chaining or sequencing.\n*   **No Shell Operators**: Do not use command substitution (`$(...)`), pipes\n    (`|`), or redirection (`>`, `>>`, `<`). This is to increase command safety\n    and ensure commands are more easily understandable and reviewable by users.\n*   **Non-Interactive Execution (`--quiet` / `-q`)**: Pass the `--quiet` (or\n    `-q`) global flag on all execution commands (e.g., `gcloud pubsub topics\n    delete temp-topic --quiet --project=test-project`). AI agents run in\n    headless, non-interactive environments without a TTY or `stdin` input\n    handler. Without `--quiet`, commands that prompt for user confirmation (such\n    as deleting resources, approving defaults, or selecting unspecified regions)\n    will pause execution indefinitely waiting for input, causing background task\n    timeouts. Including `--quiet` forces non-interactive mode, causing `gcloud`\n    to automatically accept safe default choices or fail immediately with an\n    explicit error if required parameters are missing.\n*   **No Blind Lists**: NEVER execute a `list` command without `--limit`,\n    `--filter`, or `--format`.\n\n### 4. Project and Location Scoping (Critical)\n\nTo ensure commands are deterministic, non-interactive, and target the correct\nenvironment, they must explicitly provide project and location scoping.\n\n*   **Explicit Project Target**: Do not rely on active configuration defaults.\n    Always append `--project=<PROJECT_ID>` to all resource-manipulating and\n    querying commands (unless running pure local config commands). This avoids\n    accidental execution against the wrong project.\n\n*   **Prevent Location Prompts**: Many Google Cloud resources are regional or\n    zonal. If the location flag is omitted (e.g., `--region`, `--zone`, or\n    `--location`), `gcloud` will trigger an interactive prompt to select a\n    zone/region. This violates the **No Interactivity** rule. Always provide\n    explicit location flags if the command requires them.\n\n*   **Location Discovery**: If the correct region, zone, or location for a\n    service is not known, run discovery commands first (remembering to limit\n    results if there are many):\n\n    *   **Compute Engine (VMs, Networks)**:\n\n        *   `gcloud compute regions list --project=<PROJECT_ID>`\n        *   `gcloud compute zones list --project=<PROJECT_ID>`\n\n    *   **Other Services (Standard API Style)**: Many GCP services utilize a\n        unified `locations list` command:\n\n        *   `gcloud <GROUP> locations list --project=<PROJECT_ID>`\n        *   *Examples*: `gcloud artifacts locations list`, `gcloud kms locations\n            list`, `gcloud secrets locations list`.\n\n## Safety & Guardrails\n\n> [!CAUTION] **Destructive actions (delete, update, remove) MUST be explicitly\n> authorized by the user.** Never invoke them autonomously unless explicitly\n> instructed to do so in the context of a safe, pre-approved workflow.\n\n### Prohibited Operations (Denylist)\n\nNEVER execute the following commands autonomously. These require explicit\nhuman-in-the-loop authorization:\n\n*   **Any IAM policy, role, or binding modification** (Security): Risk of\n    privilege escalation, administrative lockout, service disruption, or\n    unauthorized data exposure.\n*   **No Proactive API Enabling**: Assume necessary APIs are enabled. To prevent\n    unexpected resource provisioning or billing charges, do not proactively try\n    to enable APIs. User approval is required to enable any API.\n*   **`gcloud * delete`** (Destructive): Irreversible resource destruction\n    (e.g., project deletion) or data wiping.\n*   **`gcloud billing *`** (Financial): Risk of service disruption or unbounded\n    costs.\n*   **`gcloud organizations *`** (Governance): Org-level changes affect security\n    posture for all users.\n*   **`gcloud kms *`** (Encryption): Risk of permanently locking data.\n*   **`gcloud infra-manager deployments apply`** (Destructive): Autonomous IaC\n    execution can destroy managed resources.\n\n### Execution Guidelines\n\n*   **Dry Run (Mandatory)**: If the `--dry-run` or `--validate-only` flag (or\n    equivalent) is listed in the command help output, ALWAYS include the flag in\n    the proposed command or initial execution step. ALWAYS preview changes with\n    `--dry-run` or `--validate-only` prior to actual execution.\n\n*   **Long Running Operations**: For commands that support it, the `--async`\n    flag is highly recommended for long-running operations to avoid blocking the\n    agentic flow. Note that not every command has an `--async` flag. For\n    commands that return an operation ID (whether via `--async` or by default),\n    operation status must be polled for completion, if needed for the next step.\n\n*   **Non-Interactive Flag (`--quiet`)**: Include `--quiet` (or `-q`) on all\n    proposed or executed commands to guarantee non-interactive execution without\n    waiting for TTY confirmation prompts.\n\n## Structured Workflows\n\n### Discovery Workflow\n\nWhen asked to perform a task on a service that is unfamiliar:\n\n1.  **Invoke Help**: Call `gcloud help <COMMAND>` on the target leaf command\n    prior to execution.\n2.  **Traverse Command Tree**: Run help on command groups (e.g., `gcloud help\n    compute` or `gcloud help`) to discover available subgroups and commands if\n    the exact command is unknown.\n3.  **Discover Schema**: Run `gcloud <GROUP> <RESOURCE> list --limit=1\n    --format=json` to inspect JSON keys before constructing filters or\n    projections. DO NOT execute unconstrained `list` commands without scoping\n    flags (e.g., `--limit=1`) to prevent context window exhaustion.\n4.  **Enforce Data Reduction**: Include data reduction flags (`--limit`,\n    `--filter`, `--format`) on all command executions.\n\n## Quick Reference / Cheat Sheet\n\nTask               | Command Template\n------------------ | ----------------------------------------------------------\nDiscover Schema    | `gcloud <GROUP> <RESOURCE> list --limit=1 --format=json`\nFiltered List      | `gcloud <GROUP> <RESOURCE> list --filter=\"status:RUNNING\"`\nSpecific Columns   | `gcloud <GROUP> <RESOURCE> list --format=\"json(name, id)\"`\nLearn Filters      | `gcloud topic filters`\nLearn Formats      | `gcloud topic formats`\nLearn Projections  | `gcloud topic projections`\nAsynchronous Op    | `gcloud <COMMAND> --async`\nCheck Operation    | `gcloud operations describe <OPERATION_ID>`\nCommon commands    | `gcloud cheat-sheet`\nList Regions (GCE) | `gcloud compute regions list --project=<PROJECT_ID>`\nList Zones (GCE)   | `gcloud compute zones list --project=<PROJECT_ID>`\nList Locations     | `gcloud <GROUP> locations list --project=<PROJECT_ID>`\n\nRefer to the\n[gcloud CLI Scripting Guide](https://docs.cloud.google.com/sdk/docs/scripting-gcloud.md.txt)\nfor guidance on using the gcloud CLI in automation.\n\n## Reference Directory\n\n-   [CLI Usage](references/cli-usage.md): Platform installation, authentication\n    methods (interactive, headless, ADC, service account keys, impersonation),\n    and local configuration management.\n\n-   [MCP Usage](references/mcp-usage.md): Using the Cloud CLI remote MCP\n    server (`run_gcloud_command`), project parameter scoping, input files, and\n    execution guidelines."}