# Review Pull Requests on a WordPress Plugin

Yes. The agent runs PHPCS and PHPStan on the branch, then reads the diff for the capability, nonce, sanitizing and escaping checks a linter cannot confirm.

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

## What the agent does

A WordPress plugin review has a mechanical half and a judgment half, and the agent does the mechanical half first so the judgment has evidence. In a plugin like WordPress/two-factor, `composer.json` declares the type `wordpress-plugin` and three scripts that need no WordPress install: `composer lint` runs PHPCS with the rules in `phpcs.xml.dist` (the `WordPress` and `WordPress-VIP-Go` standards and `PHPCompatibilityWP` from PHP 7.4 up), `composer lint-compat` runs the compatibility standard on its own, and `composer lint-phpstan` runs PHPStan with `phpstan.dist.neon` and the `szepeviktor/phpstan-wordpress` extension. The agent runs `composer install` and then all three on the pull request's branch and on the base branch, so it can report what the pull request added and not what was already there.

The linters catch a known class of mistake. Given a function that echoes `$_GET['name']` and saves `$_POST['x']` with `update_option`, PHPCS with this ruleset reports the unescaped output, the input used without sanitizing and the form data processed without a nonce. It says nothing about who is allowed to call the function. So the agent reads every changed hook, AJAX action, admin form handler and REST route for the check a linter cannot see: a `current_user_can` call with the right capability and, where the code acts on another user, the right object. This plugin shows the pattern to hold a pull request to. Its REST routes in `providers/class-two-factor-totp.php` pass `permission_callback` to `Two_Factor_Core::rest_api_can_edit_user_and_update_two_factor_options`, which requires `edit_user` for the target user and then a recent second-factor check.

It reads suppressions as carefully as code. The ruleset already tells PHPCS that `two_factor_is_valid_user_action` counts as nonce verification, and the non-test source carries 41 `phpcs:ignore` comments, most of them in `class-two-factor-core.php`. A pull request that adds another one, or that widens an `exclude-pattern` in `phpcs.xml.dist`, gets a comment asking what makes the line safe. The agent also holds the diff to the rules the repository wrote for itself in `AGENTS.md`: files under `includes/` are kept close to WordPress core and are not to be edited, and compatibility code for other plugins belongs in `class-two-factor-compat.php`.

