1
---
2
name: review-agent-setup
3
description: Configure human-in-the-loop gating for AI agent review actions in Claude Code. Use when setting up a project where an agent may post PR reviews, comments, merges, or edit CI configuration, and you want a cryptographically auditable approval trail with Cedar-enforced gates.
4
---
5
6
# review-agent-governance — Setup
7
8
Gate AI agent review actions (PR reviews, comments, merges, CI edits) behind
9
explicit human approval. Each tool call that runs produces an
10
Ed25519-signed receipt; denied calls never reach the signing hook.
11
12
## When to use this plugin
13
14
Install it in projects where a Claude Code agent:
15
16
- Reviews, comments on, or merges pull requests (`gh pr review`, `gh pr merge`)
17
- Triages issues (`gh issue comment`, `gh issue close`)
18
- Publishes releases (`gh release create`)
19
- Modifies CI configuration (`.github/workflows/`, `.gitlab-ci.yml`)
20
- Pushes to protected branches (`main`, `master`, `release`, `production`)
21
- Posts to external notification surfaces (Slack webhooks, Discord), once you
22
add a rule for the command that posts (the default policy does not gate them)
23
24
If the agent is only doing local file edits and running tests, this plugin is
25
overkill. Use `protect-mcp` for general tool-call policy enforcement and skip
26
this one.
27
28
## One-time setup
29
30
### 1. Install the plugin
31
32
```bash
33
claude plugin install wshobson/agents/review-agent-governance
34
```
35
36
### 2. Copy the default policy to your project
37
38
```bash
39
cp .claude/plugins/review-agent-governance/policies/review-agent-governance.cedar \
40
./review-governance.cedar
41
```
42
43
You can edit this file to match your project's specific rules. See
44
`../agents/review-policy-author.md` for guidance on authoring review
45
policies.
46
47
### 3. Create a receipts directory and sign key
48
49
```bash
50
mkdir -p ./review-receipts
51
echo "/review-receipts/" >> .gitignore
52
echo "/review-governance.key" >> .gitignore
53
echo "/.review-approved" >> .gitignore
54
if [ ! -e ./review-governance.key ]; then
55
d=$(mktemp -d) && npx protect-mcp@0.32.4 init --dir "$d" && mv "$d/keys/gateway.json" ./review-governance.key
56
fi
57
chmod 600 ./review-governance.key
58
```
59
60
protect-mcp 0.32.4 `sign` does not create the key, so the last command creates
61
it, and it never replaces an existing key. Without a key, the receipts are
62
unsigned. To rotate the key, archive `./review-governance.key` and
63
`./review-receipts/receipts.jsonl` first, then run the command again. Give auditors the `publicKey`
64
value from `./review-governance.key`. Do not commit the file, because it also
65
holds the private key.
66
67
## Per-session workflow
68
69
The Cedar policy denies review-surface actions unconditionally. To approve
70
a specific action, open an approval window before it and close it after.
71
72
### Flag file (simplest)
73
74
```bash
75
# Before the action you want to approve
76
touch ./.review-approved
77
78
# Let Claude Code run the review / comment / merge
79
80
# Immediately after
81
rm ./.review-approved
82
```
83
84
### Slash command (from within Claude Code)
85
86
```
87
/approve-review "Reviewing PR #123 authored by contributor X"
88
```
89
90
This creates `./.review-approved` with the given reason embedded as a note,
91
and records the reason in an unsigned approval log under
92
`./review-receipts/approvals/`. A follow-up `rm` is still needed to close the
93
window.
94
95
### Dry-run everything (force full policy evaluation)
96
97
If you want every tool call to go through Cedar with no approval bypass:
98
99
```bash
100
export REVIEW_APPROVAL_FLAG=./.never-approve
101
```
102
103
Any tool call matching a forbid rule will be denied; approved windows have
104
no effect. Useful for CI or for a locked-down audit run.
105
106
## Verifying the receipts
107
108
List all receipts:
109
110
```bash
111
ls -la ./review-receipts/
112
```
113
114
Verify every receipt offline with the public key:
115
116
```bash
117
PUB=$(node -p 'JSON.parse(require("fs").readFileSync("./review-governance.key")).publicKey')
118
npx @veritasacta/verify@0.11.1 --replay-chain ./review-receipts/receipts.jsonl --key "$PUB"
119
```
120
121
Exit 0 means every receipt verified. Exit 1 means a receipt failed
122
verification, because it was tampered with, the key is wrong, or a line is
123
malformed. Exit 2 means the receipts file could not be read.
124
125
A denied call never runs, so it has no receipt. To see what the policy
126
blocked, run this inside Claude Code:
127
128
```
129
/list-pending
130
```
131
132
It lists the tool calls that the PreToolUse hook blocked in the current
133
session, with the tool name and the command or path.
134
135
## Example: approving a PR review
136
137
```bash
138
# 1. Human reviews the agent's proposed comment
139
$ /list-pending
140
Blocked in this session:
141
- Bash "gh pr review 42 --approve --body 'LGTM'"
142
- Bash "gh pr comment 42 --body 'Looking good'"
143
144
# 2. Human decides the first one is appropriate, approves it
145
$ /approve-review "Approving LGTM on PR 42 after visual inspection"
146
./.review-approved created
147
148
# 3. Agent retries the action; this time it succeeds
149
$ agent: gh pr review 42 --approve --body "LGTM"
150
[receipt appended to ./review-receipts/receipts.jsonl, decision=allow]
151
152
# 4. Human closes the window
153
$ rm ./.review-approved
154
```
155
156
The allowed call has a signed receipt that anyone with the public key can
157
verify offline. The denied attempt has no receipt, and the approval log is
158
not signed, so keep both in mind when you show the trail to an auditor.
159
160
## Composing with protect-mcp
161
162
If both plugins are installed, each plugin's `hooks/hooks.json` registers its
163
own PreToolUse hook, and Claude Code runs both on every tool call:
164
165
```json
166
{ "type": "command", "command": "\"${CLAUDE_PLUGIN_ROOT}\"/hooks/evaluate.sh" }
167
```
168
169
Each `evaluate.sh` reads `tool_name` and `tool_input` from the hook payload on
170
stdin (Claude Code sets no `TOOL_NAME` variable) and evaluates its own policy:
171
`./protect.cedar` for protect-mcp and `./review-governance.cedar` here.
172
173
Both hooks must pass for the tool call to proceed. Cedar deny in either
174
policy blocks it.
175
176
## Standards
177
178
- **Ed25519** — RFC 8032 (digital signatures)
179
- **JCS** — RFC 8785 (deterministic JSON canonicalization)
180
- **Cedar** — AWS's open authorization policy language
181
- **IETF draft** — [draft-farley-acta-signed-receipts](https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/)
182