# Policy as code for AI agents: a hands-on lab | Kaba Digital Inc.

> Write the rules an agent must follow as code, test them, and watch the agent stop when it should. Build it from a starter template.

Source: https://kabadigitalinc.com/labs/policy-as-code-for-ai-agents/

[← All labs](https://kabadigitalinc.com/labs/)

# Policy as code for AI agents

Write the rules an agent must follow as code, test them, and watch the agent stop when it should. Build it from a starter template.

Status

Planned

Level

Intermediate

Length

3 hours

When

To be announced

[Get notified of dates ↗](https://kabadigitalinc.com/newsletter/)

Agents are easy to start and hard to trust. This lab is about the second part: writing down what an agent may do, in code, so the rules are visible, testable, and reviewed like any other change.

## What you will build

You start from the starter template, which already runs an agent with a few tools. You then write a policy that decides, for each tool call, whether to **allow**, **ask a person**, or **block**, and you add tests that fail when the policy is wrong.

## How the session runs

1. A short walkthrough of the starter and the idea of policy as code.
2. You build the policy yourself, in small checkpoints, with others building beside you.
3. You break your own agent on purpose, and fix the policy.
4. You leave with a working repository you can adapt.

## Bring

A laptop, Node, and an API key for any model provider you already use.

What you build

* An agent that calls tools
* A policy file that allows, asks, or blocks each action
* Tests that prove the policy holds

Before you come

* Comfortable reading TypeScript
* A laptop with Node installed
* An API key for one model provider

Starter template

Policy-as-code agent starter

A small agent with tools, a policy file that allows, asks, or blocks each action, and tests for the policy.

Repository link appears when it is public. · MIT licence

[Get notified of dates](https://kabadigitalinc.com/newsletter/)[Book it for your team](https://kabadigitalinc.com/workshops/)

## An idea worth building?

Bring the problem, the insight, and the ambition. Let’s figure out what we could build together.

[Start a conversation ↗ ](https://kabadigitalinc.com/contact/)
