All jobs

Fix a Failing CI Build in an Angular App

Yes. A failed workflow starts an agent that reads the log, reruns the Prettier check or the Playwright suite in a sandbox, and opens a pull request with the fix.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The run starts from a workflow_run.failure event with the workflow name, the branch and the head commit, and the agent reads the failed job's log with gh run view <run id> --log-failed before it clones anything. In an Angular app like realworld-apps/angular-realworld-example-app there are two workflows that can fail. .github/workflows/lint.yml, named Format Check, checks out with submodules: true, installs Bun with oven-sh/setup-bun@v2, runs bun install and then bun run format:check, which is prettier --check over ts, html, css, json and md files with realworld/** excluded. .github/workflows/playwright.yml, named Playwright Tests, does the same setup, installs Chromium with bunx playwright install --with-deps chromium, runs bun run test:e2e with CI=true under a sixty-minute timeout, and uploads playwright-report/ on every run and test-results/ on failure. Neither workflow runs the Vitest unit suite or ng build, so the agent runs those itself before it pushes.

A format failure is the easy case and the log says which files. .prettierrc sets singleQuote, printWidth 120, trailingComma all and arrowParens avoid, and .husky/pre-commit runs lint-staged, which formats staged files, so a red Format Check usually means a commit made with the hook skipped, a file type the lint-staged glob covers but a generated file does not, or a Prettier bump that changed its output. The agent runs bun install and bun run format:check on the commit, sees the same files, runs bun run format, and commits the result with no other change.

A Playwright failure takes more reading. playwright.config.ts extends baseConfig from realworld/specs/e2e/playwright.base inside the realworld submodule, which .gitmodules points at realworld-apps/realworld with ignore = dirty, sets testDir to ./realworld/specs/e2e and baseURL to http://localhost:4200, and starts npm run start as its webServer with a two-minute timeout and reuseExistingServer off on CI. The test:e2e script runs playwright test --grep-invert @security, leaving the @security tagged tests to test:e2e:security. The app itself calls https://api.realworld.show/api through src/app/core/interceptors/api.interceptor.ts, so the suite depends on a shared backend, and CLAUDE.md notes the tests read app state through window.__conduit_debug__. That gives three causes to tell apart: a change under src/app (a route guard in app.routes.ts, a component under features/article or features/profile, the debug hook), a submodule update that changed a spec, which README.md says needs bun run setup again, or the shared API being down. The agent reproduces with bun run setup, bunx playwright install --with-deps chromium and bun run test:e2e, reads the traces and screenshots in test-results/, and reruns the one failing spec by name to see whether it fails every time.

Then it fixes what it can prove. For an app change it edits the component, service or route under src/app, runs bun run test so the Vitest specs under src/**/*.spec.ts still pass, bun run build so ng build with the budgets in angular.json still succeeds, bun run format:check, and bun run test:e2e once more, and opens a pull request against the failing branch whose description names the job, quotes the first error from the log, and shows the same spec failing and then passing in the sandbox. For a cause that is not in this repository, the shared API or a spec in the submodule, it opens no pull request and ends with a result that names the spec, the request it saw fail and what to change where.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "The GitHub Actions workflow on this branch failed; the workflow_run event follows this prompt. Read the failed job's log with gh run view <run id> --log-failed and quote the workflow name and the first error. For Format Check, run bun install and bun run format:check, then bun run format, and commit only the formatting change. For Playwright Tests, run bun run setup to initialise the realworld submodule, bunx playwright install --with-deps chromium and bun run test:e2e, read test-results for the failing spec's trace and screenshot, and rerun that spec alone to see whether it is deterministic. Decide whether the cause is under src/app, a spec in the realworld submodule, or the shared api.realworld.show backend. Fix only a cause under src/app, then run bun run test, bun run build, bun run format:check and bun run test:e2e until all pass. Do not update the submodule, do not change the workflows or playwright.config.ts, and do not skip or retag a test. Open a pull request against the failing branch that names the job, quotes the first error, and shows the command failing and then passing in the sandbox; if the cause is outside this repository, open no pull request and say in your result which spec failed, what it requested and where the fix belongs.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  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

