Skip to main content
skill Claude Code Gemini CLI CX Codex official · Google

iam-helper-for-policy-simulator — Claude skill: test IAM changes

This skill replays recent access logs against a proposed IAM policy, so you see who loses access before the change goes live.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add google/skills --skill iam-helper-for-policy-simulator -a claude-code
Open on GitHub

What iam-helper-for-policy-simulator does

The skill walks the agent through a fixed sequence. It dumps the current IAM v1 (Allow) policy for a project, folder or organization into /tmp/current_policy.json, then builds /tmp/proposed_policy.json by editing the bindings array. A no-op check stops the run if nothing actually changed.

Next comes gcloud iam simulator replay-recent-access, which replays access history against the proposed policy. The results go through python3 scripts/analyze_simulation.py. A REVOKED_COUNT=0 means the change is safe and the agent asks for confirmation before applying it with gcloud projects set-iam-policy or the folder and organization equivalents. Anything above zero and the skill halts, naming the principals, permissions and resources that would break.

Safety gates are strict: an empty or partial policy fetch ends the workflow, a crashed simulator is never treated as safe, and temp files get deleted on every exit path. You need roles/policysimulator.admin, roles/cloudasset.viewer and IAM admin roles on the target resource. It does not cover IAM v2 deny policies or VPC Service Controls, so skip it for those.

What it helps with

  • check whether a role removal breaks a running service account
  • compare a proposed policy against the current one and drop empty edits
  • list the principals and permissions that would lose access
  • apply an IAM policy only after a clean simulation
  • clean up temp policy files between runs

Example prompts for the agent

  • Simulate removing roles/editor from this service account in the project
  • Replay recent access for adding roles/viewer to a group in folder TARGET_FOLDER_ID
  • Run the simulation for the organization and show me which accesses break

How to install iam-helper-for-policy-simulator

1Skills CLI (Vercel)

npx skills add google/skills --skill iam-helper-for-policy-simulator -a claude-code

2Manually: put the files in place

~/.claude/skills/iam-helper-for-policy-simulator/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/iam-helper-for-policy-simulator/

From the same set172

The whole set →
bigquery-basics official google Manages BigQuery resources and runs SQL queries. Use it to create datasets, tables and views, or handle basic data ingestion and analysis. Claude Code Gemini CLI CX Codex 17,678installs cloud-run-basics official google This skill helps an agent manage Cloud Run services, jobs, and worker pools when a project needs HTTP deployment, scheduled work, or pull-based background processing. Claude Code Gemini CLI CX Codex 17,532installs gemini-api official google Connects Gemini API from Google Cloud Agent Platform to the agent. Gives access to Gemini models, multimodal input, function calling, and context caching. Claude Code Gemini CLI CX Codex 17,116installs google-cloud-recipe-auth official Google LLC This skill explains Google Cloud authentication and permissions. Use it when setting up IAM, ADC, or service accounts for local code and production workloads. Claude Code Gemini CLI CX Codex 15,450installs google-cloud-recipe-onboarding official Google LLC Guides a developer through a first Google Cloud project: CLI checks, sign-in, project setup and billing. It fits a personal first project. Claude Code Gemini CLI CX Codex 15,390installs cloud-sql-basics official google This skill helps create and explain Cloud SQL resources for MySQL, PostgreSQL, and SQL Server. Use it when setting up a database in Google Cloud. Claude Code Gemini CLI CX Codex 14,679installs google-cloud-waf-security official google This skill reviews Google Cloud workloads against the security pillar of the Well-Architected Framework and suggests actions for IAM, networks, data, and operations. Claude Code Gemini CLI CX Codex 14,620installs google-cloud-waf-cost-optimization official google Reviews Google Cloud workloads through the Well-Architected Cost Optimization pillar. Use it to inspect spending, resize resources, assess discounts, or find idle capacity. Claude Code Gemini CLI CX Codex 14,266installs

Similar

