opa-policies

opa-policies is a skill for Claude Code from sawrus/agent-guides. It costs 21 tokens per session (1,205 once invoked), scanned A, original, MIT.

Guidance for writing Kubernetes admission policies with Open Policy Agent (OPA), Gatekeeper, and Kyverno. These policies check or change resources before Kubernetes accepts them.

In plain words
What is it for?
Writing, testing, and debugging Gatekeeper ConstraintTemplates and Constraints or Kyverno policies that validate, mutate, or generate Kubernetes resources.
Why use it?
It helps enforce security rules, such as requiring containers not to run as root, and helps diagnose deployments blocked by those rules.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Writing, testing, and debugging Gatekeeper ConstraintTemplates and Constraints or Kyverno policies that validate, mutate, or generate Kubernetes resources.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sawrus/agent-guides/opa-policies
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.

Any agent
npx skills add sawrus/agent-guides --skill opa-policies
Clone the repo
git clone --depth 1 https://github.com/sawrus/agent-guides

Made for: Claude Code.

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 opa-policies

README.md
[![agentmods](https://agentmods.dev/badge/skills/sawrus/agent-guides/opa-policies/github.svg)](https://agentmods.dev/skills/sawrus/agent-guides/opa-policies)
Your own site
<a href="https://agentmods.dev/skills/sawrus/agent-guides/opa-policies"><img src="https://agentmods.dev/badge/skills/sawrus/agent-guides/opa-policies/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for opa-policies

Your own site · 80×15
<a href="https://agentmods.dev/skills/sawrus/agent-guides/opa-policies"><img src="https://agentmods.dev/badge/skills/sawrus/agent-guides/opa-policies.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 21 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,205 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00021 $0.01205
Opus 5 $0.00010 $0.00602
Sonnet 5 $0.00004 $0.00241
Haiku 4.5 $0.00002 $0.00120

Measured 11d ago against content hash 55d8c1c6f5e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

opa-policies 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 11d 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.

areas/devops/devsecops/skills/opa-policies/SKILL.md · 189 lines

How it starts

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

Skill: OPA Policies & Kyverno

Expertise: Gatekeeper ConstraintTemplates, Kyverno ClusterPolicies, validation + mutation + generation.

When to load

When writing admission policies, testing policy changes, or debugging policy-blocked deployments.

Gatekeeper: ConstraintTemplate + Constraint

# 1. ConstraintTemplate — defines the policy logic in Rego
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
  name: k8srequirenonroot
spec:
  crd:
    spec:
      names: { kind: K8sRequireNonRoot }
  targets:
    - target: admission.k8s.gatekeeper.sh
      rego: |
        package k8srequirenonroot

        violation[{"msg": msg}] {
          container := input.review.object.spec.containers[_]
          not container.securityContext.runAsNonRoot
          msg := sprintf("Container '%v' must set runAsNonRoot: true", [container.name])
        }

        violation[{"msg": msg}] {
          container := input.review.object.spec.containers[_]
          container.securityContext.runAsUser == 0
          msg := sprintf("Container '%v' must not run as UID 0", [container.name])
        }

---
# 2. Constraint — applies the template to specific resources/namespaces
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequireNonRoot
metadata:
  name: require-non-root-production
spec:
  enforcementAction: deny           # deny | warn | dryrun
  match:
    kinds:
      - apiGroups: [apps]
        kinds: [Deployment, StatefulSet, DaemonSet]
    namespaceSelector:
      matchExpressions:
        - key: environment
          operator: In
          values: [production, staging]

Gatekeeper: Require Image Digest

apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
  name: k8srequireimagedigest
spec:
  crd:
    spec:
      names: { kind: K8sRequireImageDigest }
  targets:
    - target: admission.k8s.gatekeeper.sh
      rego: |
        package k8srequireimagedigest

        violation[{"msg": msg}] {
          container := input.review.object.spec.containers[_]
          not contains(container.image, "@sha256:")
          msg := sprintf(
            "Container '%v' image '%v' must reference a digest (@sha256:...), not a mutable tag",
            [container.name, container.image]
          )
        }

Read the full file on GitHub · 189 lines

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. 11d ago First seen · 189 lines · 21 tokens per session scan A 55d8c1c6f5e5

Subscribe to this mod's changes

opa-policies is a skill published in the GitHub repository sawrus/agent-guides (17 stars, last pushed 10d ago), licensed MIT. It adds 21 tokens to every session and 1,205 once invoked, about $0.0001 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-30.