What the agent does
The agent reads the test setup before it measures anything. In a Symfony app like symfony/demo, phpunit.dist.xml bootstraps tests/bootstrap.php, forces APP_ENV=test, fails on any deprecation, notice or warning, declares src as the only <source> directory, and loads the DAMA Doctrine test bundle extension so each test runs in a rolled-back transaction. .env.test points DATABASE_URL at data/database_test.sqlite, and config/packages/dama_doctrine_test_bundle.yaml turns on the static connection under when@test. composer.json requires PHP 8.4 or newer, pins the platform to php: 8.4.1, and lists phpunit/phpunit 11.5 in require-dev; the auto-scripts block runs cache:clear, assets:install, importmap:install and sass:build on every install, which is why a sandbox install takes the same steps CI does.
Then it reads the workflows. .github/workflows/tests.yaml runs vendor/bin/phpunit on a matrix of PHP 8.4 and 8.5 on Ubuntu plus 8.4 on macOS and Windows, through shivammathur/setup-php with coverage: "none" and the intl, mbstring, pdo_sqlite and zip extensions, after composer install --ansi --no-interaction --no-progress and a PHPUnit problem matcher. lint.yaml runs PHP-CS-Fixer from its Docker image, the console linters for YAML, Twig, XLIFF, translations and the container, doctrine:schema:validate, composer audit and PHPStan at level 6 from phpstan.dist.neon. There is no coverage driver, no coverage artifact and no floor, so a change that deletes half the tests under tests/Controller, tests/Command, tests/Form, tests/Twig and tests/Utils still goes green.
The agent measures first. It installs PHP 8.4 with pcov in the sandbox, runs composer install so the auto-scripts build the assets the controller tests render, and runs vendor/bin/phpunit --coverage-clover coverage.xml --coverage-text to get the line coverage of src as it is today, with the per-file table that shows where the gaps are among src/Controller, src/Command, src/EventSubscriber, src/Form, src/Pagination and src/Twig. That number, rounded down, becomes the floor.
The change is small and stays inside the files that already exist. tests.yaml gains one job, coverage, on Ubuntu with PHP 8.4 and coverage: pcov, which runs PHPUnit with --coverage-clover and --coverage-text, uploads coverage.xml as a workflow artifact, and fails when the total line rate in the Clover file is below the floor, checked by a short PHP script added under bin/ that reads the <metrics> element, so no new Composer dependency is needed. The matrix job is untouched, so the macOS and Windows legs stay as fast as they are. phpunit.dist.xml is left alone: the <source> block already names src, and the flags live in the workflow where the floor is.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add test coverage reporting to this Symfony application's GitHub Actions. Read .github/workflows/tests.yaml and lint.yaml, phpunit.dist.xml, tests/bootstrap.php, .env.test, config/packages/dama_doctrine_test_bundle.yaml and composer.json first, and reuse what exists. In the sandbox install PHP 8.4 with pcov and the extensions tests.yaml lists, run composer install so the auto-scripts build the assets, and run vendor/bin/phpunit --coverage-clover coverage.xml --coverage-text to measure today's line coverage of src. Add one coverage job to tests.yaml on Ubuntu with PHP 8.4 and coverage set to pcov that runs PHPUnit with the clover and text reporters, uploads coverage.xml as an artifact, and fails below today's coverage rounded down, using a short PHP script under bin/ that reads the Clover metrics rather than a new dependency. Leave the existing matrix job, phpunit.dist.xml and lint.yaml unchanged. Run the new script against your coverage.xml, run vendor/bin/php-cs-fixer check on the files you added and vendor/bin/phpstan analyze, and open a pull request with the coverage table from --coverage-text, the floor you set and the files you changed. Write no new tests.",
"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 changes .github/workflows/tests.yaml by adding a coverage job and adds one script under bin/ that reads a Clover file and exits non-zero below a floor. The matrix job, phpunit.dist.xml, lint.yaml and composer.json are unchanged, and no test is added or edited.
The description pastes the --coverage-text summary from the sandbox run, with the per-file lines for src, states the floor it chose and why it is rounded down, and shows the script's output on that file. It names the setup-php coverage: pcov input as the only difference between the new job and the matrix legs.
A reviewer checks the floor against the pasted table, confirms the artifact upload and the script, and merges. From then on a pull request that drops coverage below the floor fails the coverage job with the number in the log, and the uploaded coverage.xml shows which files lost lines.
Run it on every new Symfony repository
Start one run per repository by hand with POST /o/{org}/sessions, this prompt in input and the repository in resources; each runs in its own sandbox with its own PHP and Composer install. When several applications share the same workflow shape, a saved agent holding the prompt as instructions makes each call {"agent": "<agent id>", "input": "..."} with only the repository changing.
Give the key a webhook_url to get run.completed with data.session_url when each pull request is open, or poll GET /o/{org}/sessions?status=completed. A request_id per repository makes a retried call return the run it already started.
The use case this job follows, with its automation and trigger: Write the missing tests.
Why run it on Rush?
A coverage floor you did not measure is a guess, and a guess set too high blocks the next pull request while one set too low means nothing. Measuring takes a PHP with a coverage driver, a Composer install that builds assets, and a full PHPUnit run, which is what the sandbox does before the workflow changes, and the number it found is in the pull request.
Keeping the measurement and the workflow change in one run means the floor and the job that enforces it were tested together, with the output in the transcript. The same prompt on another Symfony application reads that application's workflow and PHPUnit file rather than assuming this one's.
Frequently asked questions
Why pcov and not Xdebug?
Both are coverage drivers that setup-php installs through the coverage input, and pcov is the faster of the two for line coverage, which is all the floor needs. The repository's matrix legs keep coverage: "none", so only the one new job pays for the driver.
Will the new job slow the macOS and Windows runs?
No. The coverage job is a separate job on Ubuntu with PHP 8.4; the matrix job in tests.yaml is unchanged and still runs with coverage: "none" on every operating system it lists today.
Does it add a coverage service or a badge?
No. The job uploads coverage.xml as a workflow artifact and enforces the floor with a script in the repository, so nothing outside GitHub is involved. Sending the Clover file to a hosted service is a one-line step a reviewer can add to the job afterwards.
Why not raise coverage while it is there?
Because that is a different pull request. The prompt forbids new tests so the change is only the measurement and the floor, which is quick to review. A second run with a write-tests prompt can take the per-file table from this pull request and fill the gaps it shows.