What the agent does
The agent clones the repository into its own sandbox and reads how component testing is already set up, so the new tests look like the old ones. In cypress-io/cypress-realworld-app, cypress.config.ts has a component block with the React framework and the Vite bundler, using vite.cypress.config.ts (its own dev server on port 3002), specPattern: "src/**/*.cy.{js,jsx,ts,tsx}" and cypress/support/component.ts, which loads @cypress/code-coverage/support and registers cy.mount from cypress/react. Cypress is 16.1.1 in yarn.lock. Of the components under src/components, four have a .cy.tsx beside them: AlertBar, SignInForm, TransactionDateRangeFilter and TransactionTitle, plus TransactionsContainer under src/containers.
SignInForm.cy.tsx shows the house pattern: it starts the real authMachine with xstate's interpret, wraps the component in a MemoryRouter from react-router-dom 5.3.4, stubs POST http://localhost:3001/login with cy.intercept, and selects elements by data-test attributes. The agent picks the untested forms that hold the most rules. BankAccountForm validates with yup: a bank name of at least 5 characters, a routing number of exactly 9, an account number of 9 to 12, and on submit calls createBankAccount with the values and userId, then navigates to /bankaccounts unless onboarding is set. UserSettingsForm requires first name, last name, a valid email and a phone number matching phoneRegExp, and calls updateUser with the user's id. TransactionCreateStepTwo requires an amount and a note and has separate request and payment submit buttons.
Each test mounts the form with cy.mount, passes cy.stub() for callbacks like createBankAccount and updateUser, and asserts what a user sees: the helper text each yup rule produces once a field is touched, the submit button's disabled state while the form is invalid, and the exact arguments the callback receives. For BankAccountForm the router is a MemoryRouter whose location the test reads after submit, so the /bankaccounts navigation and the onboarding case are both checked. Reading UserSettingsForm it also notices that phoneRegExp is written with doubled backslashes, so \\+ matches backslashes rather than a plus sign; it includes a number with a leading + and records what the form does as a finding instead of changing the regex.
To run them it installs the system libraries Cypress lists for Linux, runs yarn install with Node from the engines range (22 or 24), and runs yarn test:component:ci, which is cypress run --component, until every spec passes, then yarn types and yarn lint. It also notes that .github/workflows/main.yml runs types, lint, Vitest unit tests and the end-to-end suites in Chrome and Firefox, but never test:component:ci, so neither the existing component tests nor the new ones run in CI today.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Write Cypress component tests for the untested forms in src/components, starting with BankAccountForm, UserSettingsForm and TransactionCreateStepTwo. Read cypress.config.ts, vite.cypress.config.ts, cypress/support/component.ts and every existing .cy.tsx first, and follow SignInForm.cy.tsx: cy.mount, a MemoryRouter where the component uses routing, data-test selectors, and cy.intercept for any network call. For each form, cover every yup rule's message, the submit button's disabled state, and the exact arguments passed to its callback, using cy.stub. For BankAccountForm check the navigation after submit with and without onboarding. Do not change component code; list anything that looks wrong as a finding. Install Cypress's Linux dependencies, then run yarn test:component:ci, yarn types and yarn lint until they pass. Say in the pull request whether CI runs component tests today, but do not change the workflow. Open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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 a pull request that adds .cy.tsx files beside the components they test, for example src/components/BankAccountForm.cy.tsx, and changes no component. Each file has one it per rule or path, named for what it checks, and the description lists the tests per component with the rule each covers, plus the findings, such as what the phone validation does with a leading +.
The session transcript keeps every cypress run --component with its output, including failures while selectors and stubs were being worked out, and the final passing run with yarn types and yarn lint. Because main.yml does not run component tests, the pull request's checks show the end-to-end and unit suites still passing, not the new specs; the description says so plainly and quotes the passing component run from the sandbox.
Before merging, a reviewer checks that tests assert the messages a user sees rather than Formik's internal state, that stubs are created per test so no test depends on order, and whether to add yarn test:component:ci to main.yml in a follow-up so these tests keep running.
Run it on every component merged without a test
Once the forms are covered, keeping new components covered is a smaller job each time. An automation in the Project with a github trigger on pull_request.opened, branch_patterns set to your default branch, and a prompt that says "for any component this pull request adds under src/components without a .cy.tsx, write one and open a pull request with it" runs once per pull request. Each fire adds the pull request after the prompt; only work by an owner, member or collaborator fires it.
To backfill the rest of src/components in parallel, a script sends one POST /o/{org}/sessions per component with its name in input. A key runs at most its max_concurrent sessions at once (4 by default); later starts answer 202 with status: "queued" and begin as slots free.
The use case this job follows, with its automation and trigger: Write the missing tests.
Why run it on Rush?
Cypress component tests need a real browser, the Cypress binary and its Linux libraries, and a Vite dev server, and getting cy.mount to work with this app's router and xstate machines takes a few failed runs. In a Rush sandbox the agent installs all of that on a machine that exists for this run and iterates with cypress run --component until the specs pass, without touching a developer's Cypress cache or ports.
The transcript is the proof that the tests pass, which matters more here than usual: this repository's CI does not run component tests, so the sandbox run quoted in the pull request is the only passing run a reviewer will see until someone adds them to main.yml.
Frequently asked questions
Why component tests and not more end-to-end tests?
The forms' rules are cheaper to cover one component at a time. A component test mounts BankAccountForm alone and checks each yup message in a second or two, while an end-to-end test needs the backend, seed data and a signed-in user. The existing end-to-end suites stay as they are.
Will it change our forms to make them easier to test?
No. The prompt says not to change component code. Anything that looks wrong, like the phone validation, is listed as a finding for you to decide on.
Can it add component tests to our CI as well?
Yes, in a follow-up to the same session. Ask it to add yarn test:component:ci to main.yml and it adds a job, runs the steps in the sandbox first, and pushes to the same branch.
We use React Router 6, not 5. Does that matter?
Only for the wrapper. The agent reads which router version your package.json has and uses the matching MemoryRouter and the way that version exposes the current location in tests.