Use after creating a PR to monitor CI and automatically fix failures before reporting back. Fires automatically after PR creation. Do not report the PR as ready until CI is green.
Announce at start: "Monitoring CI for this PR -- will fix any failures before reporting back."
git branch --show-currentgh pr list --head $(git branch --show-current) --json number,title,url,statusCheckRollup 2>/dev/nullgh run list --branch $(git branch --show-current) --limit 5
If no runs found yet, wait 15 seconds and retry. CI may not have triggered immediately after push.
# Get the most recent run ID
RUN_ID=$(gh run list --branch $(git branch --show-current) --limit 1 --json databaseId -q '.[0].databaseId')
# Watch it to completion
gh run watch $RUN_ID
gh run view $RUN_ID --json conclusion -q '.conclusion'
If success: Report back. CI is green. PR is ready for review.
If failure: Proceed to Step 4.
If cancelled or skipped: Note it and report -- do not attempt to fix.
# Get failed job details
gh run view $RUN_ID --log-failed
Read the full failure output. Identify:
Apply the minimal fix. Do not refactor surrounding code.
For test failures: check if the test expectation is wrong (requirement changed) or the implementation is wrong. Fix the right one.
For lint/type errors: fix the specific violation only.
After fixing:
git add <changed files>
git commit -m "fix: address CI failure -- <brief description>"
git push
Go back to Step 1. Watch the new run triggered by the push.
Attempt limit: After 3 fix attempts with continued failures, stop and report:
CI is still failing after 3 fix attempts.
Failing job: <name>
Error: <message>
Cannot resolve automatically -- needs your attention.
PR: <url>
Report back concisely:
CI passed. PR is ready for review: <url>
Do not summarize what was fixed unless asked.