Skip to content

Examples

Real POLICY.md files from the repository. Copy the pattern that fits, adjust the rules, ship it.

Note: the @sidianlabs/policy CLI shown in some examples is not on npm yet — run it from a clone (npm install && npm run build, then node bin/policy.js).

Project guardrails

examples/project/POLICY.md - drop this at a repo root for instant baseline protection:

markdown
---
name: project-guardrails
description: Project-wide guardrails for AI agents
version: 1.0.0
scope: project
appliesTo: [all]
rules:
  - capability: file.write
    action: deny
    condition:
      field: { path: payload.path, op: includes, value: .env }
    reason: Never write .env or secret files

  - capability: command.run
    action: deny
    condition:
      field: { path: payload.argv, op: includes, value: rm -rf / }
    reason: Destructive commands are forbidden

  - capability: command.run
    action: allow
    condition:
      field: { path: payload.argv, op: includes, value: npm run test }
    reason: Running tests is safe

  - capability: package.install
    action: require_approval
    reason: New dependencies can affect the supply chain
---

## Forbidden
- Never commit `.env` files, `secrets.json`, or any file containing credentials.
- Never execute obfuscated shell commands or piping from remote URLs directly into `sh`.
- Never push directly to `main` or `production` branches.

## Ask first
- Adding or removing dependencies.
- Modifying CI/CD pipeline files.
- Changing infrastructure or deployment configuration.

## Allowed
- Running `npm run typecheck`, `npm run test`, and `npm run build`.
- Reading project documentation, source files, and configuration.
- Refactoring files inside `src/` as long as tests still pass.

Skill-scoped policy

examples/skill/ui-polish/POLICY.md - negative boundaries for one skill, sitting next to its SKILL.md:

markdown
---
name: ui-polish-policy
description: Negative boundaries for the ui-polish skill
version: 1.0.0
scope: skill
appliesTo: [ui-polish]
rules:
  - capability: file.write
    action: deny
    condition:
      field: { path: payload.path, op: includes, value: ChatPage.tsx }
    reason: The ui-polish skill must not touch ChatPage.tsx
---

## Forbidden
- Never modify `ChatPage.tsx`.
- Never change global theme tokens.

## Ask first
- Adding new dependencies for styling.

## Allowed
- Refactoring `src/components/*.tsx`.
- Updating CSS modules and Tailwind classes.

Payment guardrails pattern

For money movement, combine amount thresholds with environment scoping:

yaml
rules:
  - capability: payment.*
    action: require_approval
    condition:
      field: { path: payload.amount, op: gt, value: 1000 }
    reason: Payments over $1000 need a human

  - capability: payment.*
    action: deny
    condition:
      and:
        - field: { path: payload.amount, op: gt, value: 50000 }
        - field: { path: constraints.environment, op: eq, value: production }
    reason: No single payment over $50k in production

Testing your policy

bash
# Does this policy catch the dangerous command?
npx @sidianlabs/policy check . command.run --payload-file payload.json

# Validate before committing
npx @sidianlabs/policy validate POLICY.md --strict

Released under the Apache 2.0 License.