What the agent does
The agent reads the app as it is. In an app shaped like realworld-apps/angular-realworld-example-app it opens package.json and finds Angular 21.2 with standalone components, @rx-angular for templates, Vitest 4 through @analogjs/vite-plugin-angular for unit tests, Playwright for end-to-end tests, and a test:e2e script that runs the suite from the realworld/specs/e2e submodule. It reads src/app/app.routes.ts, where every route uses loadComponent or loadChildren: the home and tag pages, login and register guarded against signed-in users, settings and editor behind a requireAuth guard, profile from profile.routes.ts, and article/:slug. There is no ** route, so a mistyped URL renders the header, an empty router-outlet and the footer with no message and no way back.
The agent also reads how a missing resource behaves today. src/app/features/article/pages/article/article.component.ts loads the article in the constructor's pipeline with a catchError that sets an errors signal to Failed to load article, so a slug that does not exist shows an error list inside the article page rather than a not-found page. And src/app/core/interceptors/error.interceptor.ts handles HTTP errors for the whole app, which is where a 404 from the API could be turned into navigation if the prompt asked for it.
The change follows the app's own conventions. The agent adds src/app/core/layout/not-found.component.ts, a standalone OnPush component with RouterLink back to /, a short message and the container page classes the other pages use so it sits inside the same layout. In app.routes.ts it appends { path: '**', loadComponent: () => import('./core/layout/not-found.component') } as the last entry, because the router matches in order and a wildcard anywhere earlier would swallow the routes below it. In article.component.ts it narrows the catchError: a response whose status is 404 navigates to /not-found with skipLocationChange so the address bar keeps the slug, while any other error still fills the errors signal as before. A named not-found route is added just above the wildcard so that navigation has a target.
Tests go where the project keeps them. The unit suites under src/app are *.spec.ts files run by vitest with the jsdom environment from vitest.config.ts, so the agent adds not-found.component.spec.ts that renders the component with TestBed and asserts the message and the link, and extends articles.service.spec.ts's existing 404 case with a routing test that a 404 response leads to the not-found route. It runs npm test, then npm run build to be sure the new lazy chunk compiles, then npm run format:check since the repository runs Prettier through lint-staged and husky, and opens a pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a not-found page to this Angular app. Create a standalone NotFoundComponent under src/app/core/layout with a message and a RouterLink home, add it as a lazy-loaded named not-found route and as the final ** wildcard route in app.routes.ts, and change the article page so a 404 from the API navigates to it with skipLocationChange while other errors keep the current behaviour. Add a Vitest spec for the component and a routing test for the 404 case, run npm test, npm run build and npm run format:check, 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. The diff adds src/app/core/layout/not-found.component.ts and its spec, appends two entries to src/app/app.routes.ts, changes the catchError block in src/app/features/article/pages/article/article.component.ts, and extends one existing spec. No guard, interceptor or service changes, and the header and footer components are untouched because the new page renders inside the existing router-outlet. The description names the two URLs a reviewer can open to see it: any unknown path, and article/ followed by a slug that does not exist.
The repository's own workflows run on the pull request. .github/workflows/playwright.yml installs with Bun, runs bun run test:e2e against the dev server on port 4200, and uploads the report, and lint.yml checks formatting, so the existing end-to-end suite confirms that no real route was shadowed by the wildcard. The session's trajectory at GET /o/{org}/sessions/{id}/messages keeps every npm test and npm run build with its output.
Before merging, a reviewer checks that the ** entry is the last object in the routes array, that skipLocationChange is set on the article redirect so a reload of a bad slug does not land on /not-found permanently, and that the new component imports only RouterLink and nothing from the feature modules. Nothing reaches main until the pull request merges.
Run it on every new Angular app
A team that maintains several Angular front ends starts one run per repository with POST /o/{org}/sessions, this prompt and that repository in resources. Each run reads its own routes file and its own error handling, so an app that already has a wildcard gets only the article redirect, an app with a different layout folder gets the component where its header and footer live, and each opens its own pull request. Send a request_id per run so a retry returns the run already started.
Set a webhook_url on the API key and every run the key starts posts run.completed or run.failed when it finishes, with a session_url for the result, so a script can collect the pull request links. The key runs at most max_concurrent sessions at once, 4 by default; any session beyond that is created and answered 202 with status: "queued", then started oldest first as slots free.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A 404 page is a small component and one route, and the thing that goes wrong is ordering: a wildcard placed above a lazy route silently breaks that route, and the only way to know is to run the end-to-end suite or click through every page. Doing that on a laptop means a Bun install, a dev server on 4200 and Playwright browsers, with your working tree tied up until the branch is pushed. On Rush the run has its own sandbox with a computer and a browser in it, so the agent runs the unit suite, the build and a browser check as many times as it needs.
The result is checkable rather than claimed. The pull request shows the routes array with the wildcard last, the Playwright workflow runs the whole flow on the branch, and the trajectory keeps every test and build run with its output. Several apps mean several sandboxes and several pull requests at once.
Frequently asked questions
Will the wildcard route break deep links?
Not if it is last, which is where the agent puts it and what a reviewer checks. Angular matches routes in order, so article/:slug, profile and the rest match first and only a path none of them claim falls through to **. The existing Playwright suite covers the real routes, so a shadowed one would fail there.
Why keep the bad slug in the address bar?
Because skipLocationChange means a user who mistypes a slug sees the not-found page but can correct the URL in place, and a reload tries the article again rather than sticking on /not-found. If you prefer a real redirect, say so in the prompt and the agent drops that option.
Does the API's 404 still show inside the article page?
No. The catchError in article.component.ts now checks the status: a 404 navigates to the not-found route, and every other error keeps filling the errors signal exactly as before, so a server outage still shows the error list rather than a page that claims the article does not exist.
Is the new component lazy-loaded like the others?
Yes. Both the named route and the wildcard use loadComponent with a dynamic import, the same pattern every other entry in app.routes.ts uses, so the 404 page is its own chunk and adds nothing to the initial bundle. npm run build in the trajectory shows the chunk.
What tests are added?
A Vitest spec for the component, rendered with TestBed under the jsdom setup in src/test-setup.ts, asserting the message and the home link, and a routing case beside the existing 404 test in articles.service.spec.ts showing that a 404 response ends on the not-found route. The end-to-end suite is the repository's own and is not changed.
More Angular jobs
The same job on other stacks
- Add a Custom 404 Page to a React Router App (React Router)
- Add a 404 Page to a SolidJS App (SolidJS)
- Add a 404 Page to a Vue Router App (Vue)