Fix CI Until Green
FeaturedOn demandAbout Fix CI Until Green
A manually started loop for a failing CI run on the current branch. Each round pulls the most recent failed run, finds the cause, fixes and pushes it, then reads the conclusion of the newest run. It stops after at most 8 rounds.
Key features
- 01Manual trigger, capped at 8 rounds
- 02Judges success from the conclusion field returned by gh run list
- 03Starts every round from the most recent failed run
- 04Supports Cursor and Claude Code
Use cases
- 01CI turns red on a branch after a dependency bump
- 02Build or lint step fails after a refactor
- 03New pipeline errors appear after merging the main branch
- Goal
- The latest CI run on this branch passes.
- Exit when
- Stop when the latest run's conclusion is success, or after 8 rounds without it.
- Between iterations run
- gh run list --branch $(git branch --show-current) --limit 1 --json conclusion -q '.[0].conclusion'
Launch prompt
Paste into Cursor / Claude Code. The agent repeats the steps below until the exit condition is met.
Start the "Fix CI Until Green" loop. Goal: The latest CI run on this branch passes. Max iterations: 8. Step 1: Fetch failed run — List the most recent failed CI run on the current branch and note which job and step failed. `gh run list --branch $(git branch --show-current) --status failure --limit 1` Step 2: Find and fix the cause — Read the failure logs, identify the root cause and change the code locally, touching only what relates to that failure. Step 3: Push the change — Commit the fix, push it to the current branch and wait for the new CI run to finish. Step 4: Push and verify — Read the conclusion of the latest run. If it is success the loop ends; otherwise the next round begins. `gh run list --branch $(git branch --show-current) --limit 1 --json conclusion -q '.[0].conclusion'` Between iterations run: `gh run list --branch $(git branch --show-current) --limit 1 --json conclusion -q '.[0].conclusion'` Exit when: Stop when the latest run's conclusion is success, or after 8 rounds without it.
Steps
Each round runs in order; if the exit condition isn’t met, another round starts, up to 8.
List the most recent failed CI run on the current branch and note which job and step failed.
gh run list --branch $(git branch --show-current) --status failure --limit 1Read the failure logs, identify the root cause and change the code locally, touching only what relates to that failure.
Commit the fix, push it to the current branch and wait for the new CI run to finish.
Read the conclusion of the latest run. If it is success the loop ends; otherwise the next round begins.
gh run list --branch $(git branch --show-current) --limit 1 --json conclusion -q '.[0].conclusion'Supported agents
Coding agents that can run this loop directly.