protocol-reverse-engineering Dávid Balatoni This skill helps inspect network traffic, map protocol structures, and write protocol documentation. Use it for proprietary protocol analysis or network debugging. Claude Code CX Codex Cursor 12,701installs secret-scanning official github This skill guides GitHub secret scanning, push protection, custom patterns, and alert remediation. Use it when a repository needs secret checks before commits or pushes. GitHub Copilot 4,600installs memory-safety-patterns Seth Hobson This skill applies ownership, RAII, smart pointers, and resource management to Rust, C++, and C. Use it for systems code or memory-bug debugging. Claude Code CX Codex Cursor 11,746installs kubernetes-specialist https://github.com/Jeffallan This skill helps create and validate Kubernetes manifests, set workload security, and troubleshoot failing pods. Use it for deployment and cluster operations. Claude Code CX Codex Cursor +1 14,100installs dependabot official github A GitHub Copilot skill that helps write and tune .github/dependabot.yml: grouped updates, monorepo patterns, security updates. GitHub Copilot 4,400installs git-guardrails-claude-code Matt Pocock This skill adds a Claude Code hook that stops risky Git commands before they run. Use it when an agent must not push or discard working-tree changes. Claude Code 499,069installs ponytail-review DietrichGebert ponytail-review reviews a change beyond the diff, checking connected code, bugs, risks, load, tests, speed, and unnecessary code. Use it for PRs and commits. Claude Code CX Codex Cursor +1 56,300installs ponytail-audit DietrichGebert It audits a repository and ranks bugs, risks, and redundant code in a one-shot report. Use it when you need a review without code changes. Claude Code CX Codex Cursor +1 44,800installs

Questions about iam-helper-for-policy-simulator

How do I install iam-helper-for-policy-simulator in Claude?

Run npx skills add google/skills --skill iam-helper-for-policy-simulator -a claude-code. The skill lands at ~/.claude/skills/iam-helper-for-policy-simulator/SKILL.md.

What does iam-helper-for-policy-simulator do?

It simulates an IAM v1 Allow policy change against access history and applies the edit only when the simulation shows no breakage.

What permissions does the skill need?

roles/policysimulator.admin, roles/cloudasset.viewer, plus IAM admin roles on the project, folder or organization you are editing.

Source text

SKILL.md · Apache-2.0
---
name: iam-helper-for-policy-simulator
description: >-
  Safely simulates and applies Identity and Access Management (IAM) v1 (Allow)
  policy changes on Google Cloud.
  Uses the Policy Simulator to replay historical access logs against proposed policies
  to prevent breaking active workloads before applying the changes. Use when
  simulating or applying IAM v1 allow policies across Projects, Folders, or Organizations.
  Don't use for analyzing IAM v2 deny policies, VPC Service Controls, or performing
  general policy troubleshooting.
metadata:
  version: "1.0.2"
  category: Security
---

# IAM Policy Simulator (v1 Allow)

You are an advanced security assistant helping users safely modify IAM
policies. You must NEVER apply a modifying policy change without first
running a Policy Simulation to ensure existing workloads are not disrupted. You
must only use standard public gcloud commands.

## Usage Attribution

**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
MUST read and follow the instructions in
[Usage Attribution](references/attribution.md).

## Core Concepts & Prerequisites

*   **IAM v1 (Allow Policies)**: Specifies who has access (a role) to a
    resource.
*   **Policy Simulator**: Replays the last 90 days of access logs against a
    proposed policy to verify if any historical access would be blocked by the
    change.
*   **Required Permissions**: The execution environment must have
    `roles/policysimulator.admin`, `roles/cloudasset.viewer`, and the
    appropriate IAM Admin roles for the target resource.
*   **Resource Scope**: Changes can target Projects, Folders, or Organizations.

## Execution Workflow: Plan, Simulate, Analyze, Apply

### Step 1: Retrieve Current Policy (Plan)

Fetch the baseline IAM v1 policy for the target resource (Project, Folder, or
Organization) and save it to the `/tmp/` directory:

**For Projects:**

```bash
gcloud projects get-iam-policy TARGET_PROJECT_ID --format=json > /tmp/current_policy.json
```

**For Folders:**

```bash
gcloud resource-manager folders get-iam-policy TARGET_FOLDER_ID --format=json > /tmp/current_policy.json
```

**For Organizations:**

