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.

prompt
→ Claude
CI job: on workflow failure, run `codex exec` non-interactively with the failing logs + repo, have it generate and propose a fix (PR or patch artifact) automatically. `codex exec` runs one task and exits, so each CI failure is one bounded iteration.
claude-code

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

More ci loops

Ship a PR through CI and reviews

/loopnew

Draft a PR, run CI, collect reviews, merge, and release—repeat every 30 minutes until land criteria are met.

prompt
→ Claude
/loop 30m /flow-next:land # ship loop: draft PR → CI green → reviews converged → merged → released
cihigh risk

Watch PR checks pass

/loopnew

Poll GitHub PR checks every 5 minutes until all status checks pass.

prompt
→ Claude
/loop 5m gh pr checks 1234
cilow risk

Wait for CI so you don't have to

/loopnew

Poll gh pr checks every 10 minutes and get told when the PR is ready to merge, or a summary of which checks failed and why.

prompt
→ Claude
/loop 10m run `gh pr checks 1234`; if all pass, tell me it's ready to merge; if any fail, summarize which and why
cilow risk