# Review Pull Requests Automatically in a Phoenix App

An agent reviews a hexpm pull request that moves syntax highlighting into a pool of lumis processes: 2 blocking findings, 5 suggestions, tests run.

[Run this on Rush](https://cloud.getrush.ai/run/review-pull-requests/phoenix/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The prompt points the review at package publishing and API controllers, but hexpm/hexpm #2004 touches neither. The agent says so and reviews what the 15 files do change: `HexpmWeb.SyntaxHighlight` now hands work to a `NimblePool` of `lumis serve` processes in the new `syntax_highlight/pool.ex`, started from `lib/hexpm/application.ex`, with settings in `config/runtime.exs` and metrics in `prom_ex/plugins/hexpm.ex`.

It reads the three callers of the highlighter (`preview_live.ex`, `diff_live.ex` and `readme/renderer.ex`), the `mix.exs` dependency and `mix.lock`, and `test/test_helper.exs`. The `test` alias runs `ecto.create`, `ecto.load` and `ecto.migrate` first, so after three failed attempts it runs a disposable Postgres 14, the CI image's major version.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Review the Phoenix pull request identified by the URL, base SHA and head SHA the caller appends below. Require the PR identity and verify the checked-out head. Read mix.exs, mix.lock, CI and test configuration, then install dependencies with mix deps.get using compatible Elixir and OTP. Review changes to package publishing and API controllers with surrounding authorization, repository scope, persistence and tests. Use disposable Postgres, never production data; run relevant ExUnit tests and mix test, noting the alias's database setup. Post one GitHub review with current-head file-and-line findings, a concrete failure scenario for each, blocking issues separated from suggestions, exact test results and limits of test doubles. If posting is unavailable, return the review and state it was not posted. Do not change source, push commits, publish packages or merge.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on hexpm/hexpm at 9499567: pull request #2004, a draft (15 files), reviewed with 2 blocking findings and 5 suggestions, each with a file, line and failure scenario. The highlighter and LiveView tests returned `Result: 191 passed` on two runs, and the full `mix test` ended `Result: 4439/4441 passed (32/32 properties, 4407/4409 tests)`. One failure, in `Hexpm.Diff.GeneratorTest`, repeats in code the pull request does not touch; the run believes it is its local git 2.39.5 but did not run main to confirm. The other passed on rerun. The review was not posted.

For the reviewer: whether production should depend on the unreleased `ericmj/lumis` branch `hexpm-serve` with `override: true`, and whether a pool that fails to start should stop the boot or raise an alert instead of quietly serving plain text.

## Run it on every pull request into main

An automation with a `github` trigger on `pull_request.opened` and `pull_request.synchronize` and `branch_patterns` set to `main` reviews every push from a maintainer's branch like #2004. The event carries the URL but no SHAs, so have the saved prompt read them from it. A fork's pull request fires no trigger; start it from the console with the URL and SHAs appended.

## Why run it on Rush?

This change compiles, passes its own tests and adds no mocks: the new tests drive real `lumis serve` processes. What it risks shows only when the agent reads how the pieces start together: `init_pool/1` blocks startup for up to 60 seconds before `HexpmWeb.Endpoint` starts, and a missing `priv/native/lumis` makes the pool return `:ignore`, leaving one `Logger.error` line as the only trace.

## Frequently asked questions

### What did it take to run mix test?

Erlang 29.1 and Elixir 1.20.4 from builds.hex.pm, `zig cc` as the C compiler, and three Postgres attempts: a SQL_ASCII cluster, a missing `psql`, and a build without the `citext` extension, before Zonky's Postgres 14 passed setup. The Dockerfile and its Rust 1.99 pin were not built.

### Why did it not review the publishing and API code the prompt named?

The pull request changes none of it; the review says so.

## More Phoenix jobs

- [Add Missing Tests to Every Pull Request in a Phoenix App](https://getrush.ai/run/test-every-pull-request/phoenix/)
- [Upgrade Phoenix 1.7 to Phoenix 1.8](https://getrush.ai/run/upgrade-framework-major/phoenix/)
- [Upgrade Hex Dependencies in a Phoenix App](https://getrush.ai/run/upgrade-hex-dependencies/phoenix/)

## The same job on other stacks

- [Review Pull Requests in a Playwright Test Suite](https://getrush.ai/run/review-pull-requests/playwright/)
- [Review Pull Requests on a Python Library](https://getrush.ai/run/review-pull-requests/python/)
- [Review Pull Requests on a Quarkus Service](https://getrush.ai/run/review-pull-requests/quarkus/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
