Review every pull request in CI
Run the reviewer on every pull request in GitHub Actions and show its review in the job summary, with the exact agent the team reviewed. Here the team publishes each release of the reviewer as a package to its registry, so CI runs a released, immutable package. You end with a configuration file and a workflow in the repository, and a review in each pull request's job summary.
Pull the release
On a laptop, pull the release pinned by the digest that pandra push printed on its Digest: line when the team published it, so CI runs exactly what the team reviewed:
pandra pull ghcr.io/acme/reviewer@sha256:<digest>The pull prints what the package contains, including the github server and the secret it asks for, which the next steps supply.
Write a configuration for CI
Point Pandra at a configuration file for CI, then choose the harness, give it the Anthropic API key as its credential, and pin its version:
mkdir -p .github/pandra
export PANDRA_CONFIG_FILE="$PWD/.github/pandra/config.toml"
pandra config secret set anthropic-api-key --env ANTHROPIC_API_KEY
pandra config target set claude --harness claude-code \
--login api-key --secret anthropic-api-key
pandra config target use claude
pandra harness use claude-code@2.1.285The agent reads pull requests, whose text can try to steer it, so keep the key out of its environment. As the target's credential, the key goes only to Pandra's proxy, which puts it in requests to Anthropic's API, and the harness gets a placeholder (give the harness an API key). Without a credential, Claude Code reads ANTHROPIC_API_KEY from the job's environment, where the agent and its tools can read it too. In the job, PANDRA_SECRET_ANTHROPIC_API_KEY supplies the key (step 4).
pandra config secret set warns that ANTHROPIC_API_KEY is not set here, and pandra harness use that the version is not installed here. The runner downloads the harness on its first run.
Give the GitHub server its token
The server gets the token as a Bearer header. The logical secret github-token reads it from the environment variable GITHUB_TOKEN; in the job, PANDRA_SECRET_GITHUB_TOKEN supplies the value instead (step 4):
pandra config secret set github-token --env GITHUB_TOKEN
pandra config mcp set github-ci \
--agent ghcr.io/acme/reviewer@sha256:<digest> --server github \
--secret Authorization=github-token \
--format Authorization='Bearer {}'The configuration file now holds this, with no secret value, only where it comes from, so commit it:
# .github/pandra/config.toml (excerpt)
[defaults]
target = "claude"
[targets.claude]
harness = "claude-code"
env.ANTHROPIC_API_KEY = { secret = "anthropic-api-key" }
[harnesses.claude-code]
version = "2.1.285"
[secrets.anthropic-api-key]
env = "ANTHROPIC_API_KEY"
[secrets.github-token]
env = "GITHUB_TOKEN"
[mcp.github-ci]
inputs.Authorization = { secret = "github-token", format = "Bearer {}" }
[agents."ghcr.io/acme/reviewer"]
mcp.github = "github-ci"
[allowed-servers."ghcr.io/acme/reviewer".github]
inputs = { Authorization = { secret = "github-token", format = "Bearer {}" } }
url = "https://api.githubcopilot.com/mcp/"Add the repository secret
Add ANTHROPIC_API_KEY as a repository secret. GitHub does not pass it to pull requests from forks, so this suits branches of the same repository. The GitHub token needs no secret. GitHub creates a token for each job, ${{ github.token }}, which expires when the job finishes.
The job passes ANTHROPIC_API_KEY to Pandra as PANDRA_SECRET_ANTHROPIC_API_KEY, and its token as PANDRA_SECRET_GITHUB_TOKEN, each of which takes the place of its secret's env source. Pandra removes these variables from the harness's environment variables, so the agent does not inherit them (supplying a value without its store). A variable the job sets under its own name in its env, such as GH_TOKEN or GITHUB_TOKEN, would reach the agent.
Add the workflow
The job installs the Pandra release that PANDRA_VERSION names, approves the pinned digest, and runs the review without questions.
name: Agent review
on: pull_request
permissions:
contents: read
packages: read
pull-requests: read
jobs:
review:
runs-on: ubuntu-latest
env:
PANDRA_VERSION: "0.1.0"
AGENT: ghcr.io/acme/reviewer@sha256:<digest>
PANDRA_CONFIG_FILE: ${{ github.workspace }}/.github/pandra/config.toml
PANDRA_SECRET_ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
PANDRA_SECRET_GITHUB_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install Pandra
run: |
curl -fsSL "https://pandra.io/$PANDRA_VERSION/install.sh" | sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Sign in to the registry
env:
REGISTRY_TOKEN: ${{ github.token }}
run: echo "$REGISTRY_TOKEN" | pandra auth login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
- name: Fetch and approve the agent
run: pandra pull "$AGENT" && pandra agent trust "$AGENT"
- name: Review
env:
BASE_REF: ${{ github.base_ref }}
run: |
pandra run "$AGENT" --prompt "Review the changes on this branch against origin/$BASE_REF." > review.md
cat review.md >> "$GITHUB_STEP_SUMMARY"Security
The agent can still use the job's token without the github server. actions/checkout keeps the token as the checkout's Git credential, and pandra auth login stores it in Pandra's data directory, which the agent can read because it runs as the same user. The token has only the permissions that the workflow's permissions block grants, so the agent and the github server can read the repository, its packages, and its pull requests but cannot change them.
Because AGENT is pinned to the digest the team reviewed, the job's approval can never cover a revision nobody has seen. The registry sign-in is needed only for a private package. An agent shared through Git works the same way pinned to a full commit, such as github.com/acme/reviewer@<full-commit>, with a Git credential on the runner for a private repository (running in CI covers the job's other settings).
Fail the job on serious findings
Optionally, add a step to the job. Save the schema from structured answers as .github/pandra/findings.schema.json, ask for an answer in that shape, and check it with jq, which fails the step when a high finding exists. Pandra itself fails the run, with exit code 1, when the answer does not match the schema.
pandra run "$AGENT" --prompt "Review the changes on this branch." \
--output-schema .github/pandra/findings.schema.json > findings.json
jq \
-e '[.findings[] | select(.severity == "high")] | length == 0' findings.json