---
title: "Agent skill for writing authorization policies"
description: "Writing authorization policies from a blank file is slow. The Cerbos agent skill handles the drafting for you, asking clarifying questions in plain English before generating a full Cerbos policy bundle with schemas, roles, resource policies, and tests. Works with Claude Code, Cursor, Codex, and more."
author: "Alex Olivier"
date: "2026-04-21T12:13:00.000Z"
canonical: "https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies"
image: "https://stylish-appliance-1c1cc1c30d.media.strapiapp.com/Cerbos_now_has_an_agent_skill_for_writing_authorization_policies_5_d3cb4c33a8.png"
tags: ["engineering","documentation","guide"]
source: "https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies"
---

# Agent skill for writing authorization policies

Writing authorization policies has always been the bit I wanted to make easier. The [Cerbos](https://www.cerbos.dev/) policy language is expressive, the CEL conditions are powerful, but there's still a learning curve when you're staring at a blank file trying to model your access control requirements.

So we built a skill that does it for you: https://github.com/cerbos/skills

<p>&nbsp;</p>

## What it actually does

You describe what you need in plain English. "Editors can update posts in their own department. Admins can do everything. Viewers are read-only except they can't see salary data." That kind of thing.

The skill asks you clarifying questions until it has a clear picture of your resources, roles, actions, and conditions. It'll also push back on things that seem too broad. Say "admins can do everything" and it'll ask whether admins really need delete access, or whether you want an explicit list of actions. 5 years of helping teams model their authorization has taught us that the vague requirements are where security holes hide, so the skill steers you toward least-privilege and explicit deny-by-default from the start.

Once it has a clear spec, it generates everything in one pass: schemas, derived roles, resource policies, test fixtures, and test suites. The generated policies follow patterns we've seen work across hundreds of production deployments. Things like scoping derived roles tightly, using attribute conditions instead of role proliferation, and structuring tests to cover both the allowed and denied paths.

Once the files are written, it runs `cerbos compile` via Docker to validate the whole bundle. If something fails (and sometimes it does), the skill reads the errors and fixes them. It keeps iterating until the compiler is happy or it's tried 3 different fixes for the same problem, at which point it tells you what's wrong and lets you take over.

<p>&nbsp;</p>

## The workflow

There are 5 phases, and the skill follows them in order:

1. **Spec intake.** Asks questions in plain business language ("who can delete a project?") until roles, resources, actions, and conditions are nailed down. Nudges you toward zero trust principles along the way: explicit permissions over implicit ones, narrow scopes over broad grants. Produces a short spec and confirms it with you before writing anything.  
     
2. **Write.** Generates all files in a single batch: schemas first, then derived roles and shared variables, then policies, then test data and test suites. Every generated policy follows the same patterns we use internally and recommend to customers. No wildcard actions, no overly permissive defaults, conditions on every rule that needs them.  
     
3. **Validate.** Runs `docker run --rm -v "$(pwd):/policies" ghcr.io/cerbos/cerbos:latest compile /policies` and check for any errors.  
     
4. **Fix.** If validation fails, it works through errors in priority order: YAML syntax, schema validation, compile errors, then test failures. One fix per iteration. Never deletes a test to make things pass (that rule is in there because I know how tempting it is).  
     
5. **Finalize.** Reports what was created and flags any assumptions it made along the way.

<p>&nbsp;</p>

## What you get

A complete policy bundle ready to drop into your Cerbos PDP:

- `_schemas/` with your principal and resource attribute schemas  
- `derived_roles/` with shared role definitions and exported variables  
- `resource_policies/` (or `role_policies/`) with your actual authorization rules  
- `testdata/` with fixtures and test suites that exercise your policies

<p>&nbsp;</p>

## Install it

Works with Claude Code, Cursor, Codex, OpenCode, and a bunch of other agents.

```shell
npx skills add cerbos/skills --skill cerbos-policy
```

If you're using Claude Code directly:

```shell
claude plugin marketplace add cerbos/skills
```

The repo is at [github.com/cerbos/skills](https://github.com/cerbos/skills).

<p>&nbsp;</p>

## Why we built this

Cerbos policies are code. They live in your repo, they're version controlled, they're testable. That makes them a natural fit for AI coding agents that already live in your editor and understand your codebase.

The tricky part was getting the output right. Authorization policies have sharp edges. A missing condition or a wrong role binding and you've got a security hole. So we packed the skill with the full Cerbos reference material (policy schemas, CEL patterns, testing recipes) and wired it to always validate against the real compiler. The agent doesn't just generate YAML and hope for the best. It proves the policies compile.

We also baked in 5 years of learnings from working with teams building authorization. Every recommendation the skill makes, from how it structures derived roles to how it models attribute conditions to how it generates test cases, comes from patterns we've seen succeed (and fail) in production. The zero trust defaults, the preference for explicit deny, the way it pushes you to define schemas upfront: that's all stuff we learned the hard way by watching what breaks when you skip it.

We've been using this internally for a few months now and it's genuinely changed how fast we can put together policy bundles for demos and customer POCs. I think it'll save you a fair amount of time too, especially if you're new to Cerbos and want to get something working quickly without picking up bad habits along the way.

Give it a try and let us know how you get on. We're tracking feedback and bug reports on the [GitHub repo](https://github.com/cerbos/skills/issues).

---

For a general guide on how to write, test, and validate authorization policies - [read this write-up](https://www.cerbos.dev/blog/authorization-policies-how-to-write-test-validate-with-ai-help).

Using a specific agent?
The Cerbos policy skill works in these and other tools:
* [Claude Desktop](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-claude-desktop)  
* [Claude Code](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-claude-code)  
* [Cursor](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-cursor)  
* [VSCode](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-vs-code)  
* [Codex](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-codex-cli)  
* [OpenCode](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-open-code)  
* [Pi](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-pi)  
* [Kiro](https://www.cerbos.dev/blog/agent-skill-for-writing-authorization-policies-in-aws-kiro)

## FAQ

### What does the Cerbos policy skill do?

The Cerbos policy skill turns plain English authorization requirements into a full policy bundle. You describe what you need, the agent skill asks clarifying questions, then generates schemas, derived roles, resource policies, and test suites in one pass. Every output is validated against our real compiler before it hands the files back to you.

### Which AI coding agents does the Cerbos policy skill work with?

The Cerbos policy skill works with Claude Code, Cursor, Codex, OpenCode, and any other agent that supports the skills protocol. It's a drop-in agent skill, so there's no new tool to adopt on top of what your team already uses. The [skill repo](https://github.com/cerbos/skills) has the full compatibility list.

### How do I install the Cerbos policy skill?

Installing the Cerbos policy skill takes one command. Run npx skills add cerbos/skills \--skill cerbos-policy from your project directory, or if you're using Claude Code directly, add the plugin marketplace with claude plugin marketplace add cerbos/skills. Both approaches install the same agent skill.

### Does the Cerbos agent skill validate the policies it generates?

Yes, the agent skill validates every policy it generates against the real compiler. After writing the bundle, the Cerbos policy skill runs cerbos compile via Docker and checks for errors. If validation fails, it works through issues in priority order, fixing YAML syntax first, then schema validation, then compile errors, then test failures, one fix per iteration.

### Can I use the Cerbos policy skill if I'm new to authorization?

You can use the Cerbos policy skill even if you're new to [authorization policies](https://www.cerbos.dev/blog/how-does-authorization-work). The agent skill asks questions in plain business language and pushes back on vague requirements that would otherwise create security holes. The generated output follows zero-trust defaults and least-privilege patterns we've built up from five years of helping teams model authorization.

### What does the Cerbos agent skill generate?

The Cerbos agent skill generates a complete policy bundle ready to drop into your Cerbos PDP. That includes principal and resource attribute schemas, derived roles with shared variables, resource or role policies with your actual authorization rules, and test fixtures with test suites that exercise both the allowed and denied paths.