What comes back is a pull request against the failing branch. Its description names the workflow and job, quotes the first error from the log, and shows the same command failing and then passing in the sandbox with the Bun version used. For a Format Check failure the diff is formatting only; for a Playwright Tests failure it is the files under src/app the spec exercised, with the Vitest, build and format results quoted beside the end-to-end rerun.

The session read at GET /o/{org}/sessions/{id} names the branch and the pull request URL, and the transcript at GET /o/{org}/sessions/{id}/messages keeps the log read, the submodule setup, each bun run test:e2e invocation with its output, and the single-spec reruns, so a reviewer sees whether the failure was deterministic before the fix. When the cause is outside the repository the session's result says so and there is no pull request.

Before merging, a reviewer checks that the fix changes behaviour the spec actually tests rather than the path the spec takes to it, that no test was skipped or retagged, and lets both workflows run on the new commit, since the Playwright Tests workflow is the one check that exercises the app against the shared backend.

Run it on every failed CI run on a branch

Add an automation to the Project with this prompt and a github trigger on workflow_run.failure, or on check_suite.failure to cover every check, with branch_patterns for the branches you want watched. The trigger adds the run event after the prompt and fills in nothing, so the agent reads the run id and head commit from it. Only runs caused by someone who can write to the repository fire it; runs from forks never do, and the automation's max_runs_per_hour, between 1 and 30, keeps a branch that fails on every push from starting more than that many runs.

From your own server instead, a handler that receives GitHub's workflow_run webhook with conclusion set to failure sends POST /o/{org}/sessions with the run id written into input and a request_id that is a UUID v5 of the run id, so a redelivered webhook returns the run already started rather than a second one. Give that key a webhook_url and Rush POSTs run.completed when the turn ends, with data.session_url to read for the pull request.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

A red Playwright run on this app has three possible causes and only one of them is in the repository, and telling them apart means initialising a submodule, installing Chromium, starting ng serve and rerunning one spec several times while reading its trace. That is twenty minutes a person does not have between other work, and skipping it is how a flaky spec gets retagged. The agent does it in its own sandbox with the same Bun and Chromium the workflow installs.

The pull request carries the proof: the log line, the reproduction, the fix and the passing rerun, with the unit tests and the build run as well even though CI does not run them, and the transcript shows every attempt. When the cause is the shared backend or the submodule, the result says so with the failing request, so nobody opens a pull request to fix the wrong repository. Several failing branches run at once, each in its own sandbox.

Frequently asked questions

Which Bun and Node versions does the sandbox use?

The workflows install Bun through oven-sh/setup-bun@v2 with no version pinned and the repository has no .nvmrc, so the agent uses the current Bun release, which is what CI gets, and a Node that satisfies the >=20.11.1 engine in package.json. It records both versions in the pull request so a difference from CI is visible.

What if the shared RealWorld API is down?

The app sends every request to https://api.realworld.show/api through api.interceptor.ts, so an outage there fails the Playwright suite with no change to this repository. The agent sees the failing requests in the trace, reruns the spec, and ends with a result that names the endpoint and opens no pull request.

Will it update the realworld submodule?

No. The prompt forbids it, because a submodule bump changes which specs run against the app and belongs in its own pull request. If the failing spec changed in the submodule and the app has not caught up, the result says which spec and what the app would need to change.

Does it run the @security tests?

No. test:e2e runs playwright test --grep-invert @security, which is what the Playwright Tests workflow runs, and the agent reproduces the workflow's command. The test:e2e:security script that runs only those tests is a separate job you can ask for in a follow-up.

Why does CI check formatting when there is a pre-commit hook?

Because .husky/pre-commit runs only on a machine where bun run prepare installed the hook and only on staged files, so a commit made with the hook skipped or from an editor without it reaches CI unformatted. The Format Check workflow catches that, and the fix is a bun run format commit.

More Angular jobs

The same job on other stacks

Keep reading