skills sourced live from GitHub · all skills listed are free · each skill is provided under its author's license.
home / DevOps / Policy As Code Skill by @BagelHole
The skill is the compliance/governance/policy-as-code folder inside that repository. Copy it into the folder your agent loads skills from; check your agent's documentation for where that is.
Implement policy as code with OPA, Sentinel, and Kyverno. Automate policy enforcement in CI/CD and infrastructure.
Enforces compliance through code using Open Policy Agent with Rego, Kyverno for Kubernetes and Checkov custom checks, then wires them into CI/CD. It also covers how to manage policy exceptions, which is where most real programmes struggle.
The original SKILL.md is organised into these sections:
Written and maintained by @BagelHole. It is published under the MIT license, which allows reuse with attribution. See the author profile. SkillDirectory does not claim authorship: this page adds our own review and links back to the original, and the skill's text belongs to its author.
# Policy as Code
Automate policy enforcement through code using OPA/Rego, Kyverno, Checkov, and CI/CD integration to prevent compliance violations before they reach production.
## When to Use
- Enforcing security and compliance policies on infrastructure-as-code changes
- Preventing misconfigured Kubernetes workloads from deploying
- Automating guardrails in CI/CD pipelines for Terraform, CloudFormation, or Helm
- Implementing organizational standards that must be consistently applied
- Replacing manual approval gates with automated policy checks
## Open Policy Agent (OPA) Rego Policies
```rego
# deny_public_s3.rego - Deny S3 buckets with public access
package terraform.aws.s3
import rego.v1
deny contains msg if {
resource := input.resource_changes[_]
resource.type == "aws_s3_bucket"
resource.change.after.acl == "public-read"
msg := sprintf(
"S3 bucket '%s' has public-read ACL. All buckets must be private. [Policy: no-public-s3]",
…
Excerpt only, quoted from the author's repository. Open the repository for the complete file.