What the agent does
The agent clones the repository into its own cloud sandbox and reads how orders change status before writing a notification. In an app like filamentphp/demo (Laravel 12, Filament 5, PHP 8.4 in CI, Pest 3 and Larastan at level 8), App\Models\Shop\Order casts status to the App\Enums\OrderStatus enum with the cases New, Processing, Shipped, Delivered and Cancelled, belongs to App\Models\Shop\Customer, which has an email column, and uses soft deletes. The status is changed from several places: OrderForm.php exposes it as ToggleButtons, so the edit page can set any value; OrdersTable.php has row actions that move an order from New to Processing, from Processing to Shipped and from Shipped to Delivered, each calling $record->update(['status' => ...]); and EditOrder.php has a Replicate action that resets a copy to New. There is no app/Mail, no app/Notifications and no observer, and .env.example sets MAIL_MAILER=smtp against a local Mailhog on port 1025 with QUEUE_CONNECTION=sync.
Because the status is written from many code paths, the agent hooks the model rather than each action. It adds App\Observers\OrderObserver with an updated method that checks $order->wasChanged('status'), skips orders with no customer or no customer email, and sends App\Notifications\OrderStatusChanged to the customer; the observer is attached with the #[ObservedBy] attribute on the Order model, and Customer gains the Notifiable trait with routeNotificationForMail returning its email. The notification implements ShouldQueue, uses the mail channel, and renders a Markdown mail template at resources/views/mail/orders/status-changed.blade.php whose subject and body depend on the new status: Processing confirms the order is being prepared, Shipped names the shipping method from the order, Delivered thanks the customer, and Cancelled says so plainly. A change to anything other than status, a change to New, and a soft delete send nothing.
Tests follow the repository's Pest setup under tests/. A feature test uses Notification::fake() with the existing OrderFactory and customer factory to assert that updating status from New to Processing sends OrderStatusChanged to the customer with the right status in its payload, that updating notes sends nothing, that an order whose customer has no email sends nothing, and that the mail renders without error for all five statuses. A second test drives the panel the way a user does, calling the Processing action on the orders table through Filament's Livewire testing helpers, and asserts the notification is sent, so the observer is proven to run from the UI path and not only from a direct model update.
The agent runs composer test in the sandbox, which is pest --parallel followed by phpstan analyse at level 8 over app, and vendor/bin/pint --test with the repository's pint.json rules, fixing anything they report. Because queueing with QUEUE_CONNECTION=sync runs the notification inline, the pull request says that a production deploy needs a queue driver and a worker for the email not to delay the panel action, and it adds MAIL_FROM_ADDRESS to the list of variables to set, since .env.example leaves it null.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Send customers an email when an order's status changes in this Filament app. Read the Order model, the OrderStatus enum, the orders resource with its form, table actions and pages, and the mail and queue config first. Hook the status change at the model level so the edit form, the table actions and any other update all trigger it, send a queued notification to the order's customer with wording per status, skip orders without a customer email and skip changes that do not touch the status. Add Pest tests with Notification::fake for the model path and for one table action through Filament's testing helpers, make PHPStan and Pint pass, and 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 on its own branch adding app/Observers/OrderObserver.php, app/Notifications/OrderStatusChanged.php, resources/views/mail/orders/status-changed.blade.php and two test files, and changing app/Models/Shop/Order.php and app/Models/Shop/Customer.php. No Filament resource file changes, which is the point of the observer. The description lists the statuses and the subject line each one gets, and shows the Pest, PHPStan and Pint output from the sandbox.
The run's record keeps the test run with every test name and the static analysis output, so a reviewer can see which paths are covered, including the table action test, without running anything locally.
Before merging, a reviewer reads the five email texts, decides whether a status set directly on the edit form to the same value should be treated as a change (it is not, because wasChanged compares values), and sets the queue connection and MAIL_FROM_ADDRESS for the environment where this goes live.
Run it on every Linear issue labelled customer-email
Shop features like this usually arrive as tickets. Add an automation in the Project with a linear trigger on linear.issue.labeled for a label such as customer-email and this prompt; when the label is applied, a run starts with the issue appended after the prompt, so the agent reads the requested wording and edge cases from the ticket, and the pull request links back to it. Linear is connected once under Settings → Connections, and a label applied by another app integration never fires the trigger.
From a script, POST /o/{org}/sessions with this body and the issue URL in resources does the same through your Linear connection. A request_id, a UUID v5 of the issue id, makes a repeated call return the run it already started.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
The easy version of this feature hangs a Notification::send on one table action and misses the edit form, the bulk action and the next developer's new button. The agent reads every place the status is written, picks the model hook that covers all of them, and proves it with a test that goes through the panel.
The sandbox runs Pest, PHPStan at level 8 and Pint for real, and the run's record keeps the output, so the pull request shows the suite passing on the branch. Several shops, or several notification features, can be done at once in separate sandboxes.
Frequently asked questions
Which status changes send an email?
Any change of the status column to Processing, Shipped, Delivered or Cancelled on an order whose customer has an email address. A new order, a change to another field, a status saved with the same value and a soft delete send nothing. The pull request lists the subject line for each status.
What if an order has no customer or the customer has no email?
The observer returns before sending. The orders form requires a customer, but the model allows updates without one and the demo seeder may create such rows, so the guard is tested explicitly.
Will this send real mail from my development environment?
Only to whatever MAIL_MAILER points at, which in .env.example is a local Mailhog. The tests use Notification::fake() and never send. With QUEUE_CONNECTION=sync the notification runs inline; set a real queue driver and run a worker in production so the panel action does not wait on SMTP.
Does it cover changes made from the edit form as well as the table actions?
Yes. The observer runs on every Eloquent update or save, so the ToggleButtons field on the edit page, the row actions, the replicate action and any future code path that saves the model all trigger it. A raw query builder update() bypasses Eloquent events, and the pull request says so.
Can I change the wording?
The subjects and the per-status paragraphs are in one Markdown Blade template and one match on the enum in the notification class. Edit the template and the tests that render each status still pass as long as the view compiles.
More Filament jobs
More jobs like this: Turn a Linear label into a PR
- Add Order Webhooks to a Shopify App (Shopify app)
- Add Output Channel Logging to a VS Code Extension (VS Code Extension)
- Set a Document Title per Page in a SolidJS App (SolidJS)