devops-policy-as-code
Use when the user asks to enforce admission policies with OPA Gatekeeper, Rego, Kyverno, ValidatingAdmissionPolicy (CEL), conftest or opa test, mutation…
от j4flmao★ 47 звёзд на GitHub
Установить devops-policy-as-code в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Policy as Code
Purpose
Implement policy as code using OPA/Rego and Kyverno: write admission policies, enforce guardrails, validate configurations, and automate compliance checks in Kubernetes and cloud environments. Covers mutating and validating policies, constraint templates, policy testing, CI/CD integration, and policy lifecycle management.
Agent Protocol
Trigger
Exact user phrases: "policy as code", "OPA", "Open Policy Agent", "Rego", "Gatekeeper", "Kyverno", "admission controller", "admission webhook", "conftest", "constraint template", "constraint", "policy enforcement", "guardrails", "compliance as code", "policy testing", "opa test", "validate", "mutate", "generate", "policy report", "background scan".
Input Context
- Existing policy tools (OPA, Kyverno, or none)
- Cluster/environment (Kubernetes, Terraform, CI/CD)
- Compliance requirements (PCI, SOC2, HIPAA, internal)
- Team structure and policy ownership
- Existing policy rules (if any, to migrate)
Output Artifact
Policy definitions (Rego files, Kyverno YAML, Gatekeeper constraints), policy tests, CI/CD integration scripts, and policy reporting configuration.
Response Format
Rego policy code, Kyverno ClusterPolicy YAML, constraint template YAML, or test files. No preamble. No postamble. No filler.
Completion Criteria
- Policy framework selected (OPA/Gatekeeper, Kyverno, or hybrid)
- Core security policies defined (privileged containers, host networking, resource limits)
- Compliance policies defined (labels, annotations, encryption, network policies)
- Mutation policies defined (default labels, sidecar injection, resource defaults)
- Policy tests written and passing
- CI/CD integration established (conftest for IaC, admission for K8s)
- Policy reporting and monitoring configured
- Policy lifecycle management defined (review cadence, versioning)
Architecture / Decision Trees
Policy Engine Decision Tree
What kind of policies?
Kubernetes admission only → Kyverno (K8s-native, YAML-based, or)
OPA Gatekeeper (Rego-based, more flexible)
Multi-platform (K8s + Terraform + CI/CD + API gateways) → OPA (broadest support)
Team familiarity with Rego?
Low/None → Kyverno (YAML policies, no new language)
Moderate/High → OPA/Gatekeeper (more expressive, steeper learning curve)
Mutation policies needed?
YES → Kyverno (native mutation support) or OPA with mutating webhook
NO → Both work well
Background scanning needed?
YES → Kyverno (built-in background scan, policy reports)
NO → Both work well
Multi-cluster federation?
YES → OPA Gatekeeper (constraint template distribution) or Kyverno with GitOps
NO → Either
Policy Categories
| Category | Examples | Engine | Priority |
|---|---|---|---|
| Security | No privileged containers, no hostNetwork, read-only root FS | Both | P0 |
| Security | Block insecure registries, enforce seccomp | Both | P1 |
| Compliance | Required labels, team annotations, cost center | Both | P1 |
| Operations | Require resource limits, probes, anti-affinity | Both | P2 |
| Operations | Default network policies, default deny ingress | Kyverno | P2 |
| Cost | Block expensive instance types, limit namespace quotas | Both | P2 |
| Governance | Enforce naming conventions, data classification labels | Both | P3 |
| Automation | Inject sidecars, add default tolerations | Kyverno | P3 |
Core Workflow
Step 1: OPA/Rego Policy Development
package kubernetes.admission
# Deny privileged containers
deny[msg] {
input.request.kind.kind == "Pod"
container := input.request.object.spec.containers[_]
container.securityContext.privileged == true
msg := sprintf("Container %v is privileged — not allowed", [container.name])
}
# Require resource limits on all containers
deny[msg] {
input.request.kind.kind == "Pod"
container := input.request.object.spec.containers[_]
not container.resources.limits
msg := sprintf("Container %v has no resource limits", [container.name])
}
# Block latest image tag
deny[msg] {
input.request.kind.kind == "Pod"
container := input.request.object.spec.containers[_]
endswith(container.image, ":latest")
msg := sprintf("Container %v uses latest tag: %v", [container.name, container.image])
}
# Require readOnlyRootFilesystem
deny[msg] {
input.request.kind.kind == "Pod"
container := input.request.object.spec.containers[_]
container.securityContext.readOnlyRootFilesystem != true
msg := sprintf("Container %v must have readOnlyRootFilesystem: true", [container.name])
}
# Block hostNetwork
deny[msg] {
input.request.kind.kind == "Pod"
input.request.object.spec.hostNetwork == true
msg := "Pod uses hostNetwork — not allowed"
}
# Require specific labels
deny[msg] {
input.request.kind.kind == "Pod"
required_labels := {"app.kubernetes.io/name", "app.kubernetes.io/instance", "owner"}
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/kyverno-policies.md
- references/opa-k8s-admission.md
- references/opa-policy-language.md
- references/opa-rego-terraform.md
- references/policy-as-code-advanced.md
- references/policy-as-code-fundamentals.md
- references/policy-ci-cd.md
- references/policy-testing.md
FAQ
Что делает скилл devops-policy-as-code?
Use when the user asks to enforce admission policies with OPA Gatekeeper, Rego, Kyverno, ValidatingAdmissionPolicy (CEL), conftest or opa test, mutation policies, or compliance as code in CI. Produces tested policies and CI enforcement. Not for compliance programs (use enterprise-compliance-audit) or RBAC/ABAC design (use abac-access-control).
Как установить скилл devops-policy-as-code?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл devops-policy-as-code запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…