Detect failed GitHub Actions runs, reproduce failures locally, auto-fix code issues, and report actionable steps for infrastructure failures. Use when user says "fix workflow", "fix CI", "fix pipeline", "why did CI fail", "check actions", or wants to investigate failed GitHub Actions runs.
Diagnose and fix failed GitHub Actions runs. Code failures are reproduced locally and fixed. Infrastructure failures produce an actionable report.
Parse arguments from ARGUMENTS:
--dry-run: Diagnose and report only, do not apply fixesgh CLI is authenticated: run gh auth status. If not authenticated, stop and tell the user to run gh auth login.git status --porcelain. If dirty, warn the user that fixes will mix with existing changes and ask whether to proceed.gh run list --status=failure --limit 10 --json databaseId,workflowName,headBranch,createdAt,event,url(workflowName, headBranch). Keep only the most recent run per group.Process each failed run sequentially:
gh run view <id> --json workflowName,headBranch,headSha,conclusion,jobs,urlgh run view <id> --log-failed — capture the error output--log-failed returns empty, report: "Logs unavailable — re-run with gh run rerun <id>" and skip this run..github/workflows/*.yml in the repo. Match by comparing the YAML name: field to the workflowName from the run JSON. If no match by name, try matching by filename.--log-failed output, identify which job and step failed.run: command and working-directory (or the job-level defaults.run.working-directory).run: key, does not reference ${{ secrets.* }}, does not connect to remote services, AND the failure is caused by code that can be fixed (e.g., type errors, test failures, lint issues, build errors).run: key and is locally reproducible, BUT the failure is caused by a difference between the local dev environment and CI — not by the code itself. Signals: the command succeeds locally but fails in CI, or the error references version mismatches, missing system deps, or lock file sync issues (e.g., npm ci failing because package-lock.json was generated by a different npm version).uses: (a GitHub Action), references secrets, or connects to remote services.--dry-run, skip steps 3-5 and report what you would fix.Do NOT attempt a code fix — the code is fine, the environment is wrong. Diagnose the mismatch and report:
.nvmrc, .node-version, engines field in package.json, or similar version pinning — suggest adding one if missing.Do NOT attempt to fix. Generate a report with:
Fix Workflow complete
Fixed: N | Reported: N | Skipped: N
Fixed:
- [workflow] step "X" on branch Y — one-line description of fix
Needs manual action:
- [workflow] step "X" on branch Y — one-line description + action
Files modified: [list]
Remind the user: "Fixes applied to working tree but NOT committed. Review with git diff."
gh not authenticated: Stop with instructions to run gh auth login.github/workflows/ directory found"gh run rerun <id>