Skip to main content
This example builds pr-reviewer: an agent that reviews a pull request when it is opened or updated, and answers when someone mentions @pr-reviewer in the pull request’s conversation. Each pull request gets one session, so a later push or question is handled with the earlier review in context. GitHub posts its webhooks straight to a paddock connector; you run no server. The examples use the repository acme/web; replace it with yours.

1. The template

The template describes the reviewer: Claude Code on claude-opus, and a system prompt that fixes what it may do and how it must post. The system prompt replaces Claude Code’s own, so it describes the whole job: who the agent is, where it runs, which tools it has, how it works, and how it must post. The agent reaches GitHub only through the GitHub MCP server, which the agent gets in the next step with your token.
agents/pr-reviewer/template.yaml
Claude Code follows the review content of a system prompt readily, but output rules, such as the review event and the marker line, hold best when they come first as a contract and are repeated in each message. The rules below repeat them.

2. The agent

Create the template and an agent from it, then give the agent the GitHub MCP server with a GitHub token that can read the repository and write reviews and comments. The token is the agent’s own configuration, so no template version ever carries it.
Keep GITHUB_TOKEN in your environment, never in code. In the console, the agent’s Capabilities tab adds the same MCP server. After the agent’s first turn, its harness status shows the github server as loaded.

3. The connector

The connector’s inbound function is the github preset. It checks GitHub’s signature with a secret you generate (for example openssl rand -hex 32), drops GitHub’s redeliveries by their X-GitHub-Delivery header, and routes two kinds of events to the agent, both to the session of the pull request, acme/web#<number>:
  • a pull request opened, reopened, made ready for review, or pushed to, asking for a review of what changed since the last one; drafts are skipped;
  • a new comment on the pull request that mentions @pr-reviewer, not written by a bot, asking for an answer.
The preset’s code is copied into the connector, so you can read it in the console and edit it, such as to change the messages it sends the agent. Before you connect GitHub, run it on sample events with connector.functions.test, or in the console’s test panel, which shows the routes a request would deliver. A synchronize event should route to the pull request’s session, and a draft or a ping should route nowhere.

4. The GitHub webhook

In the repository’s Settings → Webhooks → Add webhook: GitHub sends a ping when you save the webhook. It shows in the connector’s deliveries as done, with no route.

What happens

Find a pull request’s conversation with sessions.list({ metadata: { connectorKey: "acme/web#42" } }), or in the console’s Sessions page.

Notes from running it

  • Posting as yourself. With a personal token, reviews and comments are posted as your own account. GitHub does not let an author approve or request changes on their own pull request, which is why the prompt allows only COMMENT reviews. The marker line tells the agent’s comments from yours, and the prompt keeps the agent from ever writing the mention, so its replies never route back to it. A bot account’s token avoids both limits.
  • Iterating on the prompt. An agent stays on the template version it was created from, so a new template version does not change this agent’s prompt; it only records the prompt for agents you create from that version later. To change the prompt of the running agent, set the agent’s own system prompt (agent.SystemPrompt.Set in Go, agent.system_prompt.set in Python, agent.systemPrompt.set in TypeScript; see Configuration). Only sessions created afterwards use it: a pull request’s existing session keeps the prompt it started with, so delete that session, or wait for the next pull request, to see the change.
  • Tools in the sandbox. The agent reaches GitHub only through the MCP server. The prompt says so, and says what the sandbox lacks, so the agent does not reach for a CLI or a checkout it does not have.