```bash
gcloud organizations get-iam-policy TARGET_ORG_ID --format=json > /tmp/current_policy.json
```

**CRUCIAL SAFETY GATE:** Verify that the policy was successfully retrieved. If
the command fails or the resulting JSON is empty, you MUST terminate the
workflow immediately and inform the user. Do not proceed to prepare or simulate
an empty or partial policy.

### Step 2: Prepare Proposed Policy

Create a `/tmp/proposed_policy.json` file. Modify `/tmp/current_policy.json` by
adding or removing role bindings in the `bindings` array to match the requested
change.

**CRUCIAL NO-OP CHECK:** Compare the proposed policy to the current policy. If
no changes were actually made (e.g., you are trying to remove a role the user
doesn't hold, or add a role they already have), you MUST inform the user that no
changes are necessary and **terminate the workflow immediately**. Do not run a
simulation.

### Step 3: Run Policy Simulation

Run the simulator to replay the last 90 days of access logs against the proposed
policy change. Execute the exact command for your resource type:

**For Projects:**

```bash
gcloud iam simulator replay-recent-access //cloudresourcemanager.googleapis.com/projects/TARGET_PROJECT_ID /tmp/proposed_policy.json --project=TARGET_PROJECT_ID --format=json > /tmp/simulation_results.json
```

**For Folders:**

```bash
gcloud iam simulator replay-recent-access //cloudresourcemanager.googleapis.com/folders/TARGET_FOLDER_ID /tmp/proposed_policy.json --format=json > /tmp/simulation_results.json
```

**For Organizations:**

```bash
gcloud iam simulator replay-recent-access //cloudresourcemanager.googleapis.com/organizations/TARGET_ORG_ID /tmp/proposed_policy.json --format=json > /tmp/simulation_results.json
```

*(Note: If the Policy Simulator API is not enabled, it will prompt you to enable
it. Select Yes. Do not use placeholders verbatim; replace TARGET_PROJECT_ID,
TARGET_FOLDER_ID, or TARGET_ORG_ID with the actual resource ID).*

**CRUCIAL SAFETY GATE:** Verify the command exited successfully. If the
simulator command crashes, times out, or returns a non-zero exit code, you MUST
NOT treat the failure as a "safe" result. Terminate the workflow immediately and
report the simulator failure to the user.

### Step 4: Analyze Simulation Results

Analyze the contents of `/tmp/simulation_results.json` using the provided helper
script. Do not write custom scripts on the fly. You MUST execute the following
command:

```bash
python3 scripts/analyze_simulation.py
```

*   **SAFE (No Breakage):** If the script outputs `REVOKED_COUNT=0`, the change
    is safe.
*   **UNSAFE (Breakage):** If the script outputs `REVOKED_COUNT` > 0 (meaning
    the logs contain `ACCESS_REVOKED` or `ACCESS_MAYBE_REVOKED`):
    *   Identify the `principal`, `permission`, and `fullResourceName` from the
        printed JSON.
    *   **Do NOT apply the policy.**
    *   The change will break an active workload. Inform the user of the
        specific disrupted accesses.

### Step 5: Apply Policy (Only if Safe)

If and only if the simulation in Step 4 was SAFE (No Breakage), prompt the user:
*"The simulation showed no disrupted access. Do you want to apply this policy
change? (Yes/No)"*.

*   **If Yes:** Apply the policy using the correct command for the resource
    type:

**For Projects:**

```bash
gcloud projects set-iam-policy TARGET_PROJECT_ID /tmp/proposed_policy.json
```

**For Folders:**

```bash
gcloud resource-manager folders set-iam-policy TARGET_FOLDER_ID /tmp/proposed_policy.json
```

**For Organizations:**

```bash
gcloud organizations set-iam-policy TARGET_ORG_ID /tmp/proposed_policy.json
```

*   **If No:** Terminate the workflow.

### Step 6: Cleanup (Always Run)

After applying the policy, declining the prompt, or terminating early due to a
NO-OP/failure, always delete the temporary files to prevent cross-contamination
in future runs:

```bash
rm -f /tmp/current_policy.json /tmp/proposed_policy.json /tmp/simulation_results.json
```

© google · Apache-2.0 · google/skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor