Diagnose CI
Investigate and diagnose CI pipeline failures.
Steps
-
Find the failure:
- If a
run_idis provided, usegh run view <run_id> --log-failed. - Otherwise, run
gh run list --status=failure --limit 5 --json databaseId,name,headBranch,conclusion,createdAtto find recent failures. - Pick the most recent failure on the current branch (or the most recent overall if none match).
- If a
-
Pull logs: Run
gh run view <id> --log-failedto get the failed step logs. If output is large, focus on the last 100 lines of the failing step. -
Diagnose: Analyze the logs to identify:
- The specific step that failed
- The root cause (compile error, test failure, lint issue, missing secret, timeout, etc.)
- The relevant file(s) and line(s) if applicable
-
Suggest fix: Based on the diagnosis:
- If it’s a code issue: show the fix and offer to apply it
- If it’s a config issue (missing secret, wrong action version): explain what to change
- If it’s flaky (timeout, network): suggest re-running with
gh run rerun <id>
-
Report: Present a concise summary:
## CI Failure: <workflow name> (run #<id>) - Branch: <branch> - Failed step: <step name> - Root cause: <explanation> - Fix: <what to do>
Rules
- Always check the current repo’s workflows first (
gh run list). - If
ghis not authenticated or the repo has no remote, report that clearly. - Don’t blindly re-run failed pipelines — diagnose first.