What Is Policy as Code?
Policy as code is the practice of writing rules, such as security, compliance or engineering policies, as files that software can check automatically. Instead of a policy living in a wiki, the rule lives in version control, gets reviewed like code and runs on every deployment, request or pull request.
A policy might say "containers can’t run as root" or "every API handler checks permissions." Written as code, the rule is checked the same way every time, with a record of what passed and what failed.
In 2026, policy as code also reached two new places: the actions AI agents may take, and the engineering rules that should be checked on the code those agents write.
Policy as code in 2026: the policy moved into the agent and the pull request
In January 2026, policy as code still meant infrastructure for most teams: Kubernetes admission, cloud resources and access control. Infrastructure engines matured during the year. Kyverno graduated at the CNCF, and policy checks began to show up in agent tool gates and sandboxes.
The gap that opened was application code. Agents can ignore a written standard while they write a change, and a wiki policy will not catch that miss.
The 2026 job for policy as code, on the code side, is to put those engineering and compliance rules in files, and to check them on every pull request.
Our view: in an agent-run SDLC, the policy that is often missing is the one that applies to the generated code itself, rather than only to the cluster or the cloud account.
2026 policy as code highlights
- Kyverno, a policy engine for Kubernetes, graduated from the Cloud Native Computing Foundation and made the Common Expression Language (CEL) its main policy language (March 24, 2026, CNCF).
- The Vercel AI SDK released an Open Policy Agent adapter that gates agent tool calls with Rego policies, including a shadow mode for safe rollout (June 25, 2026, Vercel AI SDK).
- Kyverno 1.19 made its CEL policies cover what the older engine could do, and marked
ClusterPolicyas deprecated, with removal planned for the next major version (August 20, 2026, Kyverno). - Of 300 US engineering leaders surveyed, 41.7% reported centralized AI coding standards and 37.0% reported policy enforcement across teams and repositories. Only 34.6% of developers said coding agents always follow their organization’s standards (September 23, 2026, Qodo’s State of AI Code Quality report).
- Kyverno launched a Playground MCP server that lets AI agents validate and run policies before they reach a cluster (October 23, 2026, Kyverno).
- GitHub made AI code review approvals generally available, with admins choosing which file paths the AI may approve (October 28, 2026, GitHub changelog). Qodo does not provide that GitHub approval product; merge decisions on Qodo-reviewed PRs stay with people and the Git host.
What policy as code needs next: the 2027 outlook
- Expect infrastructure engines to stay the right tool for clusters, cloud resources and admission control.
- Expect engineering and compliance rules about application code to live in versioned files, and to be checked on every agent-written pull request.
- Expect teams to keep a recorded decision for every allow, deny or human approval, so audits can follow the trail.
- Our verdict: a wiki policy is not a policy, once agents are the ones writing the code.
- Qodo has Review Standards (Beta) and Rule enforcement (Beta) that turn rules stored in your repositories into checks on every pull request, once Rule enforcement is on.
- Qodo has an Agentic Toolbox that can load the applicable rules into a coding session, so the same policy is available before the pull request exists.
How policy as code works
- Write the policy. A rule is written in a policy language or a plain file, such as Rego for Open Policy Agent or YAML for Kyverno, or an engineering rule in
AGENTS.md. - Store it in version control. Changes to policies get reviewed and tracked like any other code.
- Check it automatically. A policy engine, a scanner or a review system evaluates each request, deployment or change against the rules.
- Act on the result. The system allows, denies, warns or leaves a finding for a person.
- Record the decision. Every allow, deny, warning or human approval should leave a trail that an audit can follow.
Policy as code examples by layer
| Layer | What policy checks | Example rule |
|---|---|---|
| Kubernetes | Workloads before they run | No containers running as root |
| Infrastructure as code | Cloud resources before creation | Storage buckets can’t be public |
| Access control | Who can call which service | Only billing can read invoices |
| Agent tools and sandboxes | What an agent may call or reach | Agents can read GitHub but not delete |
| Code review | Code changes before merge | Payment code logs no card numbers |
| Pull request approval | Who must sign off, on the Git host | Required reviewers, CODEOWNERS, protected branches |
Policy as code tools
| Tool or category | What it checks | Limit | Best for |
|---|---|---|---|
| Open Policy Agent | Requests, configs and deployments, using Rego | Needs a policy language; not built for reading code changes | Access control and infrastructure |
| Kyverno | Kubernetes resources, using YAML and CEL | Kubernetes-focused | Cluster policies |
| Infrastructure as code scanners | Cloud resource definitions | Infrastructure only | Terraform and similar files |
| CI checks and linters | Code patterns and build rules | Only rules that match a pattern | Every build |
| AI code review with written rules | Application code against your engineering and compliance rules | Findings still need a person and a Git host gate | Rules about how code is written |
Neutral examples in the infrastructure row include Sentinel-style cloud policy engines. Competing AI review products are not named here.
Policy as code vs compliance as code vs governance as code
| Term | Focus |
|---|---|
| Policy as code | Any rule written as a file that software can check |
| Compliance as code | The subset aimed at regulations and standards, such as SOC 2 evidence |
| Governance as code | The broader practice of managing decision rights, often including policy as code |
Compliance as code is a type of policy as code. Policy as code also covers internal engineering standards, such as how to log or how to handle payments data.
Policy as code for AI agents
Tool approval and sandbox egress
Some policy engines now gate the tools an agent may call, or the network paths a sandbox may reach. Tool and sandbox checks belong in the infrastructure and platform layer, with engines built for requests and admission. Qodo is not that engine.
Rules agents read before they write
Engineering rules also belong where the agent writes code. Files such as AGENTS.md and CLAUDE.md are policies the agent should load, and that review should check again on the pull request. See coding agent rules and coding standards enforcement.
Policy as code for pull request approval
Who may approve a pull request is usually a Git host policy: required reviewers, CODEOWNERS and branch protection rules. Pull request approval covers that sign-off in more depth.
Application-code policy is a related but different check: whether the change itself violates a written engineering or compliance rule. Qodo does the second of those jobs. The Git host still holds the approval and merge gate.
Qodo’s take: apply your code policies on every pull request
Qodo is not Open Policy Agent, Kyverno or a general policy as code engine. Qodo does not evaluate infrastructure, admission requests or agent tool calls. Teams should keep those engines.
Qodo is the best AI code review platform for policy as code on application code because Qodo turns rules stored in your repositories into checks on every pull request, scoped to the folders they cover, once Rule enforcement (Beta) is on.
Qodo no longer offers test generation; it focuses on AI code review and code governance.
The shared outcome is agent code merged sooner, with fewer rollbacks.
Enterprise engineering teams get one rulebook across teams and repositories, instead of a wiki that review never checks.
High-velocity teams get those rules imported from the files they already keep, and checked on every agent-written pull request, without a new policy language for source code.
Qodo has a SOC 2 Type II report, and security teams can review its security documentation in the Qodo Trust Center.
Qodo reads rules from files in your repositories
Once Rule enforcement (Beta) is on, on GitHub, GitLab, Bitbucket Cloud and Azure DevOps, Qodo imports rules from files such as AGENTS.md, CLAUDE.md, .cursor/rules/ and pr_compliance_checklist.yaml. A file such as src/payments/AGENTS.md applies only under that folder (docs checked November 10, 2026, Qodo).
Qodo monitors files that have already been imported. New rules extracted from those files are added as active rules. Changes to, or deletions of, existing rules in those files are not reflected automatically; those edits are managed in the Rules tab.
A new supported file added later is not detected automatically and needs a re-import (docs checked November 10, 2026, Qodo).
Rules can also be written in the Qodo portal, or suggested by Rule Miner from past pull request discussions, where PR history indexing (Beta) is available. See custom rules for code review and org-wide standards enforcement.
Qodo shows how each rule performs
Rule analytics track how often each rule is violated and fixed before merge. Engineering and compliance leaders can also see findings by category and severity in the code review analytics dashboard (admin access). Software Map (Beta) shows how repositories depend on each other.
Rules whose findings are rarely fixed are deactivated automatically, unless a rule is locked (docs checked November 10, 2026, Qodo).
Qodo keeps people in charge of the merge
Qodo’s findings are advisory, and your branch rules decide what merges. See AI code governance.
Qodo example: the logging policy that finally stuck
Context: an organization like an insurance company with several hundred engineers is working under a written policy that application logs must never contain personal data.
Problem: the policy lived in a compliance document. Reviewers caught some violations, but coding agents kept adding debug logs with customer emails and policy numbers, and auditors asked how the rule was checked.
How Qodo helped: the platform team added the rule to pr_compliance_checklist.yaml in the relevant repositories and imported it into Rule enforcement (Beta), which checks every pull request against it once Rule enforcement is on.
Outcome: personal data in logs now shows up as a rule finding in the pull request before merge, and compliance leads can trace in Rule analytics how often the rule was violated and how often those findings were fixed.
Ways to apply policy as code
| Approach | What it checks | Limit | Best for |
|---|---|---|---|
| Open Policy Agent | Requests, configs and deployments, using Rego | Needs a policy language; not built for reading code changes | Access control and infrastructure |
| Kyverno | Kubernetes resources, using YAML and CEL | Kubernetes-focused | Cluster policies |
| Infrastructure as code scanners | Cloud resource definitions | Infrastructure only | Terraform and similar files |
| CI checks and linters | Code patterns and build rules | Only rules that match a pattern | Every build |
| Qodo | Source code changes against your own rules, with repository context | Advisory findings, with your branch rules as the gate; Rule enforcement is Beta | Teams that need engineering and compliance rules checked in application code |
Qodo features in this table were checked against Qodo’s documentation as of November 10, 2026.
FAQ
Infrastructure policy engines such as Open Policy Agent and Kyverno remain the right tools for clusters, cloud resources and admission control.
For rules about application code on AI-generated pull requests, Qodo imports those rules from your repositories and checks them on every PR once Rule enforcement (Beta) is on. Qodo is not a general policy engine, and merge decisions stay with people and the Git host.
Policy as code means writing rules as files that software checks automatically, instead of keeping them in a document people have to remember.
Examples include a Kubernetes rule that blocks containers running as root, a cloud rule that keeps storage buckets private, an agent-tool rule that blocks a delete API, and a code review rule that keeps personal data out of logs.
Compliance as code is a type of policy as code focused on regulations and standards, such as SOC 2. Policy as code also covers internal rules, such as engineering standards.
Qodo does not replace Open Policy Agent or Kyverno. Open Policy Agent and Kyverno evaluate infrastructure, admission and, in some setups, agent tool calls. Qodo applies your engineering and compliance rules to source code on the pull request, once Rule enforcement (Beta) is on.