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

Re-run PR review on schedule

Loop/schedule

Re-invoke a specific PR review skill every 20 minutes until the review completes or you stop it.

prompt
→ Claude
/loop 20m /review-pr 1234 , to re-run that skill each iteration. {/ min-version: 2.1.196 /}As of v2.1.196, a scheduled fire only runs skills that Claude is [allowed to invoke on its own](/en/skills#control-who-invokes-a-skill). The following reach Claude as plain text instead of executing

Ship specs through code review

Loop/loop

Run spec-driven workflow loop every 10 minutes: plan work, collect reviews, execute tasks, open pull requests.

prompt
→ Claude
/loop 10m /flow-next:pilot # build loop: ready spec → plan → reviews → work → draft PR Cap the run at 15 passes.
cimedium riskclaude-codecodex

Get the build green

Loop/goal

Run the build, fix the first error, and repeat until npm run build exits 0, with a 10-turn cap.

prompt
→ Claude
/goal `npm run build` exits 0 — run the build, fix the first error, repeat until it succeeds; stop after 10 turns