Codex CI Autofix Loop (Fix Failing GitHub Actions)
An event-triggered loop where a red GitHub Actions build invokes `codex exec` non-interactively with the failing logs and repo, and Codex proposes a fix as a PR or patch artifact — one bounded iteration per CI failure.
Implementation note
When to use: repetitive CI failures — lint drift, snapshot updates, simple breakages — where a competent first-pass fix attempt on every red build would save real triage time. How it works: a CI job triggers on workflow failure and runs codex exec non-interactively with the failing logs and the repo as context; Codex generates a fix and proposes it as a PR or a patch artifact. Because codex exec runs one task and exits, each CI failure is one bounded iteration — the event is the trigger, so there is no long-running process to babysit. Safety: the rail is stated plainly in the source guidance: configure it to propose a PR, never auto-merge — every fix must land through human review, and an auto-merge variant of this loop is unsafe. The one-shot-per-failure structure also self-limits spend. Watch the early PRs for fix quality before trusting the pattern on subtle failures.
Source: OpenAI Cookbook ↗graded C · 55/100 — how grades work →
More ci loops
Get the build green
Run the build, fix the first error, and repeat until npm run build exits 0, with a 10-turn cap.
Get the build green, every time
Work through each task in .toh/plan.md, fix blockers, until the build command succeeds or you hit 40 turns.
Get lint and E2E tests passing
Execute work from PLAN.md until npm run lint and npm run test:e2e pass, scoping changes per AGENTS.md.