GitHub CI Auto Fix
Contract
Prereqs:
- Run inside the target git repo (or pass
--repo).
git, gh, and python3 available on PATH.
semantic-commit and git-scope available on PATH (required for commits).
gh auth status succeeds for the repo (workflow scope required for logs).
- Push access to the target branch (PR branch or specified branch).
Inputs:
--repo <path>: repo working directory (default .).
--pr <number|url>: PR number or URL (optional).
--ref <branch|sha>: branch name or commit SHA (optional).
--branch <name>: branch name to inspect (alias of --ref).
--commit <sha>: commit SHA to inspect (alias of --ref).
--limit <n>: max workflow runs to inspect when using branch/commit targets (default 20).
- PR-only flags:
--required (only required checks).
- Optional log extraction flags:
--max-lines, --context, --json.
Outputs:
- One or more fix commits pushed to the target branch.
- CI ends green (no failing required checks) or a terminal report of what blocked automation.
- Text summary or JSON report of failing checks (including log snippets when available) for each iteration.
Exit codes:
- N/A (multi-command workflow; failures surfaced from underlying commands).
Failure modes:
- Not inside a git repo or unable to resolve the PR/branch/commit target.
gh missing or unauthenticated for the repo.
semantic-commit/git-scope missing (cannot auto-commit).
gh pr checks field drift; fallback fields still fail.
gh run list failed for branch/commit targets.
- Logs unavailable (pending, external provider, or job log is a zip payload).
- Insufficient permissions to push to the target branch.
Scripts (only entrypoints)
$AGENT_HOME/skills/automation/gh-fix-ci/scripts/gh-fix-ci.sh
$AGENT_HOME/skills/automation/gh-fix-ci/scripts/inspect_ci_checks.py
TL;DR (fast paths)
$AGENT_HOME/skills/automation/gh-fix-ci/scripts/gh-fix-ci.sh --pr 123
$AGENT_HOME/skills/automation/gh-fix-ci/scripts/gh-fix-ci.sh --ref main
$AGENT_HOME/skills/automation/gh-fix-ci/scripts/inspect_ci_checks.py --ref main --json
Trigger
Use this skill when the user wants end-to-end CI fixing (no manual review pauses): diagnose, fix, commit, push, and keep iterating until CI
is green.
Workflow
- Verify
gh authentication with gh auth status. If unauthenticated, ask the user to run gh auth login (repo + workflow scopes).
- Resolve the target:
- If the user provided
--pr, use it.
- If the user provided
--ref/--branch/--commit, use that.
- Otherwise attempt
gh pr view --json number,url on the current branch; if unavailable, fall back to the current branch name (or HEAD
commit when detached).
- Inspect failing checks (GitHub Actions only):
- For PR targets: run
inspect_ci_checks.py, which calls gh pr checks.
- For branch/commit targets: run
inspect_ci_checks.py, which calls gh run list + gh run view.
- For each failure, capture the check name, run URL, and log snippet.
- Handle external providers:
- If
detailsUrl is not a GitHub Actions run, label as external and report the URL only.
- Auto-fix loop (repeat until green):
- Reproduce locally when feasible (prefer the repo’s documented lint/test commands; otherwise use the failing command shown in logs).
- Implement the minimal fix; avoid refactors.
- Run the most relevant local validation command(s) as a gate (lint/test/build as applicable).
- Commit using
semantic-commit-autostage (single commit per iteration unless splitting is clearly beneficial).
- Push the current branch (update the PR branch when targeting a PR).
- Wait for CI:
- PR:
gh pr checks <pr> --watch --interval 10 --required (wait until required checks finish, then confirm pass/fail)
- Branch/commit: watch the latest run for the pushed SHA (use
gh run list then gh run watch <run-id> --interval 10 --exit-status)
- If CI still fails, inspect again and continue the loop.
Notes
inspect_ci_checks.py returns exit code 1 when failures remain so it can be used in automation.
- Pending logs are reported as
log_pending; rerun after the workflow completes.
- Guardrail: if the failure indicates missing secrets, infra outage, or an external provider, stop and report the blocking detail/URL
instead of guessing.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: graysurf-agent-kit-gh-fix-ci3description: GitHub CI Auto Fix4---56# GitHub CI Auto Fix78## Contract910Prereqs:1112- Run inside the target git repo (or pass `--repo`).13- `git`, `gh`, and `python3` available on `PATH`.14- `semantic-commit` and `git-scope` available on `PATH` (required for commits).15- `gh auth status` succeeds for the repo (workflow scope required for logs).16- Push access to the target branch (PR branch or specified branch).1718Inputs:1920- `--repo <path>`: repo working directory (default `.`).21- `--pr <number|url>`: PR number or URL (optional).22- `--ref <branch|sha>`: branch name or commit SHA (optional).23- `--branch <name>`: branch name to inspect (alias of `--ref`).24- `--commit <sha>`: commit SHA to inspect (alias of `--ref`).25- `--limit <n>`: max workflow runs to inspect when using branch/commit targets (default `20`).26- PR-only flags: `--required` (only required checks).27- Optional log extraction flags: `--max-lines`, `--context`, `--json`.2829Outputs:3031- One or more fix commits pushed to the target branch.32- CI ends green (no failing required checks) or a terminal report of what blocked automation.33- Text summary or JSON report of failing checks (including log snippets when available) for each iteration.3435Exit codes:3637- N/A (multi-command workflow; failures surfaced from underlying commands).3839Failure modes:4041- Not inside a git repo or unable to resolve the PR/branch/commit target.42- `gh` missing or unauthenticated for the repo.43- `semantic-commit`/`git-scope` missing (cannot auto-commit).44- `gh pr checks` field drift; fallback fields still fail.45- `gh run list` failed for branch/commit targets.46- Logs unavailable (pending, external provider, or job log is a zip payload).47- Insufficient permissions to push to the target branch.4849## Scripts (only entrypoints)5051- `$AGENT_HOME/skills/automation/gh-fix-ci/scripts/gh-fix-ci.sh`52- `$AGENT_HOME/skills/automation/gh-fix-ci/scripts/inspect_ci_checks.py`5354## TL;DR (fast paths)5556```bash57$AGENT_HOME/skills/automation/gh-fix-ci/scripts/gh-fix-ci.sh --pr 12358$AGENT_HOME/skills/automation/gh-fix-ci/scripts/gh-fix-ci.sh --ref main59$AGENT_HOME/skills/automation/gh-fix-ci/scripts/inspect_ci_checks.py --ref main --json60```6162## Trigger6364Use this skill when the user wants end-to-end CI fixing (no manual review pauses): diagnose, fix, commit, push, and keep iterating until CI65is green.6667## Workflow68691. Verify `gh` authentication with `gh auth status`. If unauthenticated, ask the user to run `gh auth login` (repo + workflow scopes).702. Resolve the target:71 - If the user provided `--pr`, use it.72 - If the user provided `--ref`/`--branch`/`--commit`, use that.73 - Otherwise attempt `gh pr view --json number,url` on the current branch; if unavailable, fall back to the current branch name (or `HEAD`74 commit when detached).753. Inspect failing checks (GitHub Actions only):76 - For PR targets: run `inspect_ci_checks.py`, which calls `gh pr checks`.77 - For branch/commit targets: run `inspect_ci_checks.py`, which calls `gh run list` + `gh run view`.78 - For each failure, capture the check name, run URL, and log snippet.794. Handle external providers:80 - If `detailsUrl` is not a GitHub Actions run, label as external and report the URL only.815. Auto-fix loop (repeat until green):82 - Reproduce locally when feasible (prefer the repo’s documented lint/test commands; otherwise use the failing command shown in logs).83 - Implement the minimal fix; avoid refactors.84 - Run the most relevant local validation command(s) as a gate (lint/test/build as applicable).85 - Commit using `semantic-commit-autostage` (single commit per iteration unless splitting is clearly beneficial).86 - Push the current branch (update the PR branch when targeting a PR).87 - Wait for CI:88 - PR: `gh pr checks <pr> --watch --interval 10 --required` (wait until required checks finish, then confirm pass/fail)89 - Branch/commit: watch the latest run for the pushed SHA (use `gh run list` then `gh run watch <run-id> --interval 10 --exit-status`)90 - If CI still fails, inspect again and continue the loop.9192## Notes9394- `inspect_ci_checks.py` returns exit code `1` when failures remain so it can be used in automation.95- Pending logs are reported as `log_pending`; rerun after the workflow completes.96- Guardrail: if the failure indicates missing secrets, infra outage, or an external provider, stop and report the blocking detail/URL97 instead of guessing.9899---100> Converted and distributed by [TomeVault](https://tomevault.io/claim/graysurf) — claim your Tome and manage your conversions.101<!-- tomevault:4.0:skill_md:2026-04-13 -->