$npx -y skills add minghinmatthewlam/agent-guards --skill fix-ciCheck GitHub Actions status on the current PR, wait for checks to finish, analyze failures and review comments, fix issues, and repeat until CI passes. Use when a user asks to fix failing CI, check PR status, or get a PR merge-ready.
| 1 | Usage: |
| 2 | |
| 3 | - `/fix-ci` - Fix CI failures on current branch's PR |
| 4 | - `/fix-ci <pr-number>` - Fix specific PR |
| 5 | - `/fix-ci --check-only` - Only report status, don't fix |
| 6 | |
| 7 | **Instructions:** |
| 8 | |
| 9 | Automated CI fix loop. Wait for checks, inspect failures, fix, push, repeat until green. |
| 10 | |
| 11 | **Step 1: Parse Input** |
| 12 | |
| 13 | - Input: $ARGUMENTS |
| 14 | - If a PR number is provided, use that |
| 15 | - If `--check-only` flag is present, only report status without fixing |
| 16 | - If no arguments, detect PR for current branch via `gh pr view --json number,url` |
| 17 | |
| 18 | **Step 2: Readiness Gate** |
| 19 | |
| 20 | Before inspecting, ensure CI checks have finished running. Poll every 2 minutes (max 10 iterations / 20 minutes). |
| 21 | |
| 22 | ```bash |
| 23 | # Count checks still running |
| 24 | gh pr checks <pr-number> --json state --jq '[.[] | select(.state == "PENDING" or .state == "IN_PROGRESS" or .state == "QUEUED")] | length' |
| 25 | ``` |
| 26 | |
| 27 | - If 0 → proceed to Step 3 |
| 28 | - If > 0 → wait 2 minutes, retry |
| 29 | - After 10 retries → exit with timeout, report which checks never completed |
| 30 | |
| 31 | **On subsequent iterations** (after pushing a fix): also wait for CI to re-run on the new commit before inspecting again. |
| 32 | |
| 33 | **Step 3: Inspect Failures** |
| 34 | |
| 35 | Use the bundled inspection script for robust log extraction: |
| 36 | |
| 37 | ```bash |
| 38 | python "<path-to-skill>/scripts/inspect_pr_checks.py" --repo "." --pr "<pr-number>" --json |
| 39 | ``` |
| 40 | |
| 41 | The script handles: |
| 42 | - `gh` CLI field drift (auto-detects available fields, retries with fallbacks) |
| 43 | - Smart log extraction (finds failure markers, extracts context window) |
| 44 | - Job-level log fallback when run logs aren't available yet |
| 45 | - External check detection (non-GitHub Actions checks reported as URL-only) |
| 46 | |
| 47 | If the script is unavailable, fall back to manual inspection: |
| 48 | |
| 49 | ```bash |
| 50 | gh pr checks <pr-number> --json name,state,conclusion,detailsUrl |
| 51 | gh run view <run-id> --log-failed |
| 52 | ``` |
| 53 | |
| 54 | **External checks** (Buildkite, CircleCI, etc.): report the URL only, mark as out-of-scope. Don't attempt to fetch logs from non-GitHub Actions providers. |
| 55 | |
| 56 | **Step 4: Analyze and Fix** |
| 57 | |
| 58 | For each failure, read the log snippet and determine the fix. Let the repo context guide you — read project config files, package.json, Makefile, etc. to find the right commands. Don't assume specific tooling. |
| 59 | |
| 60 | General patterns: |
| 61 | - **Lint errors**: Read failing files, fix issues, run the project's lint command to verify |
| 62 | - **Type errors**: Fix type mismatches, run the project's type-check command |
| 63 | - **Test failures**: Read test + implementation files, fix the root cause, run the specific test |
| 64 | - **Generated file drift**: Run the project's generation commands, stage the output |
| 65 | |
| 66 | If `--check-only`, skip this step — just report findings and exit. |
| 67 | |
| 68 | **Step 5: Commit and Push** |
| 69 | |
| 70 | ```bash |
| 71 | git add <specific-files> |
| 72 | git commit -m "fix: resolve CI failures |
| 73 | |
| 74 | - Fixed [describe what was fixed] |
| 75 | - Resolves failures in [job names]" |
| 76 | git push |
| 77 | ``` |
| 78 | |
| 79 | **Step 6: Loop Until Success** |
| 80 | |
| 81 | After pushing, go back to Step 2 (readiness gate). Wait for CI to re-run, then re-inspect. |
| 82 | |
| 83 | - Max 3 iterations |
| 84 | - If still failing after 3 iterations → report remaining failures, ask for help |
| 85 | |
| 86 | **Step 7: Check PR Review Comments** |
| 87 | |
| 88 | After CI passes (or in parallel with fixing), fetch review feedback from all sources: |
| 89 | |
| 90 | ```bash |
| 91 | # Code-level inline comments |
| 92 | gh api "repos/{owner}/{repo}/pulls/<pr-number>/comments" > /tmp/pr_review_comments.json |
| 93 | |
| 94 | # PR-level review bodies |
| 95 | gh api "repos/{owner}/{repo}/pulls/<pr-number>/reviews" > /tmp/pr_reviews.json |
| 96 | |
| 97 | # General PR conversation |
| 98 | gh pr view <pr-number> --comments |
| 99 | ``` |
| 100 | |
| 101 | **Triage each actionable comment into tiers:** |
| 102 | - **Fix** — real bug, security issue, logic error, correctness problem |
| 103 | - **Consider** — reasonable improvement, not critical |
| 104 | - **Skip** — nitpick, stylistic preference, bot noise |
| 105 | |
| 106 | Human reviewer comments weighted higher than bot comments. Present the triage to the user and ask which to address. After fixing approved comments, commit, push, and loop back to Step 2. |
| 107 | |
| 108 | **Step 8: Report Results** |
| 109 | |
| 110 | ``` |
| 111 | ## CI Fix Results: PR #<number> |
| 112 | |
| 113 | **Status:** PASSED | FAILED | IN_PROGRESS |
| 114 | **Branch:** <branch> | **URL:** <pr-url> |
| 115 | |
| 116 | ### Actions Taken |
| 117 | 1. [Fix description] |
| 118 | 2. [Fix description] |
| 119 | |
| 120 | ### Review Comments |
| 121 | - [Summary of addressed/skipped comments] |
| 122 | |
| 123 | ### Next Steps |
| 124 | [If still failing: what needs manual intervention] |
| 125 | ``` |
| 126 | |
| 127 | **Error Handling:** |
| 128 | - `gh` not authenticated → inform user to run `gh auth login` |
| 129 | - No PR exists → inform user to create PR first |
| 130 | - Max iterations reached → report remaining failures |
| 131 | - External checks failing → report URL, mark out-of-scope |
| 132 | |
| 133 | ## Bundled Resources |
| 134 | |
| 135 | ### scripts/inspect_pr_checks.py |
| 136 | |
| 137 | Robust CI check inspector. Handles gh CLI field drift, smart log context extraction, job-level log fallbacks, and external check detection. |
| 138 | |
| 139 | ```bash |
| 140 | python "<path-to-s |