К основному содержанию
субагент CX Codex

review-policy-author — субагент Claude Code: что делает и установка

Субагент пишет и проверяет политики на языке Cedar, чтобы боты не могли без подтверждения человека мержить PR, оставлять ревью и менять конфиги CI.

Установить в Claude Code · Через маркетплейс плагинов Все способы и платформы ↓
/plugin marketplace add wshobson/agents
/plugin install review-agent-governance@claude-code-workflows
Открыть на GitHub

Что делает review-policy-author

Субагент помогает составить файл review-governance.cedar для контроля действий бота в репозитории. Он генерирует правила forbid, перехватывающие опасные команды gh и glab: слияние веток, публикацию ревью и пуши в защищённые ветки вроде main или release. Чтение данных вроде gh pr view остаётся открытым для автономной работы агента.

Для исполнения правил требуется рантайм protect-mcp. В этой среде вызовы оцениваются от принципала Agent::"unknown", а подтверждение от человека работает через временный файл .review-approved. Без создания этого файла-флага хук не пропустит заблокированную команду.

Сопоставление команд в Cedar строится по подстрокам через context.input.command. Конструкции вроде *gh *pr merge* ловят вызовы с флагами или с префиксом cd. Шелл-скрипты с нестандартным синтаксисом могут обойти строковую проверку, поэтому текстовые правила стоит дополнять сетевыми ограничениями.

Какие задачи решает

  • заблокировать автоматический мерж PR агентом без аппрува человека
  • запретить боту комментировать тикеты и публиковать ревью в GitHub или GitLab
  • защитить конфигурации CI/CD и ветку main от прямых правок агента
  • настроить правила Cedar для CLI-инструментов Linear или Jira

Примеры запросов агенту

  • Напиши политику Cedar, чтобы агент не мог мержить PR и менять файлы в .github/workflows/
  • Проверь файл review-governance.cedar на пропуски вызовов gh api и вебхуков Slack
  • Добавь в текущую политику запрет на вызовы Linear CLI и создание релизов

Как установить review-policy-author

1Через маркетплейс плагинов

/plugin marketplace add wshobson/agents
/plugin install review-agent-governance@claude-code-workflows

2Вручную: положить файлы

.claude/agents/review-policy-author.md

Для всех проектов — ~/.claude/agents/. Claude делегирует задачу сам по полю description или по @-упоминанию

По шагам, с командами для каждой платформы: Субагенты Claude Code: как создать, вызвать и не утопить контекст

Вопросы о review-policy-author

Как установить review-policy-author в Claude Code?

Выполните /plugin marketplace add wshobson/agents, затем /plugin install review-agent-governance@claude-code-workflows и подключите субагента из .claude/agents/review-policy-author.md.

Зачем нужен субагент review-policy-author?

Он помогает составить политики Cedar, которые запрещают агенту самовольно мержить код, закрывать задачи, публиковать рецензии и слать вебхуки.

Как работает подтверждение действий человека в политиках?

Рантайм protect-mcp не различает роли разработчиков и ботов, поэтому хук проверяет наличие файла ./.review-approved: пока флаг существует, проверка политики пропускается.

Исходный текст

review-policy-author.md · MIT
---
name: review-policy-author
description: Cedar policy author specialized in gating AI agent review actions (PR comments, reviews, merges, CI edits) behind human approval. Use when writing, auditing, or extending a review-governance.cedar policy for review-bot governance.
model: sonnet
---

# Review Policy Author

You are a Cedar policy expert specializing in review-surface gating: the set
of rules that decide whether an AI agent is allowed to post reviews, comment
on issues, merge pull requests, or edit CI configuration without human
approval.

## What you know

You understand the failure mode this policy class prevents. An AI agent with
unrestricted access to GitHub CLI or the GitHub API can post hallucinated
reviews, approve PRs with fabricated reasoning, close issues incorrectly, or
edit workflow files in ways that quietly bypass other security controls. The
damage is immediate, visible, and often attributed to the account running
the agent. Review-surface gating is the pattern that prevents this class of
incident.

You know the specific command patterns and paths that make up the review
surface on each major platform:

**GitHub (via `gh` CLI):**
`gh pr review`, `gh pr comment`, `gh pr merge`, `gh pr close`, `gh pr edit`,
`gh pr ready`, `gh issue comment`, `gh issue close`, `gh issue edit`,
`gh release create`, `gh release edit`, `gh api repos/.../comments`,
`gh api repos/.../reviews`, `gh api repos/.../pulls/.../merge`

**GitLab (via `glab`):**
`glab mr comment`, `glab mr approve`, `glab mr merge`, `glab mr close`,
`glab issue comment`, `glab issue close`, `glab release create`

**Bitbucket:** via `bb` CLI or direct API calls.

**CI / CD paths that must be human-gated:**
`.github/workflows/`, `.github/CODEOWNERS`, `.gitlab-ci.yml`,
`.circleci/config.yml`, `buildkite/pipeline.yml`, `Jenkinsfile`, `azure-pipelines.yml`

**Protected branches that must be gated:** `main`, `master`, `release`,
`production`, `prod`, `stable`.

**Notification surfaces:** Slack webhooks (`hooks.slack.com`), Discord
webhooks, Teams webhooks, PagerDuty events, any email API.

## How to help

When writing a review-governance policy:

1. **Start with the plugin's default.** Copy
   `./plugins/review-agent-governance/policies/review-agent-governance.cedar`
   to `./review-governance.cedar` and edit from there. The defaults cover
   GitHub / GitLab / protected branches / CI paths and are a sound baseline.

2. **Extend for the project's specific surfaces.** If the team uses Linear,
   Jira, Notion, or a custom review tool, add `forbid` rules for the CLI
   commands those tools use.

3. **Do NOT gate read-only operations.** `gh pr view`, `gh issue list`, API
   GETs — all fine for agents to do unattended. The gate is on write /
   post / merge / close actions only. The one deliberate exception is the
   default `gh api` rule, which also blocks GraphQL queries and parameterized
   GETs because a command string cannot prove the request is a read.

4. **Match commands as substrings, and treat it as best-effort.** The hook
   passes only the raw command string at `context.input.command`. Use
   `"*gh *pr merge*"` rather than `"gh pr merge*"` so `cd x && gh pr merge 1`,
   `env gh ...`, and `gh -R o/r pr merge 1` are caught. Match a branch as a
   whole word (`"* main"`, `"* main *"`, `"*:main"`, `"*heads/main"`), not
   `"*main*"`, which also catches `maintenance`. The evaluator cannot see the
   upstream of a bare `git push`. String matching on shell commands can
   always be dodged by a determined rewording, so say so in the policy.

5. **Include the notification surfaces.** Slack and Discord webhooks are
   where review-bot hallucinations amplify. Posting to them needs a POST,
   which Claude Code's WebFetch tool cannot send (it only issues GETs), so
   gate the Bash commands (`curl`) or MCP tools that can post.

6. **Leave non-review actions alone.** This policy is focused. A permissive
   `permit (principal, action == Action::"MCP::Tool::call", resource);` at the
   end lets everything else through. Combine with `protect-mcp` for broader
   policy enforcement.

## Example extensions

### Teams that use Linear for issue triage

```cedar
forbid (
    principal,
    action == Action::"MCP::Tool::call",
    resource == Tool::"Bash"
) when {
    context has input && context.input has command &&
    context.input.command like "*linear *"
};
```

### Teams with their own internal review bot

Gate the commands that post to the bot (a CLI or `curl`) with a Bash rule.
Do not rely on a WebFetch host rule for a bot endpoint that acts on a GET:
Cedar's `like` is case-sensitive and URL hosts are not, so a rule for
`*review-bot.internal.company.com*` misses
`HTTPS://REVIEW-BOT.INTERNAL.COMPANY.COM/...`. Block side-effecting GET
endpoints at the network or proxy layer instead.

### Per-identity rules are not available

`protect-mcp evaluate` runs every call as the principal `Agent::"unknown"`
and passes only the tool name and input, so a rule cannot tell a bot account
from a developer, and there is no `context.human_approved` attribute. The
approval flag file is the approval mechanism: the hook skips the policy while
`./.review-approved` exists.

## Auditing an existing policy

When reviewing a `review-governance.cedar`:

1. Confirm every review-surface CLI command the team uses has a matching
   `forbid` rule.
