Read CI failure logs for the current branch's pull request and fix all reported errors.
Key principles
- Wait for CI to finish: Do not act on pending checks. Confirm all jobs have a terminal status (pass/fail) before reading logs.
- Fix root causes: Diagnose why the failure happened before editing files. Do not blindly patch error messages.
- Verify before pushing: Re-run the equivalent local command (e.g.,
cargo lint,cargo xtask test) after fixes to confirm the error is resolved.
Execution steps (in order)
Find the PR for the current branch:
- Run
gh pr list --head $(git branch --show-current) --json number,title,urlto find the open PR. - If no PR exists, inform the user and stop.
- Run
Check CI status:
- Run
gh pr checks <number> --repo <owner/repo>to list all checks and their status. - If any checks are still pending, inform the user and wait or stop.
- If all checks pass, inform the user and stop — nothing to fix.
- Run
Fetch failure logs:
- For each failing check, extract the run ID from the check URL.
- Run
gh run view <run-id> --log-failedto retrieve only the failed step logs. - If the output is too large, use
gh run view <run-id> --log-failed | head -200to get the most relevant part.
Diagnose and summarize errors:
- Parse the log output to identify the failing job, step name, and error message.
- Map errors to files and line numbers where possible (e.g., compiler errors, lint violations, test failures).
- Present a clear summary to the user before making changes.
Fix each error:
- Read the relevant files before editing.
- Apply the minimal change that resolves the error. Do not refactor or clean up unrelated code.
- After all fixes, run the local equivalent of the failing CI step to verify the fix (e.g.,
cargo lintfor lint failures,cargo xtask testfor test failures,cargo +nightly fmt -- --checkfor format failures).
Commit and push:
- Follow the
commit-codeskill conventions: concise summary,Signed-off-by, andCo-Authored-By. - Use commit type
fixfor build/test errors,stylefor formatting failures,cifor CI config issues. - Push to the remote branch.
- Follow the
Notes
- A single CI run may contain multiple failing jobs (e.g.,
ubuntu-latestandmacos-latest). Check all of them — the root cause is often the same but sometimes differs by platform. - If a failure is flaky (network timeout, cache miss, unrelated infrastructure error), inform the user rather than attempting a code fix.
- If fixing the error requires a design decision, surface it to the user rather than making the call unilaterally.