The last checks come from the repository's own pull request template, which calls for tests and documentation with new code, a changelog entry line, testing instructions and a statement on the use of AI tools. The agent checks each against the diff: a changed provider with no change under `tests/providers/`, a new filter with no docblock, a blank changelog line. The PHPUnit suite itself runs through `wp-env`, which needs Docker and a WordPress install, so the agent does not claim a test result: it leaves the suite to the repository's own test workflow on the pull request and says so in the review.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Review the open pull request in resources on our WordPress plugin. Read composer.json, phpcs.xml.dist, phpstan.dist.neon, the workflows under .github/workflows, the pull request template, AGENTS.md or CONTRIBUTING.md if present, and the main plugin file first. If php or composer is missing in your sandbox, install them, then run composer install. Run the project's PHPCS, PHP compatibility and PHPStan scripts on the pull request's branch and on the base branch, and report only what the pull request adds or fixes. Then read the diff. For every changed or new hook callback, admin form handler, AJAX action and REST route, state which capability check guards it and whether it checks the specific object being changed; flag any that has none or relies on a nonce alone. Flag request data used without wp_unslash and a sanitizing function, output without an escaping function, redirects that are not wp_safe_redirect, secrets compared without hash_equals, and SQL built without prepare. Question every phpcs:ignore, phpstan ignore and ruleset exclusion the pull request adds. Hold the diff to the repository's own rules for which files may be edited. Check the pull request against its template: tests for changed behaviour, docblocks for new hooks, a changelog entry and testing instructions. Do not run the PHPUnit suite if it needs Docker; say in the review that you did not run it and that the repository's test workflow covers it. Post one review with the command results first, then findings by file and line, each with the fix. Do not push commits.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app/pull/42"
    }
  ]
}
```

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

One review on the pull request. It opens with a results block for PHPCS, the compatibility check and PHPStan: clean, or the new violations by file and line with the sniff or rule name, and a note of any that the pull request fixed. Next is a table of the entry points the diff touches, one row each, with the capability and nonce that guard it or the word none.

Findings follow at their lines. A handler that verifies a nonce and never checks a capability gets the explanation that a nonce proves the request came from a page the site rendered, not that this user may do this thing, with the `current_user_can` call to add. Each new suppression comment gets a question. Template gaps are listed last: no test for the changed provider, no changelog line.

The review comments and leaves the decision to a maintainer. Whether a new filter is public API the plugin must support for years, and whether a change that is safe on a single site is safe when the plugin is network-activated, are calls for the people who maintain it. The agent states plainly that it did not run the PHPUnit suite and that the test workflow on the pull request is where that result lives.

## Run it on every pull request

An automation in the Project that holds the repository, with this prompt, read-only switched on and a `github` trigger on `pull_request.opened` and `pull_request.synchronize`, starts a review when a pull request opens and on each push to it. The trigger puts the event after the prompt and fills in nothing. With read-only on, the run can read the repository and comment and cannot push.

The trigger fires for owners, members and collaborators and never for forks, and a plugin with outside contributors gets most of its pull requests from forks. For those, a maintainer who has read the diff pushes the contributor's commits to a branch in the repository itself and opens a pull request from it, which starts the review. A team that wants reviews on request uses `pull_request.labeled` with a label in `labels`.

## Why run it on Rush?

The review runs other people's code: `composer install` pulls a dependency tree and the linters execute over a branch a stranger may have written. Doing that in a sandbox that holds only this checkout is safer than doing it on a maintainer's laptop next to their credentials. The commands and their full output stay in the transcript at `GET /o/{org}/sessions/{id}/messages`, so a maintainer can see the exact PHPCS line behind each finding.

It also gives every pull request the same first pass. Volunteers review plugin code when they have time, and the entry-point table is the part that is tedious to build by hand and costly to skip. With that table already on the pull request, the maintainer's time goes to the questions only they can answer.

## Frequently asked questions

### Can it run the plugin's PHPUnit tests?

Not the way this plugin runs them. Its tests execute inside `wp-env` containers, and the sandbox has no Docker. The lint and static analysis scripts need only PHP and Composer, so the agent runs those and leaves the suite to the workflow on the pull request. A plugin whose tests run against a local WordPress test library and a database can have them run in the sandbox; say how in the prompt.

### Does it follow WordPress coding standards or its own taste?

The repository's ruleset. It runs the PHPCS configuration the project committed and reports sniff names from it, and it does not add style opinions on top. If your plugin has no `phpcs.xml.dist`, the agent says so and limits itself to the security and correctness checks.

### Will it catch a missing capability check?

That is the main reason to have it read the diff and not only run the linter. PHPCS with the WordPress standards flags missing nonces, sanitizing and escaping, and has no rule that knows who should be allowed to call a function. The agent lists every entry point the diff touches with the check that guards it, so a missing one shows up as an empty cell.

### Does the review disclose that an AI wrote it?

Tell it to in the prompt. A project that asks contributors to disclose AI use in pull requests, as this one's template does, can have the review open with a line saying an agent wrote it and which commands it ran. The findings stand or fall on the file and line they cite either way.

## More WordPress plugin jobs

- [Run a Security Audit on a WordPress Plugin](https://getrush.ai/run/security-audit/wordpress-plugin/)

## The same job on other stacks

- [Review Pull Requests on an Actix Web API](https://getrush.ai/run/review-pull-requests/actix/)
- [Review Pull Requests Automatically in an Angular App](https://getrush.ai/run/review-pull-requests/angular/)
- [Review Pull Requests on an Ansible Role](https://getrush.ai/run/review-pull-requests/ansible/)
- [Review Pull Requests on an ASP.NET Core App](https://getrush.ai/run/review-pull-requests/aspnet-core/)
- [Review Pull Requests Automatically in an Astro Site](https://getrush.ai/run/review-pull-requests/astro/)

## 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/)