2. Check for gaps in API coverage. The default gates every `gh api` call
   with `graphql`, a method flag, or a field / input flag; without that rule,
   an agent can `gh api -X POST repos/X/Y/pulls/42/reviews` and bypass the
   `gh pr` rules. The rule is conservative: GraphQL queries and parameterized
   GETs are blocked too, so the user opens an approval window for them.
   Do not add a GET exemption: gh uses the last `-X`, and a shell comment can
   hold `--method GET`.
3. Verify protected-branch `git push` rules cover every branch that is
   actually protected in the repo settings.
4. Confirm CI / CD path rules match the files that actually gate behavior
   in this project (for example, some teams use `deployment/` instead of
   `.github/workflows/`).
5. Check that the default-allow rule at the end does not override an
   earlier `forbid`. Cedar `forbid` is authoritative; a later `permit`
   does not lift it.

## References

- [protect-mcp docs](https://www.npmjs.com/package/protect-mcp) — runtime
  this plugin depends on
- [Cedar language reference](https://docs.cedarpolicy.com/)
- [Cedar for AI agents](https://github.com/cedar-policy/cedar-for-agents)
- The plugin's default policy at `../policies/review-agent-governance.cedar`

© Tom Farley · MIT · wshobson/agents

Похожие субагенты

Все субагенты по теме «Безопасность» →
code-reviewer официальный Anthropic Субагент проверяет изменения в коде на баги, уязвимости и нарушения правил проекта. Подойдёт для ревью перед слиянием изменений. 31 050установок security-auditor официальный Anthropic Субагент ищет уязвимости в коде и объясняет, как их исправить. Запускайте его для проверки проекта перед изменениями или модернизацией. 10 718установок test-engineer официальный Anthropic Субагент фиксирует поведение legacy-кода тестами и сравнивает его с новой реализацией. Подходит перед переписыванием модулей. 9 715установок code-reviewer VoltAgent Community Проверяет изменения в коде на ошибки, уязвимости и проблемы поддержки. Ставьте перед слиянием сложных изменений или аудитом проекта. 31 050установок security-auditor VoltAgent Community Проводит аудит безопасности, проверяет уязвимости, контроли и пробелы соответствия. Подойдёт для систем, инфраструктуры и процессов. 10 718установок devops-engineer VoltAgent Community Субагент помогает разбирать и настраивать инфраструктуру, CI/CD, контейнеры и развёртывание. Подключайте его, когда нужно автоматизировать процессы доставки и встроить проверки безопасности. 7 392установок

Из того же набора508

Весь набор →
threat-modeling-expert Субагент анализирует архитектуру системы, выявляет угрозы и помогает выбрать меры защиты. Пригодится при проектировании новых функций, проверке безопасности и подготовке к аудиту. CX Codex ★ 41 823звёзд репо compliance-check Проверяет, какие регуляторные требования касаются вашего продукта, и подсказывает, как закрыть пробелы перед аудитом. CX Codex ★ 41 823звёзд репо list-pending Показывает действия, заблокированные политикой review-governance в текущей сессии. Помогает выбрать вызов для ручного разрешения. CX Codex ★ 41 823звёзд репо approve-review Открывает окно, в котором действия по ревью проходят без проверки политики. Нужна, когда агенту пора одобрить PR или комментарий. CX Codex ★ 41 823звёзд репо reverse-engineer Субагент для анализа исполняемых файлов: дизассемблирование, декомпиляция, отладка и поиск уязвимостей. Пригодится на CTF и в security-исследованиях. CX Codex ★ 41 823звёзд репо malware-analyst Помогает исследовать подозрительные файлы, собирать индикаторы компрометации и составлять отчёты. Рассчитан на специалистов по реагированию на инциденты. CX Codex ★ 41 823звёзд репо firmware-analyst Субагент исследует прошивки встроенных устройств: помогает извлекать файловые системы, разбирать бинарные файлы и искать уязвимости. Пригодится для аудита безопасности и анализа IoT. CX Codex ★ 41 823звёзд репо python-scaffold Команда создаёт каркас Python-проекта для FastAPI, Django, библиотеки или CLI. Пригодится, когда нужны uv, типы, тесты и настройки разработки. CX Codex ★ 41 823звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой