| name | diagnose-ci-failures |
| description | Diagnose CI failures for a PR using the GitHub CLI, extract error logs, and generate a plan to fix them. Use when the user asks to check CI status, pull CI issues, triage test failures, or investigate PR build failures. |
diagnose-ci-failures
Programmatically diagnose CI failures for a PR and generate a plan to fix them.
Overview
This skill provides a deterministic workflow to check CI status for a PR, extract failure logs, analyze errors, and create a plan (not code changes) to resolve issues. The output is always a plan document that can be reviewed before execution.
Workflow
1. Verify PR exists for current branch
Get the current branch and check if a PR exists:
git branch --show-current
GH_PAGER=cat gh pr view <branch-name> --json number,title,url,state
If no PR exists, inform the user and offer to create one using the create-pr skill.
2. Check CI status
Fetch the status of all CI checks:
GH_PAGER=cat gh pr view <branch-name> --json statusCheckRollup
Parse the output to identify:
- Completed checks vs. in-progress checks
- Successful checks
- Failed checks with their names and details URLs
If CI is still running, inform the user which checks have already failed or passed, highlight the checks that are still running, and suggest waiting for completion before diagnosis.
3. Extract failure logs
For each failed check, pull the logs using the run ID from the status check:
GH_PAGER= gh run view <run-id> --log-failed