policy-as-code

policy-as-code is a skill for Claude Code, Codex from arjunprabhulal/devops-skills. It costs 110 tokens per session (1,275 once invoked), scanned A, original, MIT.

A way to write infrastructure and cluster rules as code so tools can check them automatically. Infrastructure is the cloud and server setup; a cluster is a group of managed machines, such as Kubernetes nodes.

In plain words
What is it for?
Use it to enforce requirements such as private storage buckets, check Terraform plans, validate Kubernetes admission requests, and write or test OPA, Sentinel, or Kyverno policies.
Why use it?
It can reject unsafe or non-compliant changes before they are applied instead of finding them later in an audit. The rules can also be tested like other code.

Skill for Claude CodeCodex

Part of the devops-skills plugin — 56 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/arjunprabhulal/devops-skills/policy-as-code
Any agent
npx skills add arjunprabhulal/devops-skills --skill policy-as-code
Clone the repo
git clone --depth 1 https://github.com/arjunprabhulal/devops-skills

Made for: Claude Code, Codex.

Or install devops-skills, the plugin that ships this one along with the rest of its 56 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for policy-as-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/arjunprabhulal/devops-skills/policy-as-code.svg)](https://agentmods.dev/skills/arjunprabhulal/devops-skills/policy-as-code)
Your own site
<a href="https://agentmods.dev/skills/arjunprabhulal/devops-skills/policy-as-code"><img src="https://agentmods.dev/badge/skills/arjunprabhulal/devops-skills/policy-as-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 110 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,275 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00110 $0.01275
Opus 5 $0.00055 $0.00638
Sonnet 5 $0.00022 $0.00255
Haiku 4.5 $0.00011 $0.00128

Measured 4d ago against content hash 965f99a33652, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

policy-as-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/iac/policy-as-code/SKILL.md · 111 lines

How it starts

The opening of the file, as written. The whole thing — 111 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Policy as Code

A wiki page that says "all S3 buckets must be private" prevents nothing — it's read once, if ever, and forgotten by the next person who copies an old module. A policy written as code and evaluated automatically against every plan or admission request prevents the violation from landing at all, regardless of who wrote the change or whether they read the wiki.

The shift this skill is about is from auditing infrastructure after the fact to rejecting bad infrastructure before it's ever applied. An audit finding is a cleanup task; a policy failure is a change that never happened.

A policy that only runs in a nightly audit report is a compliance artifact. A policy that blocks the pipeline is a guardrail. Prefer the guardrail.

For side-by-side Kyverno YAML policies and OPA Gatekeeper Rego constraint templates, read references/kyverno-and-rego.md.

1. Put the check where the change is still reversible

The cheapest place to reject a bad change is before it's ever applied — evaluate policy against the Terraform plan output or the Kubernetes admission request, not against resources that already exist. By the time a nightly scan finds a public bucket, it's been public for up to a day.

deny[msg] {
  input.resource_changes[_].change.after.acl == "public-read"
  msg := "S3 buckets must not be created with public-read ACL"
}
  • Gate the CI pipeline on the policy check, not just the merge review — a human reviewer misses what an automated check catches every time.
  • Fail the pipeline, don't just warn, once a policy is trusted — a warning nobody reads has the same effect as no policy.
  • Reserve runtime/admission-time enforcement for the things that slip through pre-merge, like changes applied outside the pipeline entirely.

Done when: a plan or manifest violating a written policy cannot be applied through the normal pipeline path, full stop.

2. Start every new policy in audit mode

A brand-new policy enforced immediately as a hard block will, with near certainty, break some legitimate change nobody anticipated when writing the rule — and the first thing anyone learns about the new policy is that it's an obstacle. Ship it as a warning first, watch what it flags against real traffic for a stretch, then flip it to enforcing.

Read the full file on GitHub · 111 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 111 lines · 110 tokens per session scan A 965f99a33652

Subscribe to this mod's changes

policy-as-code is a skill published in the GitHub repository arjunprabhulal/devops-skills (2 stars, last pushed 9d ago), licensed MIT. It adds 110 tokens to every session and 1,275 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

google-mobile-ads-android-migrate-to-next-gen

Migrates Android applications from the old, legacy Google Mobile Ads (GMA) SDK (com.google.android.gms:play-services-ads) to the new GMA Next-Gen SDK (com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk). Provides comprehensive mapping tables for imports, classes, and method signatures to help determine…

google/skills · 105 tokens

agent-platform-inference

Connects to and performs inference with Google Cloud Agent Platform GenAI models, including First-Party Gemini models and Third-Party OpenMaaS models (Llama, DeepSeek, Qwen, etc.). Use when asked to perform inference, ask a model a question, run a test prompt, execute chat completions, or generate code for calling…

google/skills · 144 tokens

agent-platform-deploy

Deploy open models or custom weights from Model Garden to Agent Platform endpoints, check the status of an in-progress deployment operation, or clean up resources by undeploying models and deleting endpoints. Use when asked to actively deploy a model, list the Model Garden CATALOG of available models, check if a…

google/skills · 193 tokens

agent-platform-eval-flywheel

Measures and improves the quality of AI models and agents on Google Cloud using the Eval Quality Flywheel methodology. Use when evaluating an agent or model, building an eval dataset, picking or writing evaluation metrics, analyzing failures, comparing results before and after a fix, or when guidance is needed on…

google/skills · 108 tokens

agent-platform-tuning

Agent Platform Model Tuning. Use when you need to fine-tune open models or Gemini models using Agent Platform infrastructure. Don't use for model training outside Agent Platform, model deployment to endpoints (use agent-platform-deploy), or managing serving endpoints (use agent-platform-endpoint-management).

google/skills · 64 tokens

agent-platform-alert-configuration

Configures best-practice alerting policies for AI agents using OpenTelemetry (OTel) metrics, generating output as Terraform (.tf) configuration files. Use when analyzing, writing, or deploying alerting policies to monitor agent latency, error rates, token usage, and quality metrics. Don't use for standard…

google/skills · 143 tokens