What the agent does
The agent reads the diff and picks the test layer that can see each change, using the layout of cypress-io/cypress-realworld-app. A changed function in backend/database.ts gets a Vitest case in src/__tests__/transactions.test.ts, which reseeds with seedDatabase() in beforeEach; vite.config.ts runs those files with fileParallelism: false because they share one JSON database. A changed component gets a component spec beside it in the style of src/components/SignInForm.cy.tsx.
A changed flow gets a case in a spec like cypress/tests/ui/new-transaction.spec.ts: cy.task("db:seed"), cy.intercept aliases, cy.loginByXstate, and a wait on @createTransaction, never on milliseconds. It uses Node 22.20.0 from .node-version and runs yarn types and yarn lint on the new files.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This pull request changes a React 18 app with an Express API in backend/ and three test layers: Vitest in src/__tests__ and src/utils/__tests__, Cypress component specs beside components as src/**/*.cy.tsx, and Cypress e2e specs in cypress/tests/ui and cypress/tests/api. Read the pull request's diff against its base branch, taking the head and base commits from the pull request itself, and list the new or changed behavior no test covers, with file and line. For each item write the test in the layer that can see it, following the existing file's style: seedDatabase() in beforeEach for database functions, data-test selectors through cy.getBySel for components, and cy.task('db:seed'), cy.intercept aliases and cy.loginByXstate for flows. Never wait on a number of milliseconds. Use Node 22.20.0 and yarn install --frozen-lockfile, then run yarn types, yarn lint and yarn test:unit:ci; run a component spec with yarn cypress:run:component and an e2e spec by building with yarn build:ci, starting yarn start:ci and running yarn cypress:run --spec <file>. Do not change application code, do not commit or push, and do not open a pull request. Post one review on the pull request that lists each untested behavior with file and line, the test that covers it, the command that ran it and its result, and the new tests as one patch. A test that fails because the code is wrong goes in the review as a possible bug, not as a passing test. If this run names no pull request, in resources or after this prompt, stop and say so.",
"resources": [
{
"url": "https://github.com/your-org/your-app/pull/123"
}
]
}- 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.
- 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.
- 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
What comes back is one review on the pull request and nothing pushed. The review lists each untested behavior by file and line, the Vitest case, *.cy.tsx spec or cypress/tests/ case written for it, and the summary line of the command that ran it, with the browser for a Cypress run. The patch is in the review.
Two decisions stay with the reviewer: whether to apply the patch to the branch, and whether a test the review lists as failing is a bug in the change or a wrong expectation.
Run it on every pull request opened against develop
An automation with this request as its prompt and a github trigger on pull_request.opened and pull_request.synchronize, branch_patterns develop (the repository's default branch), runs it for each new pull request and each push to one. Only work by an owner, member or collaborator fires it, and a fork's pull request never does. The event names the pull request's URL, title, author, labels and base branch but no commits, so the prompt reads the head and base from that URL.
The use case this job follows, with its automation and trigger: Review every pull request.
Why run it on Rush?
An e2e case here needs a production build, the Express API on port 3001, a reseeded data/database.json and a real Chrome before it means anything. The sandbox runs all of that per pull request, so a review that says a Cypress case passed is quoting cypress run, not guessing.
Frequently asked questions
Why a patch and not a commit on the branch?
The per-pull-request recipe reviews and does not push, so the author keeps the branch. Once they apply the patch from the review, the five-container Chrome, Firefox and mobile matrix in .github/workflows/main.yml runs the new cases.
Which layer does it pick for a changed component?
A component spec beside it, as SignInForm.cy.tsx is, mounted through cypress/support/component.ts. A Vitest case is used only for a function with no rendering, such as one in src/utils/.