# Review every pull request

Returns: A review on the PR. Starts: on an event.

Each pull request gets an agent that checks it out in its own sandbox, runs the tests and posts a review with the evidence.

## Best for

- Teams that want a second review before merge
- Repositories with a test suite the agent can run

## Uses

- A connected GitHub repository
- A Project
- An automation with a GitHub trigger

## The automation

Prompt: Review this pull request. Check it out, run the tests, and post one review that cites file and line for every finding. Do not push commits.

Trigger:

```json
{
  "kind": "github",
  "events": [
    "pull_request.opened",
    "pull_request.synchronize"
  ],
  "branch_patterns": [
    "main"
  ]
}
```

## The same work as one request

`POST /o/{org}/sessions`

```json
{
  "harness": "claude",
  "input": "Review this pull request. Run the tests and post one review that cites file and line for every finding.",
  "resources": [
    {
      "url": "https://github.com/acme/payments/pull/212"
    }
  ]
}
```

## While it works

Live stream events (`GET /o/{org}/sessions/{session}/events`):

- `tool_use`: bash · gh pr checkout 212
- `tool_use`: bash · bun test payments
- `tool_result`: 46 passed, 1 failed
- `thinking`: The refund path skips the currency check.
- `message`: Posted a review with 3 findings.

## What comes back

- `status`: completed
- `result`: Review posted on #212: 3 findings, 1 failing test
- `total_cost_usd`: 0.41

## Steps

1. **Connect the repository.** Install the Rush GitHub App on the repository and create a Project for it.
2. **Add the automation.** In the Project, add an automation with the prompt above and a GitHub trigger on `pull_request.opened` and `pull_request.synchronize`. Only work by an owner, member or collaborator fires it; pull requests from forks never do.
3. **Open a pull request.** Each push starts a run. Follow it live from the Project's run list, or let it finish.
4. **Read the review.** The review lands on the pull request. The run keeps its full record: every command it ran, the test output and what it cost.

Field names are the API's; the values are an example.
