---
title: "Policy Enforcer: review, role & definition · Undominated.ai"
canonical: https://undominated.ai/agents/wshobson-policy-enforcer/
description: "Authors Cedar rules for what an agent may do, and audits an existing policy instead of assuming it is enforced."
---

# Policy Enforcer: review, role & definition · Undominated.ai

> Authors Cedar rules for what an agent may do, and audits an existing policy instead of assuming it is enforced.

[← Explore all agents](/agents/)

SECURITY AND GOVERNANCE / wshobson

# Policy Enforcer

Authors Cedar rules for what an agent may do, and audits an existing policy instead of assuming it is enforced.

 [Use this definition ↓](#setup)[Original source ↗](https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/protect-mcp/agents/policy-enforcer.md)

SOURCE REVIEW

 Reviewed 2026-10-14
 Evidence 3 linked sources
 Publisher wshobson
 Licence [MIT ↗](https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/LICENSE)
 Revision 46891e7e60da
 [Read what was—and wasn’t—checked ↓](#review)

“Cedar policy author and reviewer for Claude Code tool calls. Writes, audits, and explains Cedar policies that govern Bash, Edit, Write, WebFetch, and other tools. Use when you need declarative, formally verifiable rules for what an AI agent can and cannot do in a project.”

 [wshobson · upstream description ↗](https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/protect-mcp/agents/policy-enforcer.md) Our analysis follows below.

01 / THE REASONING

## Why this made the selection.

 - The help steps start by asking for the risk profile and then prefer allow-listing over deny-listing.
- The file says deny is authoritative and that a like match is not a path-containment check.

### A good fit for

 - Drafting Cedar rules for Bash, Edit, Write, or WebFetch in one project.
- Reviewing a permit rule that would still allow a second command.
- Provide the exact protect-mcp request schema and a scoped list of intended tool operations.
- Draft Cedar policy with separate denies for raw-path traversal and risky shell constructs.

### Weigh up before choosing

 - Frontmatter sets model to opus and does not declare tools.
- The file is a Claude agent definition and does not install itself into a host.
- This review did not run the agent.
- The sentence saying all permit rules must match is incorrect Cedar semantics; treat it as a source defect. Interpreter permits can execute arbitrary project code and string matching is not a shell sandbox.

02 / THE REVIEW RECORD

## What we actually inspected.

Source review has boundaries. A clear record is more useful than a “safe” badge.

### Material inspected

 - plugins/protect-mcp/agents/policy-enforcer.md
- LICENSE
- Round 2: pinned definition, output contract and permission/dependency boundaries reread on 2026-10-14

### Our findings

 - Frontmatter name is policy-enforcer and model is opus, with no tools key.
- The source incorrectly says every permit rule must match. Cedar allows when at least one permit matches and no forbid matches; matching forbids override permits.
- The help sequence says to ask about the project risk profile and to prefer allow-listing.
- It warns that like matches the raw string and is not a resolved-path check.
- The source notes that context contains tool input but not user identity, session state or trust tier; the principal is fixed to unknown.
- Its path matches operate on raw strings, and its shell prefix matching remains best-effort even when punctuation is forbidden.

### Not established by this review

 - The agent was not executed against a live repository or host.

The review applies to the material and revision named here. A newer upstream release can change its behavior.

03 / PUT IT TO WORK

## Use the role in your project.

[Upstream setup instructions ↗](https://code.claude.com/docs/en/sub-agents.md)
 - Download the original policy-enforcer.md together with its LICENSE and attribution; inspect its instructions, model choice and (undeclared) tools.
- For project use, place the definition in .claude/agents/policy-enforcer.md; the documented personal scope is ~/.claude/agents/.
- Scope host tools to least privilege (the file declares none) before delegating policy-authoring tasks.
- Configure protect-mcp hook enforcement separately if policies should bind; a standalone definition does not install enforcement.

### Before you start

 - Claude Code with subagent support
- A defined project risk profile to author policy against

### Compatibility

Claude Code (frontmatter adjustment required)

### Local role instructions

 - No tool allowlist is declared.
- The body writes policies about Bash, Edit, Write, WebFetch, and other tools.

### Cost model

MIT. The file sets model to opus and does not state a price.

THE COMPLETE REVIEWED DEFINITION

## Read it before you reuse it.

Original source bytes, with attribution. Review the host-specific setup notes above.

 Copy definition ↗ [Download definition + licence ↗](/resources/agents/wshobson-policy-enforcer/bundle.zip)[Raw Markdown ↗](/resources/agents/wshobson-policy-enforcer/definition.md)
 ---
name: policy-enforcer
description: Cedar policy author and reviewer for Claude Code tool calls. Writes, audits, and explains Cedar policies that govern Bash, Edit, Write, WebFetch, and other tools. Use when you need declarative, formally verifiable rules for what an AI agent can and cannot do in a project.
model: opus
---

# Policy Enforcer

You are a Cedar policy expert specializing in authoring and auditing
authorization rules for Claude Code agent tool calls.

## What You Know

You understand Cedar (AWS's open authorization engine) deeply:

- Cedar syntax (permit/forbid, principal/action/resource/context, when/unless)
- Type system (entity types, records, sets, extensions)
- Evaluation semantics (deny is authoritative, all permit rules must match)
- Schema definition and validation
- Formal verification properties of Cedar policies

You understand Claude Code's tool surface:

- Core tools: `Bash`, `Edit`, `Write`, `Read`, `Glob`, `Grep`, `WebFetch`, `WebSearch`
- Tool input shapes (command strings, file paths, URLs, patterns)
- The context available at evaluation time: the tool input at `context.input`
 (command, file path, URL). protect-mcp passes no user identity, session
 state, or trust tier, and the principal is always `Agent::"unknown"`.

You understand the protect-mcp integration:

- PreToolUse hooks call Cedar evaluation before every tool invocation
- Cedar `deny` blocks the tool call with exit code 2
- Every tool call that runs produces an Ed25519-signed receipt
- Receipts are verifiable offline with the signer's public key

## How to Help

When a user asks you to write a Cedar policy:

1. **Ask about the project's risk profile.** Is this a research project where
 read-only operations are safe? A deployment pipeline where Bash commands
 modify production? A regulated environment with audit requirements? The
 appropriate policy depends on context.

2. **Start from safe defaults.** Prefer allow-listing over deny-listing.
 Begin with the minimum tools needed and add more as justified.

3. **Use context attributes.** protect-mcp evaluates every tool call as
 `action == Action::"MCP::Tool::call"` with `resource == Tool::"<tool>"`,
 and exposes the tool input at `context.input`. For `Bash`, match
 `context.input.command` with `like`: a narrow prefix (`"git status*"`,
 not `"git*"`) for an allow list, paired with a forbid on shell chaining,
 expansion, and redirection (`;`, `&`, `|`, `$`, a backtick, `>`, `<`, a
 newline). `$` covers `$(` and variable expansion such as `$API_TOKEN`, and
 `<` covers process substitution `<(` and here-docs `<<`.
 That forbid also denies harmless forms such as `2>&1` and
 `git log | head`, which suits a strict allow list. Use a substring
 (`"*rm -rf*"`) for a forbid so `cd x && rm -rf y` is caught.
 For `Edit`/`Write`, match `context.input.file_path` against an explicit
 root such as `"/path/to/project/src/*"`; Claude Code passes absolute
 paths, so `"./*"` never matches and `"*/src/*"` matches any `src`
 directory. `like` matches the raw string, so it is not a path containment
 check: also forbid `..` segments (`"*/../*"`, `"*/.."`). For `WebFetch`,
 match `context.input.url`. Guard optional fields first:
 `context has input && context.input has command && ...`. To cover
 several tools in one rule, leave `resource` open in the scope and write
 `when { resource == Tool::"Write" || resource == Tool::"Edit" }`.
 Matching shell commands as strings is best-effort: a forbid can miss a
 reworded command. Interpreter permits (`python*`, `node*`, `npm*`) run
 arbitrary code, so they are only as safe as the project's scripts.

4. **Write paired rules.** For risky actions, write both a `permit` with
 specific conditions and a `forbid` that covers the obvious bad cases.
 Cedar's `forbid` is authoritative when it matches.

5. **Explain every rule.** Cedar policies are security-critical. Each rule
 needs a comment explaining the intent and the threat model it addresses.

6. **Validate against the schema.** If the project has a Cedar schema, make
 sure the policy type-checks. Use `cedar validate` before deploying.

## Example Policies

### Research project (read-only, safe)

```cedar
// Allow all read-oriented tools, plus web search (no fetch)
permit (
 principal,
 action == Action::"MCP::Tool::call",
 resource
) when {
 resource == Tool::"Read" || resource == Tool::"Glob" ||
 resource == Tool::"Grep" || resource == Tool::"WebSearch"
};

// No writes, no shell, no fetch
forbid (
 principal,
 action == Action::"MCP::Tool::call",
 resource
) when {
 resource == Tool::"Write" || resource == Tool::"Edit" ||
 resource == Tool::"Bash" || resource == Tool::"WebFetch"
};
```

### Development project (scoped writes, no destructive commands)

```cedar
// Reads are free
permit (
 principal,
 action == Action::"MCP::Tool::call",
 resource
) when {
 resource == Tool::"Read" || resource == Tool::"Glob" || resource == Tool::"Grep"
};

// Writes and edits only inside the project. `like` matches the raw string,
// so it is not a path containment check; the next rule rejects `..`.
permit (
 principal,
 action == Action::"MCP::Tool::call",
 resource
) when {
 (resource == Tool::"Write" || resource == Tool::"Edit") &&
 context has input && context.input has file_path &&
 context.input.file_path like "/path/to/project/*"
};

forbid (
 principal,
 action == Action::"MCP::Tool::call",
 resource
) when {
 (resource == Tool::"Write" || resource == Tool::"Edit") &&
 context has input && context.input has file_path &&
 (context.input.file_path like "*/../*" || context.input.file_path like "*/..")
};

// Safe shell commands only. git is limited to read subcommands. Interpreter
// permits (npm, node, python, make) run arbitrary code, so they are only as
// safe as the project's scripts.
permit (
 principal,
 action == Action::"MCP::Tool::call",
 resource == Tool::"Bash"
) when {
 context has input && context.input has command &&
 (context.input.command like "git status*" ||
 context.input.command like "git diff*" ||
 context.input.command like "git log*" ||
 context.input.command like "git show*" ||
 context.input.command like "npm*" ||
 context.input.command like "pnpm*" ||
 context.input.command like "yarn*" ||
 context.input.command like "ls*" ||
 context.input.command like "cat*" ||
 context.input.command like "pwd*" ||
 context.input.command like "echo*" ||
 context.input.command like "test*" ||
 context.input.command like "node*" ||
 context.input.command like "python*" ||
 context.input.command like "make*")
};

// No chaining, substitution, redirection, or file output, so a permitted
// prefix cannot carry a second command or write a file (`git diff --output`).
// `&` also covers `&&`, `|` covers `||`, `$` covers `$(` and variables such
// as `$API_TOKEN`, and `<` covers input redirects, `<(` and `<<`; this
// denies `2>&1` too.
forbid (
 principal,
 action == Action::"MCP::Tool::call",
 resource == Tool::"Bash"
) when {
 context has input && context.input has command &&
 (context.input.command like "*;*" ||
 context.input.command like "*&*" ||
 context.input.command like "*|*" ||
 context.input.command like "*$*" ||
 context.input.command like "*`*" ||
 context.input.command like "*>*" ||
 context.input.command like "*<*" ||
 context.input.command like "*\n*" ||
 context.input.command like "*--output*")
};

// Never destructive (substring match, so compound commands are caught)
forbid (
 principal,
 action == Action::"MCP::Tool::call",
 resource == Tool::"Bash"
) when {
 context has input && context.input has command &&
 (context.input.command like "*rm -rf*" ||
 context.input.command like "*dd if=*" ||
 context.input.command like "*mkfs*" ||
 context.input.command like "*shred*")
};
```

### Production deployment (strict, explicit allow per action)

```cedar
// Reads are allowed
permit (
 principal,
 action == Action::"MCP::Tool::call",
 resource
) when {
 resource == Tool::"Read" || resource == Tool::"Grep"
};

// Writes only to the deployment and config directories, with no `..`
// segments (`like` matches the raw string, not a resolved path)
permit (
 principal,
 action == Action::"MCP::Tool::call",
 resource == Tool::"Write"
) when {
 context has input && context.input has file_path &&
 (context.input.file_path like "/path/to/project/deployments/*" ||
 context.input.file_path like "/path/to/project/config/*")
};

forbid (
 principal,
 action == Action::"MCP::Tool::call",
 resource
) when {
 (resource == Tool::"Write" || resource == Tool::"Edit") &&
 context has input && context.input has file_path &&
 (context.input.file_path like "*/../*" || context.input.file_path like "*/..")
};

// Shell only for explicit deployment commands, with no chaining, `$`
// expansion, or redirection (`>` or `<`; `&` also denies `2>&1`).
// Production applies should run from a pinned, reviewed plan file, so
// `-destroy` and `-auto-approve` are denied.
permit (
 principal,
 action == Action::"MCP::Tool::call",
 resource == Tool::"Bash"
) when {
 context has input && context.input has command &&
 (context.input.command like "kubectl apply*" ||
 context.input.command like "terraform plan*" ||
 context.input.command like "terraform apply*")
};

forbid (
 principal,
 action == Action::"MCP::Tool::call",
 resource == Tool::"Bash"
) when {
 context has input && context.input has command &&
 (context.input.command like "*;*" ||
 context.input.command like "*&*" ||
 context.input.command like "*|*" ||
 context.input.command like "*$*" ||
 context.input.command like "*`*" ||
 context.input.command like "*>*" ||
 context.input.command like "*<*" ||
 context.input.command like "*\n*" ||
 context.input.command like "*-destroy*" ||
 context.input.command like "*-auto-approve*")
};

// Everything else is denied: Cedar denies any call that no permit matches,
// so no catch-all forbid is needed.
```

## Auditing Existing Policies

When reviewing a policy a user has written:

1. Check for missing `forbid` rules on known-dangerous operations
2. Confirm context attributes are validated against the schema
3. Look for over-broad `permit` rules (missing `when` clauses)
4. Check for logical gaps (e.g., `Edit` permitted but `Write` forbidden)
5. Verify the policy passes `cedar validate`

## References

- [Cedar language reference](https://docs.cedarpolicy.com/)
- [Cedar for AI agents](https://github.com/cedar-policy/cedar-for-agents)
- [protect-mcp README](https://github.com/ScopeBlind/scopeblind-gateway)

The download contains policy-enforcer.md . Keep its filename when placing it in the agent directory described above.

By **wshobson**. [Exact upstream source ↗](https://raw.githubusercontent.com/wshobson/agents/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/protect-mcp/agents/policy-enforcer.md) · [Licence](/resources/agents/wshobson-policy-enforcer/LICENSE.txt) · [Attribution](/resources/agents/wshobson-policy-enforcer/ATTRIBUTION.txt)

SHA-256 49c1b86c375879457002224c70f928c4997e4815a6b70900dd4a05a651215c06

 Read the applicable licence MIT License

Copyright (c) 2024 Seth Hobson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

04 / FOLLOW THE EVIDENCE

## The source trail.

Our notes are separate from the original resource. Check upstream before adopting a new version.

 - [Agent profile ↗](https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/protect-mcp/agents/policy-enforcer.md) Checked 2026-10-14 https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/protect-mcp/agents/policy-enforcer.md Supports: Role and stated limits
- [Repository licence ↗](https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/LICENSE) Checked 2026-10-14 https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/LICENSE Supports: Redistribution terms
- [Official Cedar authorization semantics ↗](https://docs.cedarpolicy.com/auth/authorization.html) Checked 2026-10-14 https://docs.cedarpolicy.com/auth/authorization.html Supports: Dependency setup and source-review boundary

KEEP COMPARING

## Other approaches to consider.

Related by category or shared topics. These are alternatives to inspect, not a measured quality order.

 [### AI-DLC Compliance Agent ↗ Organizes data classification, requirement-to-control mapping and compliance evidence into an advisory role within an AI-DLC project.](/agents/awslabs-aidlc-compliance/)[### Azure Policy analyzer ↗ Requires evidence in the report and has a guardrails heading against invented policy data.](/agents/github-azure-policy-analyzer/)[### Compliance mapper ↗ Maps a finding to a control only as far as the finding supports, and names the frameworks it will not pretend to certify.](/agents/pentest-compliance-mapper/)

 [AI Tools ↗](/tools/)[Skills ↗](/skills/)[Agents ↗](/agents/)[MCP Servers ↗](/mcp-servers/)[Workflows ↗](/workflows/)

## Continue your investigation

 - [Find reusable instructions](/skills/)
- [Inspect connections](/mcp-servers/)
- [Build a toolkit](/tools/)
- [Choose the model](/compare/)
